Web2c defines its format style using Pascal strings, so there are no separator characters between csnames. Is there a straightforward way of listing all csnames bound in a .fmt file?

  • 1
    Asked on SO, stackoverflow.com/questions/3163354/…, with a magnificent 3 views. I though I'd ask it here before offering a bounty there. – Charles Stewart Jul 27 '10 at 8:54
  • 1
    It's not web2c that does this, I think: TeX stores the format as Pascal strings as TeX is written in Pascal. (Web2C is just a way to get it to compile, as Pascal as Knuth used is not available for use.) – Joseph Wright Jul 29 '10 at 21:50
  • Joseph is (w)right, of course :-) – Arthur Reutenauer Aug 1 '10 at 22:46
  • 1
    But the Web2C implementation is actually relevant here, as I discovered: it seems, from my observations, that the format files generated by TeX programs compiled with that system have a short chunk of extra data added at the beginning (with respect to what’s described in TeX: The Program). The first four bytes, for example, are always W2TX in ASCII (standing for “Web2C TeX” or something similar, I suppose), then you have 4 more bytes that seem to be some sort of version number, then a C string for the engine name, etc. The actual data output by TeX proper begins at about byte 0x300. – Arthur Reutenauer Aug 5 '10 at 23:27
  • @Joseph, @Arthur: The key point being that the quasi-documented Knuth format file was changed in Web2c. Looking at the .fmt files under $TEXLIVE/texmf-var/web2c shows other constant characters for the other Tex implementations. – Charles Stewart Aug 8 '10 at 8:26

In the Web2C implementation of TeX and friends, the programs come with an (apparently undocumented) option -debug-format that prints out a lot of information contained in the format file, most of which consists of the names of the control sequences (followed by a pipe sign: |).

Hence, for example:

$ tex -debug-format \\bye 
This is TeX, Version 3.1415926 (TeX Live 2009)
fmtdebug:format magic number = 1462916184
fmtdebug:engine name size = 4
fmtdebug:string pool checksum = 57981441
fmtdebug:mem_bot = 0
fmtdebug:mem_top = 2999999
fmtdebug:string pool size = 29307
fmtdebug:sup strings = 2025
fmtdebug:csnames from 514 to 24525:

is the list of all control sequences defined in tex.fmt.

  • In LaTeX I see nice font macros generated by the NFSS: \<5><6><7><8><9>gen*cmmi<10><10.95>cmmi10<12><14.4><17.28><20.74><24.88>cmmi12 :-) – Arthur Reutenauer Aug 5 '10 at 21:35
  • This is gold. It doesn't look like everything I get from echo /dev/null|tex -fmt tex/tex.fmt -debug-format 2>&1 |fgrep "|"|sort|uniq -c (in the texmf-var directory) is a csname though: there are many occurrences of "preloaded" in the output, and several of strings like "tentt". Might you know how to filter these, other than by checking that each is a macro using a \show query? – Charles Stewart Aug 8 '10 at 9:03
  • 1
    \preloaded is a macro that is used to preload some fonts so that they're dumped in the format; it's used several times as a font name in plain.tex, and then assigned to \undefined, which is why you don't see them when you run TeX. The point is that even if the font is not available from stock plain TeX, you can take advantage of it being embedded in the format if you want to use it. – Arthur Reutenauer Aug 8 '10 at 16:46
  • This doesn't make sense to me - format files aren't Tex programs, they're state dumps. How could a single csname have multiple contents? – Charles Stewart Aug 9 '10 at 9:08
  • 1
    I can't claim I understand everything about it, but for all I know, csnames are only particular elements of the string pool to which elements of the hash table are mapped. Hence different macro definitions can point to copies of the same string, even if, obviously, at most one of these definitions will be accessible from inside TeX (and in this case, the control sequence is even “defined” to \undefined eventually). – Arthur Reutenauer Aug 9 '10 at 15:33

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.