@@ -1187,7 +1187,7 @@ def get_underline_thickness(self, font, fontsize, dpi):
1187
1187
# get any smaller
1188
1188
NUM_SIZE_LEVELS = 6
1189
1189
# Percentage of x-height of additional horiz. space after sub/superscripts
1190
- SCRIPT_SPACE = - 0.10
1190
+ SCRIPT_SPACE = 0.07
1191
1191
# Percentage of x-height that sub/superscripts drop below the baseline
1192
1192
SUBDROP = 0.3
1193
1193
# Percentage of x-height that superscripts drop below the baseline
@@ -1196,7 +1196,7 @@ def get_underline_thickness(self, font, fontsize, dpi):
1196
1196
SUB1 = 0.0
1197
1197
# Percentage of x-height that supercripts are offset relative to the subscript
1198
1198
# for slanted nuclei
1199
- DELTA = 0.15
1199
+ DELTA = 0.10
1200
1200
1201
1201
class MathTextWarning (Warning ):
1202
1202
pass
@@ -2631,7 +2631,6 @@ def is_slanted(self, nucleus):
2631
2631
2632
2632
def subsuper (self , s , loc , toks ):
2633
2633
assert (len (toks )== 1 )
2634
- # print 'subsuper', toks
2635
2634
2636
2635
nucleus = None
2637
2636
sub = None
@@ -2686,6 +2685,8 @@ def subsuper(self, s, loc, toks):
2686
2685
"Subscript/superscript sequence is too long. "
2687
2686
"Use braces { } to remove ambiguity." )
2688
2687
2688
+ last_char = nucleus .children [- 2 ] if isinstance (nucleus ,Hlist ) else nucleus
2689
+
2689
2690
state = self .get_state ()
2690
2691
rule_thickness = state .font_output .get_underline_thickness (
2691
2692
state .font , state .fontsize , state .dpi )
@@ -2735,25 +2736,26 @@ def subsuper(self, s, loc, toks):
2735
2736
shift_down = SUBDROP * xHeight
2736
2737
if super is None :
2737
2738
# node757
2738
- sub .shrink ()
2739
2739
x = Hlist ([sub ])
2740
+ x .shrink ()
2740
2741
x .width += SCRIPT_SPACE * xHeight
2741
2742
shift_down = max (shift_down , SUB1 )
2742
2743
clr = x .height - (abs (xHeight * 4.0 ) / 5.0 )
2743
2744
shift_down = max (shift_down , clr )
2744
2745
x .shift_amount = shift_down / 2.
2745
2746
else :
2746
- super .shrink ()
2747
- x = Hlist ([super ])
2747
+ if self .is_slanted (last_char ):
2748
+ x = Hlist ([Kern (DELTA * super .height ),super ])
2749
+ else :
2750
+ x = Hlist ([super ])
2751
+ x .shrink ()
2748
2752
x .width += SCRIPT_SPACE * xHeight
2749
2753
shift_up = SUP1 * xHeight
2750
- if self .is_slanted (nucleus ):
2751
- x = Hlist ([Kern (DELTA * x .height ),x ])
2752
2754
if sub is None :
2753
2755
x .shift_amount = - shift_up
2754
2756
else : # Both sub and superscript
2755
- sub .shrink ()
2756
2757
y = Hlist ([sub ])
2758
+ y .shrink ()
2757
2759
y .width += SCRIPT_SPACE * xHeight
2758
2760
shift_down = max (shift_down , SUB1 * xHeight )
2759
2761
# If sub and superscript collide, move sup up
0 commit comments