Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit156b99a

Browse files
committed
Implement the TeX alignment of subscripts [skip ci]
No point running the tests if we are absolutely sure they are going to fail.
1 parentf278686 commit156b99a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

‎lib/matplotlib/_mathtext.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ def set_names_and_parse_actions():
18301830
|p.underset
18311831
|p.sqrt
18321832
|p.overline
1833+
|p.auto_delim
18331834
)
18341835

18351836
p.simple<<= (
@@ -2206,6 +2207,16 @@ def subsuper(self, s, loc, toks):
22062207
result=Hlist([vlist])
22072208
return [result]
22082209

2210+
# Set the minimum shifts for the superscript and subscript.
2211+
constants=_get_font_constant_set(state)
2212+
ifisinstance(nucleus,Char):
2213+
shift_up=0
2214+
shift_down=0
2215+
else:
2216+
# TODO Optimise and reduce line length.
2217+
shift_up=nucleus.height-constants.subdrop*xHeight*SHRINK_FACTOR
2218+
shift_down=nucleus.depth+constants.subdrop*xHeight*SHRINK_FACTOR
2219+
22092220
# We remove kerning on the last character for consistency (otherwise
22102221
# it will compute kerning based on non-shrunk characters and may put
22112222
# them too close together when superscripted)
@@ -2232,7 +2243,6 @@ def subsuper(self, s, loc, toks):
22322243
nucleus=Hlist([nucleus])
22332244

22342245
# Handle regular sub/superscripts
2235-
constants=_get_font_constant_set(state)
22362246
lc_height=last_char.height
22372247
lc_baseline=0
22382248
ifself.is_dropsub(last_char):
@@ -2260,7 +2270,12 @@ def subsuper(self, s, loc, toks):
22602270
ifself.is_dropsub(last_char):
22612271
shift_down=lc_baseline+constants.subdrop*xHeight
22622272
else:
2263-
shift_down=constants.sub1*xHeight
2273+
# TODO Optimise.
2274+
ifshift_down<constants.sub1*xHeight:
2275+
shift_down=constants.sub1*xHeight
2276+
clr=x.height-xHeight*4/5
2277+
ifshift_down<clr:
2278+
shift_down=clr
22642279
x.shift_amount=shift_down
22652280
else:
22662281
x=Hlist([Kern(superkern),super])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp