[texhax] Question about cwebmac.tex

Igor Liferenko igor.liferenko at gmail.com
Fri Feb 5 06:54:41 CET 2016

Hi all,

cwebmac.tex escapes braces (and other symbols) with backslash, because
they are special to pdf.
For example, the string "Foo (test) program" is written to outline as
"Foo \(test\) program".
But this becomes a problem with \directlua:

! LuaTeX error [\directlua]:1: invalid escape sequence near '\('.
\ZZ ...er {chunk#2.#3} {\directlua {toutf16("#5")}
l.2 ...test) program}{1}{1}{1}{Foo \(test\) program}

Even though cwebmac.tex sets the catcode of the backslash to 12 before
the call to lua, lua tries to interpret `\' as the escape character.
The following example demonstrates this:

  function toutf16(str)
\def\foo{Foo \Uchar`\\(test\Uchar`\\) program} % backslash with catcode 12
\pdfoutline goto num 3 {\directlua{toutf16("\foo")}}

The question is how to tell LuaTeX to leave catcode of backslash 12 if
it was 12 when lua was called?

Best regards,

More information about the texhax mailing list