我想绘制一个有两列的表格:第一列包含一些LaTeX
命令,第二列包含预览。我不想在每一行中插入命令\verb++
,而是想利用<>
列说明符。但这会导致编译错误。请考虑以下 MWE:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\begin{tabular}{ll}
%\begin{tabular}{>{\verb+}l<{+}l} <--- what I want to use
\verb+\LaTeX+ & \LaTeX
\end{tabular}
\end{table}
\end{document}
答案1
https://tex.stackexchange.com/a/207977/197451
第一种方法是使用 collectcell 和 detokenise
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{array,collcell}
\newcommand{\myverb}[1]{\ttfamily\detokenize{#1}}
\begin{document}
\begin{tabular}{ >{\collectcell\myverb}l<{\endcollectcell} l }
PI_all_data_BBB_M15X.pdf & Results for \verb=BBB= model with profile plots \\
PI_all_data_BetaBin_M15X.pdf & Results for \verb=BetaBin= model with profile plots \\
PI_all_data_BinLNB_M15X.pdf & Results for \verb=BinLNB= model with profile plots \\
PI_all_data_Bin_M15X.pdf & Results for \verb=Bin= model with profile plots \\
PI_all_data_LogGamma_M15X.pdf& Results for \verb=LogGamma= model with profile plots \\
PI_all_data_TwoBin_M15X.pdf & Results for \verb=TwoBin= model with profile plots
\end{tabular}
\end{document}
第二种方法,使用 shortvrb 包
\documentclass{article}
\usepackage{shortvrb}
\MakeShortVerb{\|}
\begin{document}
\begin{tabular}{l l}
|some % text here| & some text here \\
|some $ text here| & some text here \\
|some { text here| & some text here \\
\end{tabular}
\end{document}