0

I have overcome the problem related to the positioning of the subscript in mathmode.

\documentclass[10pt]{article}
\begin{document}
$
n_P %before
$
$
\fontdimen15\textfont2=4pt
\fontdimen16\textfont2=3pt
\fontdimen17\textfont2=3pt
n_P %after
$
\end{document}

enter image description here

The output I want is the second one, and I'd like to be applied to every subscript of my document.

How can I avoid to rewrite this whole block in every math mode?

  \fontdimen15\textfont2=4pt
  \fontdimen16\textfont2=3pt
  \fontdimen17\textfont2=3pt
5
  • Just move the three lines out of math mode. May 10, 2022 at 22:24
  • Error: ! Font \nullfont has only 7 fontdimen parameters. May 10, 2022 at 22:27
  • It may not move the subscript down as far (not tested), but putting in a dummy supercript -- $n_P^{\mathstrut}$ -- might be good enough. May 10, 2022 at 22:59
  • 1
    Maybe put it in \everymath
    – user202729
    May 11, 2022 at 0:13
  • Not sure if calling \check@mathfonts, which is called by \frozen@every(display|math) the internal names of \every(display|math), is enough. Or, a dirty trick: put \setbox0=\hbox{$$} before \fontdimen lines. May 11, 2022 at 0:37

2 Answers 2

1

You need not do any more. The \fontdimen setting is global. Try to add next $n_P$ in your testing code and you see.

Of course, it is better to move this setting to the preamble. But LaTeX sets all math fonts when the first math mode is used. This is reason why you cannot do \fontdimen15\textfont2=4pt before the first math mode. But you can use a trick \setbox0=\hbox{$ $} mentioned in the comment above in order to set the math fonts in this first usage of math mode.

Note. If LuaTeX is used then these \fontdimen settings are ignored. You must set special registers mentioned at page 108 of LuaTeX documentation. For your example you must set:

\Umathsubshiftdown\textstyle=3pt
\Umathsubsupshiftdown\textstyle=3pt

and do analogical settings for \displaystyle, \scriptstyle and \scripscriptstyle.

Note2. We are using Unicode math in LuaTeX, and the default setting is better here. You can compare it by this OpTeX document:

$n_P$ ... old 8-bit fonts.

\fontfam[lm] % Unicode math is loaded

$n_P$ ... LatinModern-Math.

\bye
0

Following @user202729 advice, I have finished my work

\documentclass[10pt]{article}
\everymath{
  \fontdimen15\textfont2=4pt
  \fontdimen16\textfont2=4pt
  \fontdimen17\textfont2=4pt
}
\begin{document}
$n_P^0 \quad n_P$
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .