Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eaad1a0

Browse files
committed
Implement underline logic as in TeX
[skip ci]
1 parent cc6cead commit eaad1a0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib/matplotlib/_mathtext.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,8 @@ def csnames(group: str, names: Iterable[str]) -> Regex:
22072207

22082208
p.overline = cmd(r"\overline", p.required_group("body"))
22092209

2210+
p.underline = cmd(r"\underline", p.required_group("body"))
2211+
22102212
p.overset = cmd(
22112213
r"\overset",
22122214
p.optional_group("annotation") + p.optional_group("body"))
@@ -2259,6 +2261,7 @@ def csnames(group: str, names: Iterable[str]) -> Regex:
22592261
| p.underset
22602262
| p.sqrt
22612263
| p.overline
2264+
| p.underline
22622265
| p.text
22632266
| p.boldsymbol
22642267
| p.substack
@@ -2945,6 +2948,21 @@ def overline(self, toks: ParseResults) -> T.Any:
29452948
hlist = Hlist([rightside])
29462949
return [hlist]
29472950

2951+
def underline(self, toks: ParseResults) -> T.Any:
2952+
body = toks["body"]
2953+
state = self.get_state()
2954+
thickness = state.get_current_underline_thickness()
2955+
kern = 3 * thickness
2956+
# Place the underline below `body` (node735).
2957+
vlist = Vlist([
2958+
Hlist([body]),
2959+
Kern(kern),
2960+
Hrule(state, thickness),
2961+
])
2962+
# Make `body` rest on the baseline.
2963+
vlist.shift_amount = thickness / 2 + kern + body.depth
2964+
return [Hlist([vlist])]
2965+
29482966
def _auto_sized_delimiter(self, front: str,
29492967
middle: list[Box | Char | str],
29502968
back: str) -> T.Any:

0 commit comments

Comments
 (0)