[luatex] Changing catcodes in \directlua

luigi scarso luigi.scarso at gmail.com
Tue Jul 6 09:45:57 CEST 2010


On Tue, Jul 6, 2010 at 8:34 AM, Paul Isambert <zappathustra at free.fr> wrote:
> Things are expanded in a \directlua statement, like in a \write or \special.
> And what is not exanded, e.g. primitives like \begingroup, is interpreted as
> Lua code, where quite obviously a string like "\begingroup" doesn't make
> sense. The simplest solution to achieve what you want is:
>
> \directlua{tex.print("\luaescapestring{$\noexpand\alpha$}")}
>
> which turns into correct Lua code: first because \alpha isn't expanded,
> second because \luaescapestring modifies its argument so that you get what
> you want. Forgetting it leads to Lua reading
>
> tex.print("$\alpha$")
>
> which you might find sensible but to Lua it means ``print the dollar
> character, then a bell, then the `lpha'$ string.'' I say ``a bell'' because
> \a is an escape sequence that refers to this character, which let's admit
> isn't the most often used nowadays. On the other hand the sequence with
> \luaescapestring returns this to Lua:
>
> tex.print("$\\alpha$")
>
> which means ``print a dollar, a backslash `alpha', and a dollar'' and that's
> correctly interpreted by TeX. (Note that I'm using LuaTeX v.0.6, hopefully
> it'll change nothing.)
What about
\directlua{tex.print([[$\alpha$]])}
?
-- 
luigi


More information about the luatex mailing list