22

For context, an implicit character is a control sequence that has been \let to a character. For example, both plain TeX and LaTeX use \let\bgroup{ \let\egroup} making \bgroup and \egroup into implicit braces.

In some places, TeX accepts either, in other places, it does not. For example, implicit braces cannot be used to collect tokens for undelimited macro arguments, nor can they be used to delimit the replacement text of a macro assignment.

Implicit braces can be used

  • to form groups: \bgroup...\egroup;
  • to construct boxes: \hbox, \vbox, and \vtop;
  • to create vertical material with \insert or \vadjust;
  • for alignment material with \halign, \valign, and \noalign; and
  • to create a new math atom.

Implicit left braces—which must be matched with literal characters with category code 2 (e.g., }2)—can be used

  • to assign to token variables;
  • with \hyphenation and \patterns;
  • to change case with \uppercase and \lowercase;
  • to write messages using \message or \errmessage;
  • to write files using \write;
  • to construct a \special;
  • for \mark;
  • for \discretionary; and
  • for a four-way \mathchoice.

I tried to be thorough, but TeX is extremely complicated. Are there any other places where an implicit brace can be used instead of an explicit one?

5
  • I can try to answer this, but it may be easier to list the cases where implicit braces may not be used. Sep 11, 2010 at 7:59
  • Sure. I added a few more where they are allowed. The most obvious one I missed being token variables.
    – TH.
    Sep 11, 2010 at 9:06
  • I would add "to delimit a subscript or superscript in math mode", e.g., $a_\bgroup b\egroup$ Jan 28, 2011 at 7:20
  • @Bruno: That's creating a new math atom, I think. (I'd have to reread Appendix G to be sure.)
    – TH.
    Jan 28, 2011 at 8:05
  • I think that you are right. Jan 28, 2011 at 11:52

1 Answer 1

10

In TeX82,

Explicit left braces are required: to start the body of a macro definition: \def, \edef, \xdef, \gdef, and when a token list should be tucked into a single token.

Explicit right braces are required whenever a token list must end, including the case where a token list should be tucked into a single token.

Primitives that need a token list argument:

  • \def, \edef, \xdef, \gdef
  • \mark
  • \message, \errmessage
  • \uppercase, \lowercase
  • \write
  • \special
  • \patterns, but only in the special erroneous case of extra \patterns in initex after typesetting has already started (other uses of are happy with an implicit right brace).

Assignments that need a token list argument:

  • \toks, \output, \everypar, everymath, \everydisplay, \everyhbox, \everyvbox, \everyjob, \everycr, \errhelp

As far as I can make out, these are all the cases in TeX82. The new extended typesetting engines will have longer primitive lists for explicit right braces, but the same basic rule about closing a token list will apply.

2
  • 1
    Btw, I would never have found that odd \patterns case if I had not looked into the web source itself. Sep 11, 2010 at 9:34
  • What an odd case!
    – TH.
    Sep 11, 2010 at 11:54

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.