I am not sure if I use the wrong approach or if this is an issue in LuaLaTex in general. I tried to integrate some internationalization (I18n) to our documentation framework using Lua. Long story, short: I want to read the caption of general sections like 'references', 'appendix' and other from a resource file. But using a luaexec in \chapter or \section writes useless entries to .aux and therefore also in .toc .lof and .lot files.
This is my small sample:
\documentclass[]{article}
\usepackage{luacode}
\newcommand{\intString}[1]{\luaexec{tex.print("#1")}}
\begin{document}
\section{\intString{test}} %this breaks
\intString{lofCaption} % this works
\cleardoublepage
\addcontentsline{toc}{chapter}{\intString{lofCaption}} % this breaks
\protect\listoffigures
\cleardoublepage
\addcontentsline{toc}{chapter}{\intString{lotCaption}} % this breaks
\protect\listoftables
\end{document}
I have no idea why this causes some entries like this in my .aux file:
\@writefile{toc}{\contentsline {section}{\numberline {1}\begingroup \escapechar 92 \newlinechar 10 \edef \\{\\}\edef \nobreakspace {}{~}\let \%=%\let \#=#\endgroup test}{1}}
It looks like during creation of .aux file the lua code is neither executed nor written to the .aux but replaced by something looking like a reference.
Does anyone know if this is a malfunction of LuaLaTeX or if there is a mistake on my part?
Thank you for your attention.
.toc
file. With\addcontentsline{toc}{chapter}{<tokens>}
you write in the.toc
file a line\contentsline{chapter}{<expansion of tokens>}
and that' in fact the expansion of\luaexec
– egreg Jul 23 '14 at 10:43babel
mechanism for that. – Johannes_B Feb 18 '15 at 21:11