I was trying to get a table like this
1
2 3 4
5 6 7
8 9 10
with this function
function myTable()
t = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
for k = 1, #t do
if k == 1 then
tex.print(string.format([["& %d & \\"]], t[1]))
else
tex.print(string.format([["%d & %d & %d \\"]],
t[k], t[k + 1], t[k + 2]))
k = k + 2
end
end
end
but it says:
ua:25: bad argument #4 to 'format' (number expected, got nil)
How to do that? Looks like lua's got a weird way of implementing for loop, am I wrong?
In my document I've:
\documentclass{article}
\usepackage{harfload,fontspec,amsmath}
\setmainfont{Kalpurush}[RawFeature={mode=harf}]
\parindent 0pt
\directlua{require("test.lua")}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{ccc}
\directlua{myTable()}
\end{tabular}
\end{table}
\end{document}