In an answer to this question Automatically replace environment align by equation+aligned combination egreg uses


The role of the second # is unclear or me. It seems to be neither element of definition with arguments with the structure nor alignment marker.


1 Answer 1


The \tag command allows a *-form, so it can be called as \tag{x} or \tag*{x}.

Since the aim is to neutralize \tag we need no fancy \@ifstar definition. The syntax


means that the argument to \relaxtag is delimited by the first left brace that's found in the input stream. So in the case \relaxtag{...} the argument is empty, in the case \relaxtag*{...} the first argument is *.

This of course is supplemented by \let\tag\relaxtag in the macros.

Proof of concept:

\def\relaxtag#1#{\showtokens{Before the brace we have '#1'}\relaxrelaxtag}
\def\relaxrelaxtag#1{\showtokens{Between the braces we have '#1'}}



Running this code through pdftex (or pdflatex as well) produces the following output on the terminal

> Before the brace we have ''.
\relaxtag ...okens {Before the brace we have '#1'}
                                                  \relaxrelaxtag {
l.4 \relaxtag{
> Between the braces we have 'x'.
\relaxrelaxtag ...Between the braces we have '#1'}

l.4 \relaxtag{x}

> Before the brace we have '*'.
\relaxtag ...okens {Before the brace we have '#1'}
                                                  \relaxrelaxtag {
l.6 \relaxtag*{
> Between the braces we have 'x'.
\relaxrelaxtag ...Between the braces we have '#1'}

l.6 \relaxtag*{x}


Quoting from the TeXbook, page 204, second doubly dangerous paragraph:

A special extension is allowed to these rules: If the very last character of the ⟨parameter text⟩ is #, so that this # is immediately followed by {, TeX will behave as if the { had been inserted at the right end of both the parameter text and the replacement text. For example, if you say ‘\def\a#1#{\hbox to #1}’, the subsequent text ‘\a3pt{x}’ will expand to ‘\hbox to 3pt{x}’, because the argument of \a is delimited by a left brace.

  • So that's what #{ means! I've never been able to make much sense of that paragraph on p204, but every time I've seen it, I've been hunting for something else, so I've never really dug into it. Thanks! Nov 8, 2015 at 20:35
  • @NormanGray You're welcome!
    – egreg
    Nov 8, 2015 at 20:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.