I often need to look up a catcode table, and quick searches on the web are rarely satisfying.
So I thought, it must be (in the long term) easier to use a Latex function of sorts, to loop through all 8-bit sequences (that is, ASCII characters), and print out:
[ASCII code] - [ASCII character] - [catcode] - [catcode meaning]
A "reverse indexing" would be nice as well – where catcodes are output, and then which ASCII chars belong to them, e.g:
[catcode] - [catcode meaning]:
[ASCII code1] - [ASCII character1]
[ASCII code2] - [ASCII character2]
....
Just wanted to note – I'd like such a table to be \typeout
ed to the terminal (not typeset in a PDF).
In #21397 – How to get the catcode of a token?, a \printcatcode
exercise is mentioned, that answers the mapping from ASCII character to a verbose catcode meaning…
So I guess, one would just have to make a loop from 0 to 255 (maybe something similar to approaches in An expandable 'character scanning' command?), and apply all such relevant transformations – unfortunately, I'm not mastering tex core on a level where I can come up with that code off the top of my head. But maybe a function for something like this already exists?
Any suggestions for code that I could use in this context?
Best Answer
Well, here is a partial answer - does everything, (
except I don't know how to output ASCII code as character on terminal in Latex (EDIT: Fixed thanks to\char
apparently typesets, and it's not expandable, so cannot be used in\typeout
)uccode
trick by @DavidCarlisle in comments.), except the "reverse lookup".(EDIT2: See also the
texref
tool (not the package) in comment by @codebeard)The output is something like this:
.. and the code is here: