@@ -1830,6 +1830,7 @@ def set_names_and_parse_actions():
1830
1830
| p .underset
1831
1831
| p .sqrt
1832
1832
| p .overline
1833
+ | p .auto_delim
1833
1834
)
1834
1835
1835
1836
p .simple <<= (
@@ -2206,6 +2207,16 @@ def subsuper(self, s, loc, toks):
2206
2207
result = Hlist ([vlist ])
2207
2208
return [result ]
2208
2209
2210
+ # Set the minimum shifts for the superscript and subscript.
2211
+ constants = _get_font_constant_set (state )
2212
+ if isinstance (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
+
2209
2220
# We remove kerning on the last character for consistency (otherwise
2210
2221
# it will compute kerning based on non-shrunk characters and may put
2211
2222
# them too close together when superscripted)
@@ -2232,7 +2243,6 @@ def subsuper(self, s, loc, toks):
2232
2243
nucleus = Hlist ([nucleus ])
2233
2244
2234
2245
# Handle regular sub/superscripts
2235
- constants = _get_font_constant_set (state )
2236
2246
lc_height = last_char .height
2237
2247
lc_baseline = 0
2238
2248
if self .is_dropsub (last_char ):
@@ -2260,7 +2270,12 @@ def subsuper(self, s, loc, toks):
2260
2270
if self .is_dropsub (last_char ):
2261
2271
shift_down = lc_baseline + constants .subdrop * xHeight
2262
2272
else :
2263
- shift_down = constants .sub1 * xHeight
2273
+ # TODO Optimise.
2274
+ if shift_down < constants .sub1 * xHeight :
2275
+ shift_down = constants .sub1 * xHeight
2276
+ clr = x .height - xHeight * 4 / 5
2277
+ if shift_down < clr :
2278
+ shift_down = clr
2264
2279
x .shift_amount = shift_down
2265
2280
else :
2266
2281
x = Hlist ([Kern (superkern ), super ])
0 commit comments