luatex tex.sprint'ing \SetCell이 다른 결과를 생성함

luatex tex.sprint'ing \SetCell이 다른 결과를 생성함

나는 를 사용하여 tabularray의 매크로 주위에 래퍼를 만들 것입니다 . 그러나 생성하기 위해 사용하면 직접 입력하는 것과 다른 결과가 생성됩니다. 두 결과를 일치시킬 수 있는 방법에 대해 어떻게 생각하시나요?\SetCelllualatextex.sprint\SetCell[c=2]{c}

여기에 이미지 설명을 입력하세요

MWE:

\documentclass{scrartcl}
\usepackage{luacode}
\usepackage{tabularray}

\begin{luacode*}
  function setcell(s)
    tex.sprint('\\SetCell[c='..s..']{c}')
  end
\end{luacode*}
\NewDocumentCommand{\SC}{O{}}{\luadirect{setcell(\luastring{#1})}}

\begin{document}

SetCell demonstration:\\
\begin{tblr}{|lll|}
  \SetCell[c=2]{c} MULTI & & z \\
  a & b & c\\
\end{tblr}

tex.sprinting SetCell thru lualatex:\\
\begin{tblr}{|lll|}
  \SC[2] MULTI & & z \\
  a & b & c\\
\end{tblr}

\end{document}

답변1

tabularray패키지 매뉴얼(v2024A, 2024-02-16) 에 따르면 , sec. 2.1 "기존 인터페이스와 새 인터페이스",

tabular환경 과 동일 array, 모든 테이블 명령~ 해야 하다셀 텍스트의 시작 부분에 배치됩니다. 또한 새로운 테이블 명령~ 해야 하다으로 정의합니다 \NewTableCommand.

\SetCell은 내장 테이블 명령 중 하나이며 사용자의 \SC명령은 테이블 명령이어야 하기 때문에 래퍼 \SetCell이므로 로 정의해야 합니다 \NewTableCommand.

% !TeX program = lualatex
\documentclass{scrartcl}
\usepackage{luacode}
\usepackage{tabularray}

\begin{luacode*}
  function setcell(s)
    tex.sprint('\\SetCell[c='..s..']{c}')
  end
\end{luacode*}
\NewTableCommand{\SC}[1][]{\luadirect{setcell(\luastring{#1})}}

\begin{document}

SetCell demonstration:\\
\begin{tblr}{|lll|}
  \SetCell[c=2]{c} MULTI & & z \\
  a & b & c\\
\end{tblr}

tex.sprinting SetCell thru lualatex:\\
\begin{tblr}{|lll|}
  \SC[2] MULTI & & z \\
  a & b & c\\
\end{tblr}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보