How to raise baseline for math subscripts?

By default, the subscripts in math mode land lower than in LaTeX,
e.g. compare

$X_X$

vs. the same thing in LaTeX. Is there a way to control where math.attach puts the baseline for the lower attachments?

Something like

$X#sub(size: 0.7em, baseline: 0.3em)[$X$]$

gets me close to what I would like, but with this method, the subscript gets styled differently than in $X_X$ (the subscripts end up being slanted differently). Is there a better / more correct way to go about raising the baseline of a subscript?

Hi! For this issue, you can use sizes functions to control it.

$X_X$ vs. $X_#move(dy: -0.4em)[$script(X)$]$

ๅ›พ็‰‡

(I believe the relative position is defined by the font, and the result differs because Typst uses New Computer Modern but LaTeX might use Computer Modern, which are similar but not identical. I canโ€™t prove my claim at present, though.)

2 Likes

Indeed! If you use \usepackage{fontsetup} in LaTeX it will use the same font as in Typst (New Computer Modern Math) and you get the same result:

image (LaTeX)
image (Typst)

3 Likes