@@ -1191,7 +1191,7 @@ def get_underline_thickness(self, font, fontsize, dpi):
1191
1191
'stix' : 0.10 ,
1192
1192
'stixsans' : 0.10 }
1193
1193
## Percentage of x-height that sub/superscripts drop below the baseline
1194
- SUBDROP = {'cm' : 0.3 ,
1194
+ SUBDROP = {'cm' : 0.2 ,
1195
1195
'stix' : 0.3 ,
1196
1196
'stixsans' : 0.3 }
1197
1197
# Percentage of x-height that superscripts drop below the baseline
@@ -1212,6 +1212,11 @@ def get_underline_thickness(self, font, fontsize, dpi):
1212
1212
DELTA = {'cm' : 0.10 ,
1213
1213
'stix' : 0.15 ,
1214
1214
'stixsans' : 0.25 }
1215
+ # Percentage of x-height that supercripts are offset relative to the subscript
1216
+ # for integrals
1217
+ DELTAINTEGRAL = {'cm' : 0.5 ,
1218
+ 'stix' : 0.5 ,
1219
+ 'stixsans' : 0.5 }
1215
1220
1216
1221
class MathTextWarning (Warning ):
1217
1222
pass
@@ -2757,9 +2762,13 @@ def subsuper(self, s, loc, toks):
2757
2762
shift_down = nucleus .depth + SUBDROP [fs ] * xHeight
2758
2763
else :
2759
2764
shift_down = SUBDROP [fs ] * xHeight
2765
+ integral = (nucleus .height + nucleus .depth ) > 2 * xHeight
2760
2766
if super is None :
2761
2767
# node757
2762
- x = Hlist ([sub ])
2768
+ if integral :
2769
+ x = Hlist ([Kern (- DELTA [fs ] * nucleus .height ),sub ])
2770
+ else :
2771
+ x = Hlist ([sub ])
2763
2772
x .shrink ()
2764
2773
x .width += SCRIPT_SPACE [fs ] * xHeight
2765
2774
shift_down = max (shift_down , SUB1 [fs ] * xHeight )
@@ -2768,16 +2777,25 @@ def subsuper(self, s, loc, toks):
2768
2777
x .shift_amount = shift_down / 2.
2769
2778
else :
2770
2779
if self .is_slanted (last_char ):
2771
- x = Hlist ([Kern (DELTA [fs ] * super .height ),super ])
2780
+ f = DELTA [fs ]
2781
+ if integral : f = DELTAINTEGRAL [fs ]
2782
+ x = Hlist ([Kern (f * nucleus .height ),super ])
2772
2783
else :
2773
2784
x = Hlist ([super ])
2774
2785
x .shrink ()
2775
2786
x .width += SCRIPT_SPACE [fs ] * xHeight
2776
- shift_up = SUP1 [fs ] * xHeight
2787
+ if integral :
2788
+ shift_up = max (shift_up ,SUP1 [fs ] * xHeight )
2789
+ else :
2790
+ shift_up = SUP1 [fs ] * xHeight
2777
2791
if sub is None :
2778
2792
x .shift_amount = - shift_up
2779
2793
else : # Both sub and superscript
2780
- y = Hlist ([sub ])
2794
+ if integral :
2795
+ y = Hlist ([Kern (- DELTA [fs ] * nucleus .height ),sub ])
2796
+ else :
2797
+ y = Hlist ([sub ])
2798
+ #y = Hlist([sub])
2781
2799
y .shrink ()
2782
2800
y .width += SCRIPT_SPACE [fs ] * xHeight
2783
2801
shift_down = max (shift_down , SUB2 [fs ] * xHeight )
0 commit comments