That's easy! TeX always does macro expansion, except when it doesn't.
On page 215, second double dangerous paragraph, we read
Expansion is suppressed at the following times:
- When tokens are being deleted during error recovery (see
- When tokens are being skipped because conditional text is being
- When TeX is reading the arguments of a macro.
- When TeX is reading a control sequence to be defined by
- When TeX is reading argument tokens for
- When TeX is absorbing the parameter text of a
- When TeX is absorbing the replacement text of a
\read; or the text of a token variable like
\toks0; or the token list for
\write. (The token list for
\write will be expanded later, when it
is actually output to a file.)
- When TeX is reading the preamble of an alignment, except after
a token for the primitive command
\span or when reading the
- Just after a token such as
$3 that begins math mode, to see if another token of category 3 follows.
- Just after a
`12 token that begins an alphabetic constant.
Not unreasonable, is it? When doing definitions, we want that nothing is expanded (except for
\xdef) and the fourth, fifth, sixth and seventh bullets deal with this. Similarly if we want to store a token list in a register or in
Similarly, the token after
\aftergroup must not be expanded for obvious reasons; it will later, when TeX examines it again at the appropriate time.
The last bullet has a technical reason: If you want to refer to an alphabetic constant that corresponds to a character with
\catcode 0, 5, 9, 13, 14, or 15 it can be “escaped” with a backslash in front of it, but this actually doesn't form a control sequence. So you can do
`\^^M if you want to refer to the constant 13 or do
The second bullet can be supplemented by an important remark: notwithstanding that TeX does no expansion when skipping conditional text, it does examine the tokens in order to match conditionals with their
\fi. Any token that is
\let to a primitive conditional, to
\fi counts under this respect.