# [texhax] \directlua in LuaLaTeX

Arno Trautmann Arno.Trautmann at gmx.de
Thu Feb 4 23:33:25 CET 2010

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.
\\  -&gt;\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?

cheers
Arno