TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After reading another question relating to how to see definitions of commands, I tried:


But this shows me in my logfile:

\protect \LaTeX

I just want to see where the \LaTeX command deep down somewhere finally says "OK, make the 'L' big, then make a little raised 'a,' then ..."

share|improve this question
See also the related question Where do I find out how a command/environment is defined?. I don't think it is a direct duplicate, because the current question is about a specific case of macros where \show alone doesn't work. – Martin Scharrer May 10 '11 at 15:38
up vote 52 down vote accepted

Some macros are defined to be robust by expanding to \protect followed by a macro with almost the same name but ending with a space! Special care must be taken to define and use such macros because spaces are normally not allowed in macro names. If such a macro is written into external files (.aux, .toc, ...) the space is not taken as part of the macro name any longer, so that the original macro is called again.

To see the definitions of such macros you need to use the following code:

\expandafter\show\csname LaTeX \endcsname

The \csname <text>\endcsname can be used to build a macro called \<text> which can include non-letters like numbers or spaces. The \expandafter is required to expand \csname LaTeX \endcsname (note the space after the X) to \LaTeX  (also note the space here) before \show is executed.

I also programmed a command line tool called texdef to display such definitions:

 texdef -t latex LaTeX

(Instead of texdef -t latex you can also write latexdef if that name was installed)

This will display the definition of \LaTeX and detect that it calls \LaTeX  and also shows the definition of it.

$ texdef -t latex LaTeX

macro:->\protect \LaTeX  

\LaTeX :
\long macro:->L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em\TeX 

Alternatively use quotes to add the space explicitly:

 texdef -t latex 'LaTeX '
share|improve this answer
Very neat, thanks! Efficient how the LaTeX symbol uses the TeX symbol in its definition, too. – mring May 10 '11 at 15:37

An alternative to Martin's answer to to redefine \protect:


(The group is not compulsory, but means that you can keep going with a document and not have everything go wrong. If you are just making a short 'test' document, you can miss it out.)

share|improve this answer
+1 Really nice idea! – Martin Scharrer May 10 '11 at 15:54
@Martin: It's not mine - I picked it up years ago, I think when I was trying to learn what 'protected' meant. – Joseph Wright May 10 '11 at 15:55
@josephwright: so you're one of those rare beasts who read the faq?!!! – wasteofspace Jan 7 '13 at 10:42

Besides Martin's solution, there is a show2e package that I often use:

% \usepackage{show2e}

When compiling, it first gets

> \LaTeX=macro:
->\protect \LaTeX  .

And then

> \LaTeX =\long macro:
->L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize
\sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em\TeX .
<argument> \LaTeX  
share|improve this answer
I keep getting surprised by packages I never knew existed. Thanks for introducing it to me. – Martin Scharrer May 10 '11 at 16:35

With the package xpatch (or the experimental regexpatch) one can say


and get the answer

> \LaTeX =\long macro:
->L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize 
\sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em\TeX .

The command will also show the meaning of macros defined with \newcommand to have an optional argument. So, after \newcommand{\foo}[1][bar]{#1}, with \show\foo one would get

> \foo=macro:
->\@protected@testopt \foo \\foo {bar}.

but with \xshowcmd\foo the answer would be

> \\foo=\long macro:
share|improve this answer

There is a program texdef that allows this, as Martin mentions in his answer.

I would just add that when our friend Psmith is present in the community chat room, you can run texdef by posting a message in the chat of the following format:

!!/texdef -t latex -p multicol multicols

(This command will show the definition of multicols environment from the package multicol.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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