latex3/unicode-math

Superscript/subscript kerning when using text font

Opened this issue · 5 comments

It is usually considered proper form to switch to text font for the subscript if the subscript is not a variable or number (eg. n_{\mathrm{in}}). However, this ignores the kerning for the subscript in the math table. Is it possible somehow to change this behaviour in unicode-math? Or is this the same "no kerning between different math families" issue from latex that cannot be fixed?

There is a workaround for this BTW: adding \Umathchar"0"00"00200B at the start of the subscript before the \mathrm command shifts the no-kerning boundary to inside the subscript, without adding space since this is a zero-width character, so the subscript kerning is now respected.

Can you clarify the issue you are seeing?

with

\documentclass{article}

\usepackage{unicode-math}

\begin{document}

\ifx\directlua\undefined XeTeX\else LuaTeX\fi:
$
P_{in} +
P_{\symrm{in}} +
P_{\mathrm{in}} +
P_{\Umathchar"0"000"00200B \mathrm{in}}
$
\end{document}

I get different behaviour with luatex and xetex

image

image

so in luatex the subscript is kerned under the P in all cases, but in xetex the zero width character prevents the kerning

Use need to use STIX2 to see the issue. I think LM is using a negative bearing.

@xsrvmy ah adding \setmathfont{STIX Two Math} I get

image

image

So yes it shows the issue there, although having the effects be both engine and font dependent might make it "interesting" to handle in a common way in neutral code in the package. Something for @wspr :-)

This is a font and engine issue similar to #592. The font has (excessive) math kerning for P and each engine is applying it differently.

This issue should be closed, see #592 (comment)