# Why is a subscript set in roman font placed differently

Consider the following MWE:

\documentclass{article}
\RequirePackage{fontspec,unicode-math}
\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}
\begin{document}
\showboxdepth\maxdimen
$\gamma_{e}\ne\gamma_{\mathrm{e}}\showlists$\showlists
\end{document}


It produces this output with LuaLaTeX:

As you can see, the two subscripts are placed differently.

The first \showlists contains no surprises:

### math mode entered at line 8
\mathord
.\fam0 𝛾
_\fam0 𝑒
\mathrel
.\fam0 ≠
\mathord
.\fam0 𝛾
_\fam4 e


But the second one does:

\mathon
\TU/STIXTwoMath(1)/m/n/10 𝛾
\kern-1.5
\hbox(3.6254+0.09818)x3.85008, shifted 2.09998, direction TLT
.\TU/STIXTwoMath(1)/m/n/7.01236 𝑒
\glue(\thickmuskip) 2.77771 plus 2.77771
\TU/STIXTwoMath(1)/m/n/10 ≠
\penalty 500
\glue(\thickmuskip) 2.77771 plus 2.77771
\TU/STIXTwoMath(1)/m/n/10 𝛾
\hbox(3.401+0.07013)x3.65373, shifted 2.09998, direction TLT
.\TU/STIXTwoText(1)/m/n/7.01236 e
\mathoff


Note the \kern-1.5, which tucks the subscript in under the gamma character on the left side, and the absence of a similar kern on the right side.

Why is this happening?

Edit: As egreg notes, this appears to be related to fonts – i.e., that the subscript comes from the text font and not the math font. Replacing \mathrm{e} by \symrm{e} cures it, in this case. However, if the subscript is a word, like “ess” or “disc”, this is not a good option, as the interletter spacing in the subscript is then wrong. Here is a workaround for that:

\Umathchardef\zwspace="0"0"200B
...
$\gamma_{\zwspace\mathrm{ess}}$


which adds a zero-width space from the math font as an ordinary math atom at the beginning of the subscript, allowing the normal subscript placement to take place. This has one shortcoming: If the next character is tall, that is not taken into account, and the subscript could be too far to the left.

I have reported this problem to the luatex list, and will report back here if I have some news from them.

• You should ask on the luatex list; if I compile with XeLaTeX, the kern is added also in the second case. Apr 10 '18 at 12:13
• On the other hand, if you use \symrm{e}, the kern is added also with LuaLaTeX. I guess it has to do with different fonts used. Apr 10 '18 at 12:16
• I get no kern at all. Which tex system and which version of the fonts are you using? OK: I see it with TL17 but not TL18. Apr 10 '18 at 12:21
• @UlrikeFischer I am on the latest (frozen) TL2017 on a mac. The STIX Math font is Version 2.00 b137 (according to otfinfo). Apr 10 '18 at 12:24
• I just edited my comment: I see it on TL17 but not on TL18. Apr 10 '18 at 12:25