有没有办法在 tabularx-cell 中的 \verb 中排版 % 符号?
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\begin{document}
\verb|b%a|
\begin{tabular}{l l}
\verb|b%a| & a
\end{tabular}
\begin{tabularx}{\linewidth}{l X}
\verb|b%a| & a \\
\end{tabularx}
\end{document}
答案1
将我的评论变成答案:如果您不需要正文中的注释,tabularx
您可以将%
字符转换为可直接输入的字符。如果您需要注释,您可以使用将另一个不需要的字符转换为注释字符
\category`\<char>=14
只需<char>
用一个字符替换即可,该字符应为注释字符。在下面的示例中,我将其用于#
注释tabularx
:
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\begin{document}
\verb|b%a|
\begin{tabular}{l l}
\verb|b%a| & a
\end{tabular}
\begingroup
% use `%' as a normal character and `#` as comment character
\catcode`\#=14
\catcode`\%=12
\begin{tabularx}{\linewidth}{l X}
\verb|b%a| & a \\ # this is a comment
\end{tabularx}
# \endgroup ends the scope of our category changes, so afterwards `#' is
# again the parameter character and `%' the comments character
\endgroup
\end{document}