多列逐字记录

多列逐字记录

有人能帮我创建一个表格,其中有一些行合并,并且包含逐字文本吗?我实际上想创建 3x2 表格。像这样

\begin{tabular}{rr}
\hline
\multicolumn{2}{c}{Verbatim text(in merged row)} \\
\hline
some text      & some text \\
\hline
verbatim number & verbatim number \\
\hline
\end{tabular}

我已经尝试在这里搜索,但结果却带来了更多错误。提前致谢。

答案1

这是一个选项,使用verbdef包裹。您在宏中定义一些逐字内容,然后在需要的地方使用该宏。

在此处输入图片描述

\documentclass{article}
\usepackage{verbdef}% http://ctan.org/pkg/verbdef
\begin{document}
\verbdef{\verbtext}{Verbatim text (in merged row)}% Verbatim text
\verbdef{\verbnum}{verbatim number}% Verbatim number
\verbdef{\verbfancy}{@'#&%^}% Fancy verbatim
\begin{tabular}{rr}
  \hline
  \multicolumn{2}{c}{\verbtext} \\
  \hline
  some text  & some text \\
  \hline
  \verbnum   & \verbnum \\
  \hline
  \verbfancy & \verbfancy \\
  \hline
\end{tabular}
\end{document}​

否则,逐字文本不能按原样作为宏的参数提供。请参阅 TeX FAQ 条目:为什么逐字在...内不起作用?

答案2

看一下这个包tabu——手册中有一个名为“插入逐字材料(fancyvrb)”的(子)部分。这意味着,你fancyvrb也需要,但这不是 IME 的缺点。(我自己没有这方面的经验。)

以下是一个例子(部分摘自手册):

\documentclass{article}

\usepackage{fancyvrb}
\usepackage{tabu}

\usepackage{xcolor}

\begin{document}

According to the manual you need \texttt{tabu*} (the starred version).
I've added \Verb[commandchars=\\\{\}]|{\color{red}{\textbackslash}color}|
to show you some of the extended features of \texttt{fancyvrb}.

\bigskip

\begin{tabu*} spread 0pt {|X[-1r]|X[-1l]|}
\tabucline-
This is a small\newline
\Verb[commandchars=/\{\}]+{/color{green}\Verbatim}+ insertion
&
\vspace{-\baselineskip} %needs to be placed here
\begin{Verbatim}[commandchars=/\{\}]
And this is a complete
{/color{blue}Verbatim} environment
\end{Verbatim}
\\
\tabucline-
\end{tabu*}

\bigskip

Outside of the tabular environment \Verb|commandchars=\\\{\}| works fine,
which makes the backslash the familiar activation character for macros,
but inside it conflicts with the redefinition of \Verb|\\| -- therefore
it is replaced by \texttt{/}. There seem to be some other caveats, too --
for the comment character see the manual.

\end{document}

MWE 的结果:使用“tabu*”进行测试

相关内容