This seems to work:
\documentclass{article} \usepackage[T1]{fontenc} \usepackage{expl3,xparse} \usepackage{tabularray} \UseTblrLibrary{functional} \IgnoreSpacesOn \prgNewFunction \makerows {m} { \intReplicate {#1} {{} & & & \\\hline } } \IgnoreSpacesOff \begin{document} With tabular: \begin{tabular}{|c|c|c|c|} \hline a & b & c & d \\\hline \makerows{5} \end{tabular} With tblr: \begin{tblr}[evaluate=\makerows]{|c|c|c|c|} \hline a & b & c & d \\\hline \makerows{5} \end{tblr} \end{document}
Adapted from the example of the tabularray manual on page 46. However I am not quite sure why I need the empty {} in the definition of my empty row.
Nevertheless I want to understand why the initial latex3 approach didn't work. The problem seems to be related to the replicate function.
Edit
Using lualatex seems to work with the expand-key as mentioned by @JamesT in the comment above:
\documentclass{article} \usepackage{tabularray} \usepackage{luacode} \begin{luacode} function makerows(n) for i = 1, n do tex.sprint("& & & \\\\\\hline") end end \end{luacode} \begin{document} \begin{tblr}[expand=\directlua]{c|c|c|c} a & b & c & d \\\hline \directlua{makerows(10)} \end{tblr} \end{document}
Edit 2
I also tried pythontex which does not work even with the expand key:
\documentclass{article} \usepackage{tabularray} \usepackage[gobble=auto]{pythontex} \begin{pycode} def makerows(n): for i in range(0,n): print(r"& & & \\\hline") \end{pycode} \begin{document} \begin{tblr}[expand=\pyc]{c|c|c|c} a & b & c & d \\\hline \pyc{makerows(3)} \end{tblr} \end{document}
I guess it doesn't work, because
Printed content is saved in a file and then included via \InputIfFileExists. But \InputIfFileExists is not expandable
as described here.
tblr,tblrneeds to see the&in advance, I tried usingexpand=\makerowsin your question but it still doesn't work, hopefully someone else can help!: tex.stackexchange.com/a/691258/273733luaversion is interesting how that works, will try that in the future, nice workaround