In the following definitions, \\ captures a space token but \mksp does not.

{\def\\{\global\let\sp= } \\ }
{\def\mksp{\global\let\spx= } \mksp }

When run, the output indicates that \sp is a space token but \spx is }.

> \sp=blank space  .
l.5 \show\sp

> \spx=end-group character }.
l.6 \show\spx

Why is the \\ special? Where does Knuth discuss this in the TeXbook?

  • 3
    You get the same with commands like \. or \; or \?. In short: if the command name consist of a non-letter. In this case TeX knows that the command name ends after the one char. With \mksp` the space after the name is needed to end the command name so it is goobled. – Ulrike Fischer Nov 16 '11 at 18:15

The difference is that \\ is a control symbol, while \mksp is a control word.

In the second example, the space after \mksp doesn't go over the tokenization process, which comes even before expansion: the tokenization rules have the consequence that spaces after control words are discarded during the process, which is the same by which multiple spaces are reduced to one or spaces at the beginning of a line are discarded. On the contrary, a space after a control symbol is not ignored. So, after tokenization, TeX sees (I'll denote by • a space token that survives the tokenization pro)


After the definition, the space after the closing brace is ignored, because it's seen in vertical mode; then \\ is expanded and TeX confronts with


The space after the = is ignored by rule, but the second one remains. After that the closing brace does its duty.

In the second case, what TeX is presented with is


which becomes, after executing {, the definition and the expansion of \mksp,


Again, the space is ignored by rule, so what \spx is defined to be is }, exactly as you got. The compiler will also say that a group has not been closed.

  • 2
    The TeXBook discusses this in Chapter 8, pages 46 - 47, where he describes the tokenizing algorithm. Thanks! – Justin Bailey Nov 16 '11 at 18:45

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.