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.

  • 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

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

>@ >$ >& ># >^ >_
\newmuskip\bar >\bar
% outer macros must be handled specially
\long\def\longm#1{Blah #1} >\longm
\long\outer\def\olongm#1{Blah #1}
>\relax % Example of a TeX primitive
% See the comments for remarks on these five:
  • 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

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.

  • Unfortunately, you are right, and I will have to do that :(. – Bruno Le Floch Jan 10 '12 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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