Ego*_*gon 7 layout latex tex verbatim
如何在浮动内部使用自动字幕并排获得两个逐字环境?
\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}
Run Code Online (Sandbox Code Playgroud)
所以基本上我只需要将这些示例并排(并保持字幕的自动识别).我已经尝试了一段时间了.
终于找到解决办法了。
\usepackage{caption}
\begin{fileformat}[h]
\centering
\begin{minipage}[b]{0.4\textwidth}
\begin{filecontents}
A B C
\end{filecontents}
\captionof{fileformat}{example.abc}
\end{minipage}
\quad
\begin{minipage}[b]{0.4\textwidth}
\begin{filecontents}
C B A
\end{filecontents}
\captionof{fileformat}{example.cba}
\end{minipage}
\end{fileformat}
Run Code Online (Sandbox Code Playgroud)
caption问题的解决方案是使用宏包制作独立于环境的标题\captionof{fileformat}{Our Caption}。