Search code examples
lualatextextabular

Arrange lua/lualatex data in a Latex/tex tabular


I have data in lua, accessible to a LaTeX/TeX document (it is an array). I try to show this data in a LaTeX tabular form. I tried several ways to do this but all failed :( . Here is an example :

\begin{tabular}{|c|c|c|}\hline 
A&B&C\\ \hline
2010 & 2,78 &\\ \hline
\luaexec{for i=1,nA do;
tex.print(i.."& "..data_a[1][i].." &"..data_a[2][i]..[[\\ \hline]]);
end;}
\end{tabular}

I have this error : "use of @@array don't match its definition". Basically, everything would work except when I try to put a newline \ in the loop.

Any idea welcome !!


Solution

  • This is working !

    \begin{tabular}{|c|c|c|c|}\hline  A&B&C&D\\ \hline
    \luaexec{for i=1,nA do; tex.print(i.."& "..data_a[1][i].." &"..data_a[2][i].."&\\\\ \\hline") end}
    \end{tabular}