0

Following the suggestion from pythontex section Troubleshooting for the tabular environment, I have created following minimal example using pyluatex instead of pythontex:

%! TeX program = lualatex
\documentclass{article}
\usepackage{pyluatex}
\usepackage{tabularray}

\begin{document} % needs to be after document \let\row\relax \begin{python} print("\global\def\row{a & b & c & d & e \\}") \end{python}

\begin{tblr}{|c|c|c|c|c|} a & b & c & d & e \ \row \end{tblr}

\end{document}

Command to compile document

❯ lualatex --output-format=pdf --shell-escape pyluatex-tabularray.tex

Output

This is LuaHBTeX, Version 1.15.0 (TeX Live 2022)
 system commands enabled.
(./pythontex-tabularray.tex
LaTeX2e <2021-11-15> patch level 1
 L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-luatex.def))
(/usr/local/texlive/2022/texmf-dist/tex/latex/kvoptions/kvoptions.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/atveryend-ltx.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/tabularray/tabularray.sty)
(./pythontex-tabularray.aux)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)
! Misplaced alignment tab character &.
\row ->a &
           b & c & d & e \\
l.17 \end
       {tblr}
?

As you can see the compilation fails.

How can I use python code to generate many rows in tabularray?

A solution with pythontex is equally good.

Hotschke
  • 5,300
  • 5
  • 33
  • 63
  • 1
    Thank you. Apparently, I was not good at checking. There are two other questions: https://tex.stackexchange.com/questions/617961/tabularray-expand-multiple-macros and https://tex.stackexchange.com/questions/604228/tabularray-reading-a-table-stored-in-a-macro-by-catchfile. However, I am not sure my second question is captured as well. I will add a complete example and will look into it. – Hotschke Aug 16 '22 at 15:34
  • Since your first question is answered by the duplicates and it is preferred on the site to have only one problem per question, maybe you can remove the first part entirely and focus your question only on the second problem? – Marijn Aug 16 '22 at 15:42
  • I think I will open a new question. I could imagine the search combination python/pythontex and tabularray can help others. – Hotschke Aug 16 '22 at 15:46
  • My second question is now here https://tex.stackexchange.com/questions/654222/macro-in-mandatory-argument-of-tblr-of-tabularray-does-not-work – Hotschke Aug 16 '22 at 15:53
  • Ok, but in that case it may be better to remove the second issue from this question and close as a duplicate of either my link or one of yours. – Marijn Aug 16 '22 at 15:55
  • 1
    Done. I have removed the 2nd question and marked it as duplicate. – Hotschke Aug 16 '22 at 15:56

0 Answers0