5

The answers to the questions Differences in vertical positioning of superscripts and subscripts depending on grouping (`{ }`): Why? Caveats? Workarounds? and {(x+y)}^2 or (x+y)^2? make it clear that one should use (x+y)^2 over {(x+y)}^2 to get a proper vertical position of the supscript.

However, what is the correct approach when one uses macros with use the brace-group and hence result in a different vertical position? For example, the position of the subscript is different in \mathrm{pr}_A vs pr_A. How to get the text in roman font but at the same time keep the normal subscript position?

\documentclass{article}
\begin{document}
    \( \mathrm{pr}_A \), \( pr_A \)
\end{document}

enter image description here

5

In the case of \mathrm{pr}_A, the subscript A is placed relative to a box that contains two letters, "pr". In contrast, in the case of pr_A, the subscript A is placed relative to a box that contains just r, not pr. The pr box has depth (i.e., material below the baseline), whereas the r box does not. When placing subscripts next to the box, TeX doesn't actually "know" what's inside the box, and hence it cannot "know" that it would actually be OK to place the subscript at a less-deep position. That's why the subscript is placed lower relative to "pr" than to "r".

Note that this holds for both upright and italic lettering.

enter image description here

\documentclass{article}
\begin{document}
    \( \mathrm{pr}_A \)
    \( \mathit{pr}_A \) \ 
    \( \mathrm{p}\mathrm{r}_A \)
    \( pr_A \)
\end{document}

You also asked,

How to get the text in roman font but at the same time keep the normal subscript position?

I suppose one could write \mathrm{p}\mathrm{r}_A. However, I wouldn't recommend it. Instead, I'd define \pr as a macro. E.g., if you load the amsmath package, you could write

\newcommand\pr{\smash[b]{pr}}

or

\newcommand\pr{\smash[b]{\mathrm{pr}}}  % for upright lettering of 'pr'

That way, the "pr" box has no depth and, in consequence, the subscript A won't be placed as low as if you wrote \mathrm{pr}_A.

Finally, if \pr is supposed to be a math operator, you should define this operator via the following instruction:

\DeclareMathOperator{\pr}{\smash[b]{\mathrm{pr}}}

(\DeclareMathOperator is an instruction provided by the amsmath package.)

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.