A couple of times in the latex.ltx kernel, the macro \@@ is used. For instance in the definition of \@next (l.6222):

\def\@next#1#2#3#4{\ifx#2\@empty #4\else
   \expandafter\@xnext #2\@@#1#2#3\fi}

I don't see the macro defined anywhere. (Quick searches with e.g. \let, \def, \newcommand with and without star, etc. didn't yield anything meaningful.) I also don't see it in plain.tex. I kind of don't understand what \@next does because of this macro, and a canonical answer wasn't available on the site yet anyway.

So what does \@@ mean?

  • @ChristianHupfer Why? If you see \@next there as a token, then \@@ is a single token, it's no concatenation. It seems to be used as some sort of delimiter in arguments like \def\foo#1#2#3\@@#4{..}.
    – Manuel
    May 31, 2015 at 22:47
  • @Manuel: I'll delete my comments. You're the TeX expert here obviously
    – user31729
    May 31, 2015 at 23:05
  • @ChristianHupfer No, no, I'm no expert, really. I meant that I saw no connection to what you said.
    – Manuel
    May 31, 2015 at 23:07

3 Answers 3


You can't understand the definition of \@next without looking also at the definition of \@xnext and at an example of usage; the complete code is

\def\@next#1#2#3#4{\ifx#2\@empty #4\else
   \expandafter\@xnext #2\@@#1#2#3\fi}
\def\@xnext \@elt #1#2\@@#3#4{\def#3{#1}\gdef#4{#2}}

and an example of usage is at line 5963


The second argument to \@next should be a parameterless control sequence (due to the \ifx test and the following \expandafter). The macro \@freelist is such a macro, used in connection with the float queues, and it is updated when a float is started or floats are flushed with \clearpage. Its definition at startup is

\@elt\bx@A\@elt\bx@B\@elt\bx@C...\@elt \bx@R

that is, it lists the insertion classes pertaining to floats (here ... denote similar tokens).

If \@freelist contains nothing, the fourth argument is delivered; otherwise


remains on the input stream. So, assume \@freelist is not empty and, for the sake of simplicity, it is the same as at startup. The \expandafter makes TeX see

\@xnext\@elt\bx@A\@elt\bx@B\@elt\bx@C...\@elt \bx@R\@@\@marbox\@freelist{\global\count\@marbox\m@ne}\fi

Note that, in order for this to work, the first level expansion of the second argument to \@next must begin with \@elt. What's \@elt? It's just a token usually defined to be \relax, which is used to store ordered lists of tokens in the form \@elt<token1>\@elt<token2>... that allows for list manipulations.

Now the definition of \@xnext comes into play. It has a complex parameter text that can be described as follows:

  1. \@elt is expected just after the command
  2. #1 means an undelimited argument, so just one token or a braced group, because it's immediately followed by #2

  3. #2\@@ means a delimited argument, that is, TeX will substitute #2 with everything up to (and excluding) the first \@@ token it finds;

  4. #3 and #4 are undelimited arguments (the same as for #1 applies).

In the context of delimited arguments, the delimiter tokens need not be defined; TeX looks for the exact sequence of tokens and control sequences are considered equal only if their names are the same.

The delimiters are removed from the input stream as part of macro expansion. So in this particular case, \@elt is found and the search for the following arguments can start (\@elt will be removed); argument #1 is \bx@A; argument #2 is

\@elt\bx@B\@elt\bx@C...\@elt \bx@R

and arguments #3 and #4 are \@marbox and \@freelist respectively.

Expansion of \@xnext makes all that code be replaced by

\gdef\@marbox{\bx@A}\gdef{\@freelist}{\@elt\bx@B\@elt\bx@C...\@elt \bx@R}

The two definitions are performed, which in particular shows how \@marbox becomes equivalent to \bx@A (the first insertion class) and \@freelist is updated, essentially removing the first item. The dangling \fi remaining disappears by general TeX rule (the expansion of \fi is empty, provided it resulted from expansion of a previous conditional, which in this case was the \ifx we started with).

The token \@@ is used in a very similar way, that is, as a pure delimiter, in the auxiliary macros for the loop functions \@for and \@tfor.

  • So the expanded form of parameter 2 of \@next contains, after expansion, three tokens, the first being \@elt unconditionally?
    – 1010011010
    Jun 1, 2015 at 17:41
  • @1010011010 The expansion of argument #2 to \@next must start with \@elt. That's the only requirement.
    – egreg
    Jun 1, 2015 at 17:46
  • So in the definition parameters #1#2 can be a single token? Or will TeX first expand this until one token remains or something? \expandafter expands only once...
    – 1010011010
    Jun 1, 2015 at 17:50
  • @1010011010 I don't understand what you're saying.
    – egreg
    Jun 1, 2015 at 17:52
  • \expandafter\@xnext #2\@@... precedes \def\@xnext \@elt #1#2\@@..., so I thought parameter 2 in \@next contained \@elt<token1><token2> in expanded form ?
    – 1010011010
    Jun 1, 2015 at 18:01

Actually, just the next line defines a macro that uses \@@ as a delimiter:

\def\@next#1#2#3#4{\ifx#2\@empty #4\else
   \expandafter\@xnext #2\@@#1#2#3\fi}
\def\@xnext \@elt #1#2\@@#3#4{\def#3{#1}\gdef#4{#2}}

So it seems to be used as a delimiter (like \@nil or \relax in traditional LaTeX or quarks in expl3, \q_stop, etc.). I don't know it there's an additional idea behind \@@ (like there's when someone uses quarks or \relaxs, etc.).

  • 1
    In this case, whether \@@ has a definition or not is completely irrelevant.
    – egreg
    Jun 1, 2015 at 8:31
  • I meant I didn't know if there was an idea when using it (not referring to its definition); opposed to it just being a random (easy recognisable) token.
    – Manuel
    Jun 1, 2015 at 9:11
  • 1
    The delimiter \@@ is used also in other places, notably in the auxiliary macros for \@for and \@tfor loops, but not only.
    – egreg
    Jun 1, 2015 at 9:23
  • @egreg You seem to understand the macro, unlike me. Care to post an answer explaining it? E.g., why doesn't it matter that \@@ exists as a definition or not?
    – 1010011010
    Jun 1, 2015 at 13:30
  • @1010011010 It works as a delimiter, it's gobbled by the macro when grabbing arguments. So it doesn't matter at all. Say you define \def\foo#1\bar#2\baz{..}, then using \foo whatever{even with braces}\bar[And even more)\baz, it doesn't matter what \bar and \baz mean (if they mean anything at all) they are gobbled when \foo is grabbing arguments.
    – Manuel
    Jun 1, 2015 at 13:34

If you get the documentation for the array environment (say texdoc array) then it refers to \@@serving as an argument delimiter — see, for example, page 9 of the documentation from TeX Live 2014 (and other distributions). The sources2e documentation (say texdoc sources2e) has \@@ in its index but does not explicitly mention its usage (at least anywhere I could see). Perhaps this is a standard TeX technique ?

  • 3
    using a delimiter is a standard tex technique. the delimiter need not be \@@; it doesn't even need to be in the form of a command -- \commandname#1 #2< will do as well (observe that this example contains two delimiters). it's not part of the "latex prescribed definition mechanism" because the author of latex decided that bracing arguments was a better approach. Jun 1, 2015 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .