[texhax] \directlua in LuaLaTeX

Ulrike Fischer news3 at nililand.de
Fri Feb 5 10:18:14 CET 2010


Am Thu, 04 Feb 2010 23:33:25 +0100 schrieb Arno Trautmann:

> Hi all!
> 
> I was playing around a bit with LuaLaTeX (from TeXlive2009) and tried to
> execute TeX code in a \directlua{tex.print()}.
> 
> The LuaTeX manual shows the following example (of course without the
> LaTeX-stuff, only line 3):
> 
> \documentclass{minimal}
> \begin{document}
> before\directlua{tex.sprint("\\relax")tex.sprint(" inbetween")}after
> \end{document}
> 
> But if I compile this with lualatex, I get a big heap of errors starting
> with
> 
> ! Undefined control sequence.
> \\  ->\let \reserved at e
>                        \relax \let \reserved at f \relax \@ifstar {\let
> \reserv...
> l.4 before\directlua{tex.sprint("\\
>                                    relax")tex.sprint(" inbetween")}after
> 
> So … I don’t understand where the problem comes from and how to
> interpret these errors. I assume there is a problem that \directlua
> expands all the TeX code directly and that this might clash anyhow with
> a \protect. But no idea why this is evil …
> 
> Can anybody help me understanding this behaviour?

\\ is a command in LaTeX but probably not in context. The following
seems to work (but my luatex is rather old, version 0.39)

\documentclass{minimal}
\begin{document}
before\directlua{tex.sprint("\string\\relax")tex.sprint("
inbetween")}after

before\directlua{tex.sprint("\luaescapestring{\relax}")tex.sprint("
inbetween")}after
\end{document}


-- 
Ulrike Fischer 



More information about the texhax mailing list