I am having difficulty printing LaTeX from a lua function in a LaTeX document processed with lualatex (version 0.70.2). I have a sample that works (if I remove all newlines from the code) and a case that fails. I don't know why these get different results. Here is the sample that fails:
\documentclass{report}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
tex.sprint([[
\begin{tabular}{ | l | l | p{4.in} | }
\hline
{\bf File} & {\bf Cards} & {\bf Summary} \\
\hline
\end{tabular} ]])
\end{luacode*}
\end{document}
I get an error saying:
! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.22 \end{luacode*}
When I put all of the LaTeX code printed from lua on one line the code works fine:
\documentclass{report}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
tex.sprint([[ \begin{tabular}{ | l | l | p{4.in} | } \hline {\bf File} &{\bf Cards} & {\bf Summary} \\ \hline \end{tabular} ]])
\end{luacode*}
\end{document}
So I have a few question. First, why does the first example shown above fail? It seems like something I am not aware of is being inserted into the generated LaTeX.
Also is there a way for me to see the actual LaTeX that is generated and processed so that I can debug issues like this better? Is there a way to tell the lualatex to log the actual LaTeX it tries to process?
Any other suggestions for how to debug a problem like this?


tex.sprint. Is there a way to write a LaTeX stream via lua and have it processed as if it were text directly types into the document (newlines and all). I tried usingtex.sprintwith some of the catcodes defined in theluatexbase-cctbpackage (such asCatcodeTableLaTeXandCatcodeTableIniTeXbut these did not seem to help - I still got Ω characters). – Lance Larsen Jul 03 '15 at 14:35