LaTeX 单元内的逐字环境?
我想在 LaTeX 表中插入一些 XML ,所以我认为 \begin{verbatim}..
将是保留语法的一个很好的解决方案,但它确实不能像这样工作:
\begin{tabular}{ ll }
sample &
\begin{verbatim}
<how>
<to value="make" />
<this value="work" />
</how>
\end{verbatim}
\end{tabular}
我怎样才能让这个工作?
I would like to insert some XML inside a LaTeX table, so I thought that \begin{verbatim}..
will be a good solution for preserving the syntax, but it does not work like this:
\begin{tabular}{ ll }
sample &
\begin{verbatim}
<how>
<to value="make" />
<this value="work" />
</how>
\end{verbatim}
\end{tabular}
How can I make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将其放入
minipage
中,如下所示:不幸的是,这意味着您必须提前决定列的宽度(这就是
{3in}
部分)做)。我通常从 3 英寸开始,然后向上或向下调整它,直到页面看起来不错并且我不再收到过满的 hbox 消息。You need to put it inside a
minipage
, like so:Unfortunately, this means you have to decide how wide the column will be in advance (that's what the
{3in}
part does). I usually start with 3in and then adjust it up or down until the page looks good and I stop getting overfull hbox messages.尝试使用
I.e.,将
verbatim
环境更改为p
类型列。其他解决方案是使用multicols
或minipage
来实现verbatim
环境。Try with
I.e., change the
verbatim
environment to be inp
type column. Other solutions are to usemulticols
or aminipage
for theverbatim
environment.通过
fancyvrb
包,您可以将BVerbatim
与baseline=t
结合使用,让 LaTeX 为您工作。为了方便起见,我在这里创建了一个新的逐字环境(
Code
):结果如下:
With
fancyvrb
package you could useBVerbatim
withbaseline=t
and let LaTeX work for you.Here I've created a new verbatim environment (
Code
) for convenience:Here the result: