Latex 两个并排的带标题的逐字环境
如何在浮动中获得两个逐字环境并并排自动添加字幕?
\usepackage{float,fancyvrb}
...
\DefineVerbatimEnvironment{filecontents}{Verbatim}%
{fontsize=\small,
fontfamily=tt,
gobble=4,
frame=single,
framesep=5mm,
baselinestretch=0.8,
labelposition=topline,
samepage=true}
\newfloat{fileformat}{thp}{lof}[chapter]
\floatname{fileformat}{File Format}
\begin{fileformat}
\begin{filecontents}
A B C
\end{filecontents}
\caption{example.abc}
\end{fileformat}
\begin{fileformat}
\begin{filecontents}
C B A
\end{filecontents}
\caption{example.cba}
\end{fileformat}
所以基本上我只需要这些例子并排(并保持标题的自动编号)。我已经尝试了一段时间了。
How to get two verbatim environments inside floats with automatic captioning side-by-side?
\usepackage{float,fancyvrb}
...
\DefineVerbatimEnvironment{filecontents}{Verbatim}%
{fontsize=\small,
fontfamily=tt,
gobble=4,
frame=single,
framesep=5mm,
baselinestretch=0.8,
labelposition=topline,
samepage=true}
\newfloat{fileformat}{thp}{lof}[chapter]
\floatname{fileformat}{File Format}
\begin{fileformat}
\begin{filecontents}
A B C
\end{filecontents}
\caption{example.abc}
\end{fileformat}
\begin{fileformat}
\begin{filecontents}
C B A
\end{filecontents}
\caption{example.cba}
\end{fileformat}
So basically I just need those examples to be side-by-side (and keeping automatic nunbering of caption). I've been trying for a while now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于字幕
逐字
环境,您可以使用listings
(它提供的不仅仅是简单的字幕,语法突出显示和行号也是免费的)或定义您自己的float
环境使用 package同名。示例(来自 WikiBooks):
For captioning
verbatim
environments you can either uselistings
(which will offer much more than just plain captioning, syntax highlighting and line numbering come for free too) or define your ownfloat
environment using the package with the same name.An example (from WikiBooks):
终于找到解决办法了。
问题的解决方案是使用
caption
包宏\captionof{fileformat}{Our Caption}
制作独立于环境的标题。Found the soulution finally.
The problem solution is to make a caption independently from environment using
caption
package macro\captionof{fileformat}{Our Caption}
.使用像本示例中这样的小型页面,它将两张图片并排放置在一个带有单独标题的图形浮动中
Use minipage like in this example, which places two pictures side by within a figure float with separate captions