Take the 2-minute tour ×
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.

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 .

> ...

interactively?

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
add comment

1 Answer

up vote 12 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:

\documentclass{article}
\show\list

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
(./test.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 77 languages loaded.
(/home/one/tl/tldevsrc/Master/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/home/one/tl/tldevsrc/Master/texmf-dist/tex/latex/base/size10.clo))
> \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
add comment

Your Answer

 
discard

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.