无法使用 Lua 代码将逐字输入 tblr(tabularray)环境

无法使用 Lua 代码将逐字输入 tblr(tabularray)环境

我正在尝试使用 Lua 代码写入tblr环境。我的实际代码旨在逐行生成行。但此处给出的 MWE\directlua通过调用尝试使用 中的一行来执行此操作tex.print

我也尝试过使用tex.sprint,但tex.print根据文档,它似乎更合适。

以下是 MWE:

\documentclass[version=last]{scrartcl}
\usepackage{tabularray}

\begin{document}
    \begin{tblr}{c|c|c|c}
        \directlua{ tex.print([[ 1 & 2 & 3 & 4 \\ ]], "") }
        5 & 6 & 7 & 8 \\
    \end{tblr}
\end{document}

错误是:

> Step: init table outer spec.
> Step: parse table options.
> Step: split table.
> Step: init table inner spec.
> Step: parse table inner spec.
> Step: execute table commands.
> Step: calculate cell and line sizes.

! Misplaced alignment tab character &.
l.1  1 &
       2 & 3 & 4 \\
l.12     \end
           {tblr}
I can't figure out why you would want to use a tab mark
here. If you just want an ampersand, the remedy is
simple: Just type `I\&' now. But if some right brace
up above has ended a previous alignment prematurely,
you're probably due for more error messages, and you
might try typing `S' now just to see what is salvageable.

切换tblrfortabular也会使其再次工作,但我需要tblr/tabularray来实现它的某些功能。这似乎还表明&以某种方式处理 ,使得通过 打印它\directlua与 相矛盾tabularray

我在这里做错了什么?

相关内容