tabularray抄录的%报错

发布于 2021-09-11 21:50:34

tabularray抄录%出问题

\documentclass{ctexart}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{verb}
% 删除第二个可以
\verb|aa| &  \verb|%| & \verb|\%|
\end{tblr}\\
\verb|%|
\end{document}
  • 命令行编译错误信息如下

2ec4848f58e3d4e632c53f70881bcda6.png

查看更多

关注者
0
被浏览
1.2k
乙醇
乙醇 2021-09-12
这家伙很懒,什么也没写!

这里转述 tabularray 作者 lvjrGithub 上的回复

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}

image

See also https://tex.stackexchange.com/questions/499125/verb-with-in-tabularx

2 个回答
寄存器
寄存器 2021-09-13
这家伙很懒,什么也没写!

是不是应该在表格结束后,再用\catcode`\%=14转回来呢?否则后续可能无法注释。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览