[Tex/LaTex] Differences in vertical positioning of superscripts and subscripts depending on grouping (`{ }`): Why? Caveats? Workarounds

bracesmath-modepositioningsubscriptssuperscripts

This question about {(x+y)}^2 vs (x+y)^2 drew my attention to the slightly different vertical positioning of super- and subscripts for such expressions. Compare (x+y)^8_8 (left) and {(x+y)}^8_8 (right) [all expressions in math mode]:

different vertical positioning of super- and subscripts

\documentclass{article}
\begin{document} \((x+y)^8_8\), \({(x+y)}^8_8\) \end{document}

(This minimal example code is barely worth posting.)

This raises some questions for me:

  • Why is the vertical positioning different in the two expressions?
  • Is there anything the LaTeX user should pay attention to to get such vertical positioning "right" (this is assuming that there is deeper rationale behind the difference)?
  • Is there an easy way of getting such expressions to always have identical positioning of super- and subscripts?

The answers to the linked question above advise against the version with { }, so I assume that any rationale for the difference in vertical positioning will require a different example term.

Best Answer

Why is the vertical positioning different in the two expressions?

Because in the first case you're adding subscripts and superscripts to the parenthesis, while in the second case the whole subformula is the nucleus of the math atom to which the superscript and subscript fields are added.

Is there anything the LaTeX user should pay attention to to get such vertical positioning "right" (this is assuming that there is deeper rationale behind the difference)?

It is better to not brace a subexpression in parentheses; to brace it would usually be wrong. Adding the exponent to the parenthesis is the traditional way to denote exponentiation of the parenthesized expression.

Is there an easy way of getting such expressions to always have identical positioning of super- and subscripts?

No. They are inherently different, because the latter uses all of the braced subformula to determine the superscript's baseline.

Just $)^2$ and ${)}^2$ show the difference. In the former case the atom has nucleus ), in the latter the nucleus is {)} and rules of Appendix G applies differently: in the second case the math list is converted to a box, which hasn't the same information as a single symbol. This is a visual demonstration:

$bb^2 {bb}^2 bb_2^2 {bb}_2^2$

produces

enter image description here


It has also to be mentioned another issue: when you write ${(a+b)}$ (with sub/superscripts or not) the space around the + is frozen at its natural width, so it won't participate in the space stretching or shrinking when the line is justified. This could create bad appearance in cases such as ${(a+b)}+c$ where the spaces around the + signs might end up to be different.