[Dev-luatex] Perplexing behaviour with \directlua and tex.print

Taco Hoekwater taco at elvenkind.com
Sun May 16 21:11:19 CEST 2010

Graham Douglas wrote:
> Dear All
> I am getting some strange behaviour with the following
> minimal example via LaTeX with LuaTeX
> \pdfoutput=1
> \documentclass[12pt]{article}
> \begin{document}
> \directlua{tex.print("{\it abc}")}
> \end{document}
> I run the above and get a PDF which displays
> the following text
> protect protect protect edef OT1OT1let enc at update

\directlua expands its argument (like what happens when writing
to a file), but font switches tend to expand into internal
commands. On top of that, lua strings interpret \ as an
escape character. To circumvent both problems at the same
time, you can do this:

  \directlua{tex.print("{\\it abc}")}

Which should also work in latex (except that it trashes
the normal meaning of \\, of course).

I am pretty sure that there will be a latex package that
deals with all this expansion stuff for you.

Best wishes,

More information about the dev-luatex mailing list