[texhax] \protect in LaTeX2e

Morten Høgholm moho01ab at student.cbs.dk
Wed Oct 6 19:12:36 CEST 2004


On Wed, 06 Oct 2004 12:22:47 -0400, Alexandru Scorpan  
<ascorpan at math.ufl.edu> wrote:

> Speaking of \protect, how does one look into the bowels of a protected  
> command?  Case in point:  I' happily running latex on command line and  
> using \show to dig into definitions of various uglies, but whenever I  
> hit a \protect'ed command, as in \show\command, I get \protect\command.  
>   What should I do to to move further in decyphering these?

\DeclareRobustCommand\foo{bar} defines two commands: "\foo"  and "\foo ".  
Yes that's right, the last one has a space in it. "\foo" expands to  
"\protect\foo " and "\foo " contains the real definition. You can see it  
by doing a
      \expandafter\show\csname foo \endcsname

The idea of making robust commands the way they are is phenomenally good  
(Alan Jeffrey got the idea circa 10 years ago IIRC). One reason it is so  
brilliant is that it allows the command in question to be repeatedly  
written to files and still appear the same to LaTeX.
-- 
Morten Høgholm



More information about the texhax mailing list