[Tex/LaTex] Double subscript error with \newcommand

bracketserrorsmacrosmath-modesubscripts

Disclaimer: I know of Defining a newcommand with sub- or superscript and avoiding "double subscript" error but this only gives a work-around, but no explanation to my question.

Here's a summary of the problem. This code:

\documentclass{article}

\newcommand*{\one}{a_1}   %no explicit brackets
\newcommand*{\two}{{a_1}} %explicit brackets

\begin{document}
  $b_\one$ % error: Double subscript
  $b_\two$ % no error
\end{document}

Gives me the error Double subscript on b_\one. Why? When do I need the "scope" brackets and when do I not need them? I always thought a command defined by \newcommand is "automatically" a single "object" on its own that does not need to be put inside brackets.

The question is not why one needs brackets at all (this is clear), but the question is why one needs them in the defintion when using \newcommand?

By the way, what is the correct "vocabulary" for the "scope" and "object" in LaTeX?

Best Answer

The extent to which a "command defined by \newcommand is 'automatically' a single "object" on its own" varies by context.

  • Certainly such a command is a token, which is an atomic object in TeX's parser. When TeX is reading input, it receives any token as a whole, regardless of its expansion (if any).

  • It is also an expandable token, which means that it is not an atomic object in TeX's interpreter. In various situations, the input is subject to expansion, in which all expandable tokens are (successively left-to-right) replaced by their meanings.

  • It is not, as David explains, a "brace group", which is often treated as a single object, particularly when taken as an "argument" to a macro or function-like primitive operator (such as the subscript symbol).

One of the situations in which tokens are expanded is when a subscript symbol is looking for its operand; it expects either a brace group or a single character (or control sequence equivalent to a character). Thus, most \newcommand macros can't be used openly as subscripts, if they expand to more than one token that aren't braced.