[luatex] % character in \directlua

Paul Isambert zappathustra at free.fr
Sat Feb 19 10:16:24 CET 2011


Le 19/02/2011 01:10, Yannis Haralambous a écrit :
> Hi everybody, and sorry for my mailer: it gives me only two choices, either "text" (my current choice, believe it or not) or "rtf".
>
> I'm writing to ask whether there is a more elegant way to use a % in a \directlua argument (I need the Lua modulo operator)
> besides changing the catcode of % to 12 around the \directlua command:
>
> \begingroup
> \catcode`\%=12
> \directlua{texio.write(5 % 2)}
> \endgroup
>
> I have tried \%, \string%, nothing works besides the code above.

Any solution implies either catcode change or \string. The simplest, 
perhaps, would be to define a macro:

\bgroup
\escapechar=-1
\xdef\pc{\string\%}
\egroup

and then use \pc instead of %:

\directlua{texio.write(5 \pc 2)}

There's nothing more elegant, since we're basically dealing with verbatim.

Best,
Paul


More information about the luatex mailing list