We don't want that a space is added after
\( when it's written in the aux file. That's what
\x@protect is for. It should never be used either in macro definitions or in documents.
Let's see what happens with
\( (which, by the way, has been robust in the kernel for a couple of years).
I'll use one line for expansion step; a
• denotes a space in the macro name. A part in
《》 denotes tokens that have already been sent to the stomach.
\@typeset@protect, which is the same as
and here it's clear what happens.
Writing to files or doing
\protect is not
\@typeset@protect. The definition of
% latex.ltx, line 988:
Now the expansions
(The expansion of
\fi is empty.) At this point the execution depends on what
\protect really is (either
\string). Note that TeX won't add a space after
\( when writing to a file.
As said at the beginning, we don't want spaces creep in after control symbols such as
\@ (or active characters). If the same path as for control words were followed, the result would be writing
\(• which is not wanted.
See Moving arguments and \protect: coming to grips with the definitions for other important aspects of
Just for completeness,
\DeclareRobustCommand is defined to be
\@star@or@long\declare@robustcommand; the first macro tests for a
* (consuming it if present), setting a conditional that will be used by
\new@command later on and does not concern us. More important is to see what
% latex.ltx, line 963:
Taming the monster is not really so difficult. First the argument is tested for being defined or not, in the former case the “Redefining” info message is issued.
Now we have to distinguish two cases: the behavior will be different for a control symbol (example
\?) from a control word (example
\reserved@a will contain the stringified version of the argument, nothing particular here. Then
\reserved@b is defined to expand to
#1 and then redefined (with
\edef) in a peculiar way. Let's see what results in the two cases
\? → \?
\foo → \foo•
• denotes a space; however, the result stored in
\reserved@b are just strings of characters).
Now comes the definition of
\? we'll have
\foo we'll get just
(now the tokens are control sequences and the
• denotes a space in the name)
Then the sequence with the trailing space in its name will be defined, with
This shows why
\x@protect should not be used anywhere: it does nothing useful except when working with robusted commands and this happens at a level the user/programmer need not be aware of.