0

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

enter image description here

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)

enter image description here

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?

2
  • The vertical space is the same, look at the base lines.
    – egreg
    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.
    – Davislor
    Feb 11, 2021 at 8:17

1 Answer 1

2

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}%
    \addtolength{\subheight}{-\xheight}%
    {#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}

Computer Modern sample

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}.

2
  • 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?
    – Nasser
    Feb 11, 2021 at 7:19
  • @Nasser There probably is some way, but I suspect the code would be a lot more complicated.
    – Davislor
    Feb 11, 2021 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.