[luatex] Where can I learn more about catcodes in LuaTeX?

David Carlisle d.p.carlisle at gmail.com
Sat Jun 6 23:38:49 CEST 2020

This isn't the right list really especially as your questions are more
latex than luatex related in many ways.
You may prefer to ask on tex.stackexchange.com

On Sat, 6 Jun 2020 at 19:11, Eduardo Ochs <eduardoochs at gmail.com> wrote:

> The message about catcodes that I sent yesterday is here:
>   https://tug.org/pipermail/luatex/2020-June/007364.html
> It contains a simple test that reveals - I mean, to an imaginary
> newbie reading it - that the TeX interpreter and tex.print use two
> different catcode tables.

Not really, it's just the standard issue that you can't use  verbatim in
the argument
of another command. You used tex.print but you would see the same from

without using luatex at all.

As you have the text in a Lua string you don't really need verbatim

You could write out the tokens with \catcodetable at string  as the first
optional catcode table argument. (If I understand your use case)
but you would have to split up the string on \n first and print each
verbatim line separately.

Or you could print using the default catcode table but quote teh special
characters first. I give a small example of this at the end.

> One obvious place to learn more about these different catcode tables
> is the LuaTeX reference manual. Let me use a trick from eev to point
> to sections of the manual. The trick is explained here,
> at6.html#hacking <http://angg.twu.net/dednat6.html#hacking>

for the latex interface you could try

texdoc ltluatex
and perhaps
texdoc ctablestack

Here's a small example

verb.Lua defines a multi-line string then makes it safe for the latex
document test.tex


aaa  bbb  \gggg
     jjj { \zzz
tex.print("\\begin{flushleft}\\ttfamily\\let\\\\=\\textbackslash ")
gsub(' ','\\ '):
gsub('\n','\\par ')
.. "")




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/luatex/attachments/20200606/f1561b14/attachment.html>

More information about the luatex mailing list.