调用 tabularray 包创建表格时,如果单元格中包含由 verb 引入的抄录环境,则使用 XeLaTeX 会报错。MWE 如下。
\documentclass{ctexart}
\usepackage[a4paper,margin=0.5in]{geometry}
\usepackage{tabularray}
\usepackage{pifont}
\newcommand{\whiteding}[1]{\ding{\numexpr171+#1\relax}}
\newcommand{\blackding}[1]{\ding{\numexpr181+#1\relax}}
\newcommand{\whitedingB}[1]{\ding{\numexpr191+#1\relax}}
\newcommand{\blackdingB}[1]{\ding{\numexpr201+#1\relax}}
\begin{document}
\begin{table}
\centering
\caption{自定义命令}
\begin{tblr}{lc}
\hline\hline
命令 & 结果 \\
\hline
\verb|\whiteding{8}| & \whiteding{8} \\
\verb|\blackding{8}| & \blackding{8} \\
\verb|\whitedingB{8}| & \whitedingB{8} \\
\verb|\blackdingB{8}| & \blackdingB{8} \\
\hline\hline
\end{tblr}
\end{table}
\end{document}
报错信息如下。
(c:/texlive/2022/texmf-dist/tex/latex/psnfss/upzd.fd)
(c:/texlive/2022/texmf-dist/tex/latex/psnfss/upsy.fd)) (./MWE-12.aux)
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
! Missing } inserted.
<inserted text>
}
l.188 \end
{tblr}
? X
No pages of output.
Transcript written on MWE-12.log.
没有细看说明书的问题,主要是 verb
命令引起的问题,看说明书这里:
代码改成这样:
\begin{table}
\centering
\caption{自定义命令}
\begin{tblr}{verb,colspec={lc}}
\hline\hline
命令 & 结果 \\
\hline
\verb|\whiteding{8}| & \whiteding{8} \\
\verb|\blackding{8}| & \blackding{8} \\
\verb|\whitedingB{8}| & \whitedingB{8} \\
\verb|\blackdingB{8}| & \blackdingB{8} \\
\hline\hline
\end{tblr}
\end{table}