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 the context of a debugging package that I am writing, I need to analyse an arbitrary token in the input stream. What are the possible outcomes of \meaning<token>?

  • Macro: (\protected) (\long) (\outer) macro:#1#2->...#1...#2... (exactly characterized by the presence of ->?)
  • Character (implicit or explicit): the letter A or begin-group character { etc.
  • Primitive, e.g., \relax
  • \toks23, \char"12, \count0, and others?

There are many other types, probably, that I don't know about... select font cmr10? mathchars? boxes?

It would be great to have a complete list. Also, tips on how to parse the meaning and extract useful information from it are welcome.

share|improve this question
    
Two ideas to figure that out: 1) check the TeXBook again, 2) write a script/document which executes \meaning with all macros you can find. You need e.g. a Perl script to extract them from, say all base LaTeX or even all package files. Then you have a good statistic. –  Martin Scharrer Feb 2 '11 at 13:49
    
Yes, there is \mathchar"1. But nothing special for boxes. They are defined using \chardef, i.e. just by number. –  Martin Scharrer Feb 2 '11 at 14:15
    
@Martin: I am more or less doing that, but I probably will miss something in the process. The TeXbook is not very verbose about meaning, but I guess that I can go through all the primitives and check what they do. –  Bruno Le Floch Feb 2 '11 at 17:00
    
BTW, this package you are programming seems to be quite interresting. How far along are you? Is this a general purpose debugging package? –  Martin Scharrer Feb 2 '11 at 18:20
    
@Martin thanks. My goal is to emulate TeX's mouth + stomach step by step. I should output only primitives related to typesetting, which should produce the correct visual result. Of course, this is impossible to fully achieve, so my focus is on getting the steps (expansion, def, and other non-typesetting stuff) right. I use it to debug my macros, and probe LaTeX's internals in the stomach ("gastrology?"). –  Bruno Le Floch Feb 2 '11 at 19:01
add comment

2 Answers

up vote 10 down vote accepted

The output of this file lists all the ones I can think of. (Edited (thrice) in response to comments.)

\catcode`\>=\active
\long\def>#1{\immediate\write0{\meaning#1.}}
>\bgroup
>\egroup
>@
\catcode`\@=11
>@ >$ >& ># >^ >_
>\z@
>\z@skip
\newmuskip\bar >\bar
>\mscount
>\toks@
% outer macros must be handled specially
\edef\foo{\meaning\newbox}\immediate\write0{\foo.}
\long\def\longm#1{Blah #1} >\longm
\long\outer\def\olongm#1{Blah #1}
\edef\foo{\meaning\olongm}\immediate\write0{\foo.}
>\relax % Example of a TeX primitive
>\voidb@x
>\intop
>\tenrm
>\undefined
% See the comments for remarks on these five:
>\topmark
>\firstmark
>\botmark
>\splitfirstmark
>\splitbotmark
\end
share|improve this answer
    
I would at least add @ with and without \makeatletter to get the character @ and the letter @. Also be careful with \par as an example for a TeX primitive, because LaTeX redefines it sometimes. \relax would be better. –  Martin Scharrer Feb 2 '11 at 15:53
    
@Harald: do you know what produces select font ...? And do you happen to know what is added by e-TeX (e.g., \protected macro...)? –  Bruno Le Floch Feb 2 '11 at 16:58
    
@Bruno: In plain TeX, \show\tenrm gives \tenrm=select font cmr10. It's a font defined by \font\tenrm=cmr10. Does this help? –  Hendrik Vogt Feb 2 '11 at 17:09
2  
Thanks all, I edited the answer. I had forgotten about \tenrm and friends. I replaced \par by \relax, though it's worth noting that any control sequence that has been \let equal to some TeX primitive will be given the original name of that primitive when you ask for its \meaning. –  Harald Hanche-Olsen Feb 2 '11 at 17:51
    
@Hendrik: it helps, thanks. @Harald: I thinks the best is that I post updates to the list as a comment if it turns out to be incomplete. –  Bruno Le Floch Feb 2 '11 at 19:08
show 7 more comments

This is again a question for looking into the program code I would say: module §296 is the starting point and then you have to follow how print_cmd_chr though the TeX spaghetti code. The latter routine is unfortunately split accross the whole code more or less the whole code (or more exactly it is split into 40 pieces). If you own a printed version of the TeX source then §227 is your friend which is where it starts. This way you'll find things like end of alignment template and many more.

share|improve this answer
    
Unfortunately, you are right, and I will have to do that :(. –  Bruno Le Floch Jan 10 '12 at 2:17
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.