How to make vertical space in subscript the same for lower case letter and upper case letter?

In this example

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}

$t_{0} = k r_N + \frac{ (N-1)\phi }{2}$

$t_{0} = k r_n + \frac{ (N-1)\phi }{2}$

\end{document}


Compiled with lualatex, the output is

The problem is when the subscript is UPPER CASE, it almost looks like it is on same level as r. Like multiplication instead of subscript.

I'd like to look like this (done with the magic of paint.exe)

This probably depends on the font being used also.

Is there some global option to use that will help with such cases, so that both lower case and upper case letters have the same vertical space below the letter?

• The vertical space is the same, look at the base lines. Feb 11, 2021 at 8:11
• @egreg I think they want the height of the subscripts level, rather than the depth? At least, that’s how I answered. Feb 11, 2021 at 8:17

You can level your subscripts by placing them in a \raisebox and lowering them by the difference between the subscript’s height and the desired level (here, the x-height of the font). This involves saving the subscript in a box and measuring its height.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{settobox} % For \settoboxheight

\newbox{\subbox}
\newlength{\xheight}
\newlength{\subheight}

\newcommand\xheightsub[2]{%
\savebox{\subbox}{$${}_{#2}$$}%
\settoheight{\xheight}{$${}_x$$}%
\settoboxheight{\subheight}{\subbox}%
{#1}{\raisebox{-\subheight}{\usebox{\subbox}}}%
}

\begin{document}

$k_n = \xheightsub{k}{n} = \xheightsub{k}{N} = \xheightsub{k}{n^{2^t}} = \xheightsub{k}{+} = \xheightsub{\log}{N}$

\end{document}


One rare corner case that code does not quite cover: if you need an expression such as a \log_b to work, you would write it as a \mathop() \xheightsub{\log}{b}.

• Thanks. So there is no way to have global option/global macro type solution that goes only to the preamble to do this without having to modify the code itself? Feb 11, 2021 at 7:19
• @Nasser There probably is some way, but I suspect the code would be a lot more complicated. Feb 11, 2021 at 7:22