\documentclass{ctexart}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{verb}
% 删除第二个可以
\verb|aa| & \verb|%| & \verb|\%|
\end{tblr}\\
\verb|%|
\end{document}
这里转述 tabularray
作者 lvjr
在 Github 上的回复
The %
and characters after it are removed by TeX before tabularray
or tabularx
sees them. You need to change the catcode of %
character to make TeX treat it as a normal character.
\documentclass{article}
\usepackage{tabularray}
\usepackage{tabularx}
\usepackage{fancyvrb}
\begin{document}
For \texttt{tabularray}:
\begingroup
\catcode`\%=12
\begin{tblr}{verb}
\verb|a| \\
\verb|%| \\
\verb|\%|
\end{tblr}
\quad
\begin{tblr}{verb,columns={preto={\Verb|},appto={|}}}
a \\
% \\
\%
\end{tblr}
\endgroup
For \texttt{tabularx}:
\begingroup
\catcode`\%=12
\begin{tabularx}{\linewidth}{X}
\verb|a|\\
\verb|%|\\
\verb|\%|
\end{tabularx}
\endgroup
\end{document}
See also https://tex.stackexchange.com/questions/499125/verb-with-in-tabularx
刚看到了
在上面回答用了
\begingroup
和\endgroup
,这段话是The TeXbook.pdf内的,估摸是这个意思