# Math script size changed between unicode-math v0.8e and v0.8g?

I have just compiled an existing document using a more recent version of unicode-math and noticed that a lot of line/page breaks were different. The reason seems to be that the sizes of sub-/superscripts in math mode changed somewhere between unicode-math versions 0.8e and 0.8g.

For example, using the minimal document

\documentclass[12pt]{article}

\usepackage{unicode-math}

\begin{document}

$$x^Ax^Bx^Cx^Dx^Ex^Fx^Gx^Hx^Ix^Jx^Kx^Lx^Mx^Nx^Ox^Px^Qx^Rx^Sx^Tx^Ux^Vx^Wx^Xx^Yx^Z$$

\end{document}


unicode-math 0.8e yields

while unicode-math 0.8g gives

My questions is whether this is intentional/expected? In the release notes for unicode-math 0.8g, I see

• Better use of scriptstyle sizes in LuaTeX (I think a regression).

and indeed, as far as I can tell, only LuaTeX seems to be affected?

• The chosen size for the superscripts used to be 8pt like in standard LaTeX, now it's 8.41483pt, for both XeLaTeX and LuaLaTeX. – egreg Jun 28 '18 at 8:09
• @egreg Hm, interesting. Do you know if there is some kind of advantage to this new choice that’s worth it to make a breaking change? – Socob Jun 29 '18 at 8:46
• I'm not sure the effect was actually wanted. – egreg Jun 29 '18 at 8:52
• Opened issue at github.com/wspr/unicode-math/issues/478 – egreg Jun 29 '18 at 10:22
• @barbarabeeton The document uses 12pt – egreg Jun 29 '18 at 19:36

Edited to provide more details

I managed to track down the related changes made in v0.8g. In particular, the follow code was introduced in um-code-main.dtx:

\cs_new:Nn \@@_declare_math_sizes:
{
\dim_compare:nF { \fontdimen 10 \g_@@_trial_font == 0pt }
{
\DeclareMathSizes { \f@size } { \f@size }
{ \@@_fontdimen_to_scale:nN {10} \g_@@_trial_font }
{ \@@_fontdimen_to_scale:nN {11} \g_@@_trial_font }
}
}


We see that the unicode-math package intentionally overwrites the declaration of math sizes at \normalsize. This is because OpenType math fonts contain additional parameters ScriptPercentScaleDown (\fontdimen10) and ScriptScriptPercentScaleDown (\fontdimen11). For OpenType Latin Modern Math, these are 70 and 50, respectively.

Therefore, in a 12pt article, the intended font sizes (according to the new unicode-math) for first- and second-level scripts are 8.4pt and 6pt, respectively. Note that the LaTeX kernel legacy declarations are 8pt and 6pt for first- and second-level scripts in 12pt text. So, you would observe slightly larger first-level scripts using unicode-math.

There are more subtle differences in 12pt article between pdfLaTeX’s \usepackage{lmodern} and XeLaTeX/LuaLaTeX’s \usepackage{unicode-math} with OTF LM Math.

In the pdfLaTeX case, the design sizes used at text-size, script-size and script-script-size are LMMathItalic12, LMMathItalic8 and LMMathItalic6, respectively.

But in the XeLaTeX/LuaLaTeX case with \usepackage{unicode-math}, the text-size uses OTF LM Math 10pt font scaled up to 12pt, the script-size uses OTF LM Math 7pt font scaled up to 8.4pt, and the script-script-size uses OTF LM Math 5pt font scaled up to 6pt.

The strange 8.41483pt for the first-level script is due to the improper order of floating-point arithmetic.

I have provided a fix for the rounding error (not for honoring the original math size declarations, as I believe we should use the OpenType parameters) in the issue opened by @egreg:

\documentclass[12pt]{article}
\usepackage{unicode-math}

\ExplSyntaxOn
\cs_set:Nn \__um_fontdimen_to_percent:nN
{
\fp_eval:n { \dim_to_decimal:n { 65536 \fontdimen #1 #2 } / 100 }
}
\ExplSyntaxOff

\begin{document}

$$x^Ax^Bx^Cx^Dx^Ex^Fx^Gx^Hx^Ix^Jx^Kx^Lx^Mx^Nx^Ox^Px^Qx^Rx^Sx^Tx^Ux^Vx^Wx^Xx^Yx^Z$$

\end{document}


Hopefully this will be implemented soon. This has made into the source code of unicode-math. So no more rounding errors, yeah!

• Remember that the actual question was mainly about version differences between 0.8e and 0.8g. So what you’re telling me is that this change is expected/intentional (rounding errors notwithstanding)? In my opinion, changes to line/page breaks are very disruptive and should be clearly marked. – Socob Dec 12 '18 at 23:28
• @Socob You are correct! This change in math size declarations you've observed in version 0.8g of unicode-math is indeed intentional. Will Robertson and I are discussing this in github.com/wspr/unicode-math/issues/478, and hopefully egreg can also provide some insights. Long story short, unicode-math decided to use OTF parameters instead of LaTeX kernel legacy declarations, which unfortunately would result in 8.4pt script-size instead of 8pt. – Ruixi Zhang Dec 13 '18 at 0:06
• @Socob I should also mention the more subtle differences in 12pt article between pdfLaTeX's \usepackage{lmodern} and XeLaTeX/LuaLaTeX's \usepackage{unicode-math} OTF LM Math. In the pdfLaTeX case, the design sizes used at text-size, script-size and script-script-size are LMMathItalic12, LMMathItalic8 and LMMathItalic6, respectively. But in the XeLaTeX/LuaLaTeX case with \usepackage{unicode-math}, the text-size uses LM Math 10pt font scaled up, the script-size uses LM Math 7pt font scaled up and the script-script-size uses LM Math 5pt font scaled up. – Ruixi Zhang Dec 13 '18 at 0:13
• @Socob I edited my answer to better reflect your original question. :) – Ruixi Zhang Dec 13 '18 at 0:36