In LaTeX internal code I came accross \@@par
. How is this different from \par
or \newline
. When should I use \@@par
if I am writing a package or class file?
In general, there are so many other internal commands/macros (e.g., \z@
, \p@
, \protected@edef
, etc) in LaTeX which I come accross while studying the internal code. Is there some documentation available regarding when and how to use them if I am writing a package or class file? Should I really bother about them at all?
Best Answer
In LaTeX the
\par
command gets redefined several times during a run over a document. For example, inside atabular
it does nothing: an input such aswould print
(after the colon the parameter text is shown; after
->
up to the period the replacement text is shown). This way, users aren't bothered with empty lines inside atabular
.In a
center
,flushleft
orflushright
environment, the definition is more complicated, but eventually the macro\par
will execute{\@@par}
, where\@@par
is defined in the kernel byat a moment when
\par
still has its primitive meaning. In normal situations,\par
will have the primitive meaning and, in general, one should use\par
in macros.Another example: when a
\parbox
orminipage
is started, the\@parboxrestore
command is executed, which also does\let\par\@@par
. Why? Because the\parbox
orminipage
could be in atabular
or any other place where\par
has been redefined.The kernel has an interesting set of macros:
The macro
\@setpar
changes the meaning of\par
and\@par
; why making a copy of the new meaning of\par
into\@par
? Because one can always say\@restorepar
which will restore the meaning of\par
as defined with\@setpar
, in cases when it's not certain that\par
has the wanted meaning. The default definition of\@par
is to restore the primitive meaning.Of course, grouping plays an essential role here. For instance,
\par
does nothing intabular
, but as soon as\end{tabular}
is executed,\par
will get back the meaning it had before\begin{tabular}
. So a restoration with\let\par\@@par
is rarely needed; an exception is\@parboxrestore
, that's intended to bring LaTeX into a fresh state as if a new document should be started (we're in a\parbox
orminipage
and this indeed makes sense).Your question has probably been prompted by the line
in your code at Problems using listxadd and xappto
Well, this is a place where a plain
\par
should be used:The
\noexpand
is needed because of\xappto
and the fact that we want\par
to be stored, not its expansion at the uncontrolled moment the\xappto
command is performed.