4

I think that the maths subscripts are placed too low in the Latin Modern and the New Computer Modern fonts. Here's an example with the NewCM fonts, compiled with LuaLaTeX.

\documentclass[12pt, a4paper]{article}

\usepackage[newcmbb]{fontsetup}
\DeclareMathOperator{\spec}{spec}

\begin{document}
    \[
        \spec_{\symrm{p}}
    \]
\end{document}

newcmluaunmodified

I think the p is too low. I however think that we get a better output with ConTeXt.

\setuppapersize[A4]
\setupbodyfont[newcomputermodern-book]

\definemathfunction[spec]

\starttext
    \startformula
        \spec_{\mathrm p}           
    \stopformula
\stoptext

newcmcontext

I believe this happens due to the way ConTeXt handles maths, and also due to the modifications done in the newcomputermodern-math.lfg goodie file. I believe the following modifications (lines 79 and 80) in the goodie file give the correct result.

SubscriptBaselineDropMin             =  50, -- 200 in font (multiplied by 0.59999/2.39868)
SubscriptShiftDown                   =  150, -- 247 in font (multiplied to be consistent with cm)

I tried to modify the SubscriptBaselineDropMin and SubscriptShiftDown parameters using LuaLaTeX, and expected to get the same result as in ConTeXt, but that does not seem to be the case. I believe 1 pt corresponds to 100 units in the goodie file.

\documentclass[12pt, a4paper]{article}

\usepackage[newcmbb]{fontsetup}
\DeclareMathOperator{\spec}{spec}

% code copied from here https://tex.stackexchange.com/a/82221/128462
% check pages 115 and 116 of https://mirrors.ibiblio.org/CTAN/systems/doc/luatex/luatex.pdf

\everymath=\expandafter{%
\the\everymath%
\Umathsubshiftdown\textstyle=1.5pt\Umathsubshiftdrop\textstyle=0.5pt}
\everydisplay=\expandafter{%
\the\everydisplay%
\Umathsubshiftdown\displaystyle=1.5pt\Umathsubshiftdrop\displaystyle=0.5pt}

\begin{document}
    \[
        \spec_{\symrm{p}}
    \]
\end{document}

newcmluamodified

The subscript p is certainly shifted upwards compared to the unmodified LuaLaTeX code, but not as much as the ConTeXt result.

Why is that? Are there other parameters which are relevant here which need to be changed in order to get the ConTeXt result? I tried changing the \Umathsubshiftdown and \Umathsubshiftdrop to zero, and still did not get the desired result.


Edit:

It seems that the DeclareMathOperator is causing some things, as I see the following behaviour in pdflatex with CM, LuaLaTeX and ConTeXt. The subscripts of \mathrm{c} are lifted as compared to \spec. pdflatexcm

13
  • Without reading too carefully, I would assume that the unit is the font unit (usually 1000) from the font. (And yes, we used here the same numbers as for Latin Modern, where we tried to calculate the corresponding values for the traditional Computer Modern math fonts.) Commented Oct 30 at 15:18
  • @mickep The Em size for NewCM is 1000. I just checked. Commented Oct 30 at 15:19
  • 1
    That is as far as I remember some setting that it should not take it into account. Probably just for a reason similar to the example you show. Commented Oct 30 at 15:37
  • 1
    (In fact it might have been because of the annoyance that the superscripts on sin and cos were not aligned.) Commented Oct 30 at 15:48
  • 1
    @ApoorvPotnis I'm sorry, I think must have misremembered. I cannot find a trace about such an option. Commented Oct 30 at 20:04

1 Answer 1

5

A similar issue happens with legacy TeX: consider

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator{\spec}{spec}

\begin{document}

\[
\mathrm{c}_p \quad \mathrm{pc}_p \quad \spec_p
\]

\end{document}

pdflatex

The subscript is lowered in the last two instances, because the whole subformula “spec” is taken into account.

Clearly, what happens with unicode-math is really awful and is not limited to NewComputer Modern: here's with Latin Modern

\documentclass[12pt, a4paper]{article}

\usepackage{unicode-math}

\DeclareMathOperator{\spec}{spec}

\begin{document}

\[
\symrm{c}_{p} \quad \spec_{p}
\]

\end{document}

Latin Modern

While there possibly is a LuaTeX workaround, you can fix the thing.

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

\RenewDocumentCommand{\DeclareMathOperator}{mm}{%
  \NewDocumentCommand{#1}{}{%
    \operatorname{\vphantom{#2}}\!%
    \operatorname{\smash[b]{#2}}%
  }%
}

\DeclareMathOperator{\spec}{spec}

\begin{document}

\[
\symrm{c}_{p} \quad \spec_{p} \quad (\spec_{p}) \quad a\spec_{p}
\]

\end{document}

fix

The last two items show that the spacing is as expected.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.