I'm trying to understand what exactly a TeX assignment is according to the TeXbook (Addison-Wesley 1996), as specified on pp. 275-278.

On p. 275 it is stated that an assignment is one of two varieties: a macro definition, or a simple assignment. The macro variety is defined on p. 275 whereas the simple variety is defined across pp. 276-278.

After the macro variety is defined and before the simple variety is defined, the following remarks are made (p. 276):

Several commands that we will study below have a syntax somewhat like that of a definition, but the <parameter text> is replaced by an arbitrary sequence of spaces and ‘\relax’ commands, and the <left brace> token can be implicit:

<filler> -> <optional spaces> | <filler>\relax<optional spaces>
<general text> -> <filler>{<balanced text><right brace>

The main purpose of a <general text> is to specify the <balanced text> inside.

On the surface it seems to me that the informal description is at odds with the formal definitions, since the informal description says that the <left brace> token can be implicit, but the formal definition of <general text>* shows that an explicit left brace is mandatory.

Please help dispel my confusion:

  1. Is the '{' appearing in the definition of <general text> a typo?
  2. If no, in what sense can the <left brace> token be implicit?
  3. Another question arises concerning {'s catcode.

    Atypically of the syntax diagrams appearing in the same chapter (chapter 24), the '{' literal here appears without a subscript indicating its category code. Compare this to the literal '=' that appears on the previous page:

    Equals symbol with a category code

    Does this mean that the category code of the '{' in the formal definition of <general text> is irrelevant, i.e. that the TeX engine ignores this token's category code in this context? Or is it possible that the omission of a category code here is a typo, even if the '{' itself is not a typo?

    There are some keywords, whose category codes are irrelevant, e.g. at, bp, and by. The full list is given on p. 61. However, { doesn't appear on this list.

* <general text> is used on p. 276 in the definition of <variable assignment>:

<variable assignment> -> ... <token variable><equals><filler><token variable>
<token variable> -> <token parameter> | <toksdef token> | \toks<8-bit number>

and later on p. 279 in the descriptions of the following primitives: \uppercase<general text>, \lowercase<general text>, \message<general text>, and \errmessage<general text>.


The { means a possibly implicit character token of catcode 1. implicit in this context means it may be a control sequence \let to such a character.

Specifically you can go

 \toks0\bgroup abc}

but you can not go

  \def\foo\bgroup abc}

The TeXBook says

Control sequences sometimes masquerade as characters, if their meaning has been assigned by \let or \futurelet. For example, Appendix B says \let\bgroup={ \let\egroup=} and these commands make \bgroup and \egroup act somewhat like left and right curly braces. Such control sequences are called ``implicit characters''; they are interpreted in the same way as characters, when TeX acts on them as commands, but not always when they appear in arguments to commands. For example, the command \let\plus=+ does not make \plus an acceptable substitute for the character token |+|_{12} in the syntax rule for given above, nor does the command \let\p=p make \p acceptable as part of the keyword [pt]. When TeX's syntax allows both explicit and implicit characters, the rules below will be careful to say so, explicitly.

  • So why does the definition of <general text> use { instead of <left brace>? <left brace> and <right brace> are defined on p. 275 to be exactly what you wrote: "explicit character tokens whose category codes are respectively of types 1 and 2." – Evan Aad Aug 31 '17 at 9:34
  • 2
    no: <left brace> is an explicit character token of catcode 1. the { in the syntax productions means a possibly implicit character – David Carlisle Aug 31 '17 at 9:36
  • 2
    see page 269: it will be convenient to use { ... to stand for any explicit or implicit character of the respective category... (@EvanAad) – David Carlisle Aug 31 '17 at 9:38

At the bottom of page 275 you find

Here ⟨control sequence⟩ denotes a token that is either a control sequence or an active character; ⟨left brace⟩ and ⟨right brace⟩ are explicit character tokens whose category codes are respectively of types 1 and 2. The ⟨parameter text⟩ contains no ⟨left brace⟩ or ⟨right brace⟩ tokens, and it obeys the rules of Chapter 20.

At page 269 you read

It will be convenient to use the symbols ‘{’, ‘}’, and ‘$’ to stand for any explicit or implicit character tokens of the respective categories 1, 2, and 3, whether or not the actual character codes are braces or dollar signs. Thus, for example, plain TeX’s \bgroup is an example of a ‘{’, and so are the tokens ‘{1’ and ‘(1’; but ‘{12’ is not.

When you find { in a syntax description, it means you can use either {1 or \bgroup (or any token \let to {1), but when you find ⟨left brace⟩ it means an explicit character token of category 1 is to be employed.

For instance, \bgroup is allowed in the ⟨parameter text⟩ for a macro, but ⟨left brace⟩ isn't (as it would immediately start the ⟨replacement text⟩.

On the other hand, every primitive accepting a ⟨filler⟩ (such as \uppercase) can have their ⟨balanced text⟩ delimited on the left by { (so \bgroup is acceptable there). The final delimiter for a ⟨balanced text⟩ must be ⟨right brace⟩ (that is, an explicit }2 character).

Note: in the above description, when {1 or }2 appear, only the category code and not the character code is relevant. Which is the reason why Knuth resorted to use ⟨left brace⟩ and ⟨right brace⟩ for them.

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.