Subscript without braces

The formula $a_\beta$ renders the same as $a_{\beta}$.

But $a_\bar{b}$ yields the Missing { inserted error, as opposed to $a_{\bar{b}}$.

Why?

• Because \beta is a single token. But \bar{b} is several tokens (4?). so it takes \bar as the next token and this pulls the one after as its argument. So you get \bar applied to just { as the subscript and b} is left. Hence the unbalanced brackets and the complaint that a { is missing. – cfr Jun 7 '18 at 0:20
• I think. ...... – cfr Jun 7 '18 at 0:20
• @cfr Subscripts and superscripts are not parsed as arguments, thus the token rules for arguments do not apply here. See my answer for more details. – Heiko Oberdiek Jun 7 '18 at 0:43
• Heiko explains why it doesn't work, but it is not just superscripts \fbox{\fbox{x}} double boxes x but \fbox\fbox{x} is \fbox{\fbox}{x} which just gives errors – David Carlisle Jun 7 '18 at 1:17

TeX expects a math subformula as subscript or superscript. This is either a plain math atom or a formula surrounded by curly braces. This has nothing to do with argument parsing. Arguments are assigned based on token and token groups (curly braces) without expanding. Sub- and superscripts, however, look for math atoms and formulas with expansion.

\beta is usually a math atom and can therefore be used without curly braces as sub- or superscript.

% plain TeX
$a_\beta$

\def\beta{BETA}
$a_\beta$

$a_\empty\csname alpha\endcsname$

\bye In the second case, \beta is a single token, but it is a sequence of four math atoms B, E, T, A. The first goes to the subscript.

The third case uses eight tokens as subscript without the need for curly braces, because after expanding the math atom \alpha remains. This is different from parsing as undelimited argument. Then, the subscript would have taken the token \empty that expands to nothing.

If you are unsure about the nature of the subscript, use curly braces. The curly braces can be omitted for single math atoms or if the expansion already provides curly braces for a subformula as in the case of \text of package amstext (amsmath):

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$a_1 = a_{1}$
$a_\text{subscript} = a_{\text{subscript}}$
\end{document} • Where can I read up about math atoms, e.g. what is a math atom, and what isn't? What exactly does "parsing as undelimited argument" mean? Maybe you can edit this into the answer. Thanks! – root Jun 7 '18 at 9:27
• @root If you are really interested in the details, then it is time to dig deeper: Electronic version of Knuth's “TeXbook”? – Heiko Oberdiek Jun 7 '18 at 17:23