TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

In a TeX document, the primitive command \show will print out the current definition of a macro one level deep (it won't (and can't?) reduce to primitives). This comes with the restriction of actually being in the document itself, having to typeset and re-typeset over and over, and sifting through log messages (which, even with a bare-bones file, isn't nothing).

Is there a way to run a TeX session interactively such that I can

$ latex
> \documentclass{article}
blah blah blah

> \show\list
#1#2->\ifnum \@listdepth >5\relax \@toodeep \else \global \advance \@listdepth \@ne \fi 
\rightmargin \z@ \listparindent \z@ \itemindent \z@ \csname @list\romannumeral \the 
\@listdepth \endcsname \def \@itemlabel {#1}\let \makelabel \@mklab \@nmbrlistfalse 
#2\relax \@trivlist \parskip \parsep \parindent \listparindent \advance \linewidth -
\rightmargin \advance \linewidth -\leftmargin \advance \@totalleftmargin \leftmargin 
\parshape \@ne \@totalleftmargin \linewidth \ignorespaces .

> ...


share|improve this question
I don't really understand. You've executing latex from the command line, loaded the article document class and entered \show\list. Is this being interactive? If so, then you've actually done all of that. Or what do you mean by interactive? Moreover, certain macros are only available from "within the document", since the \documentclass loads a number of things. – Werner Jun 11 '13 at 3:59
The example is contrived; when I try it, I get all sorts of errors that I can't make sense of. (I've also never done an interactive session before, at least not with success.) – Sean Allred Jun 11 '13 at 11:18
up vote 14 down vote accepted

At some point you need an interactive prompt. You can get such a prompt by an error or the show functions (\show, \showthe, \showbox). The interface of the interactive prompt is quite basic, but additional stuff can be added after using action i, example session for file test.tex:


LaTeX will stop at \show\list, the stuff after ? is inserted by the user interactively:

$ latex test
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 77 languages loaded.
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
> \list=macro:
#1#2->\ifnum \@listdepth >5\relax \@toodeep \else \global \advance \@listdepth 
\@ne \fi \rightmargin \z@ \listparindent \z@ \itemindent \z@ \csname @list\roma
nnumeral \the \@listdepth \endcsname \def \@itemlabel {#1}\let \makelabel \@mkl
ab \@nmbrlistfalse #2\relax \@trivlist \parskip \parsep \parindent \listparinde
nt \advance \linewidth -\rightmargin \advance \linewidth -\leftmargin \advance 
\@totalleftmargin \leftmargin \parshape \@ne \@totalleftmargin \linewidth \igno
respaces .
l.2 \show\list

? i\makeatletter\show\@listdepth
> \@listdepth=\count34.
<insert>   \makeatletter\show\@listdepth

l.2 \show\list

? i\showthe\@listdepth
> 0.
<insert>   \showthe\@listdepth

l.2 \show\list


Nevertheless some care is needed:

  • Catcodes: The current catcode settings might not be known, here @ has catcode 12, \makeatother changes the catcode of @ to be used inside macro names. Otherwise \csname can be used:

    \expandafter\show\csname @listdepth\endcsname
  • Depending on the current context, inserting stuff might break or confuse things. For example, in a verbatim context, macros cannot be inserted as macros.

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.