如何在自动字幕并排字幕的浮标内获取两个逐字的环境?

\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}

因此,基本上,我只需要这些示例并排(并保持标题的自动努力)。我已经尝试了一段时间了。

有帮助吗?

解决方案

最终发现了灵魂。

\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}

问题解决方案是使用 caption 软件包宏 \captionof{fileformat}{Our Caption}.

其他提示

在此示例中使用小型使用,该示例将两张图片放在图形上,带有单独的字幕

\begin{figure}[htbp]
  \centering
  \begin{minipage}[b]{5 cm}
    \includegraphics{filename 1} 
    \caption{caption 1}
    \label{labelname 1}
  \end{minipage}
  \begin{minipage}[b]{5 cm}
    \includegraphics{filename 2}  
    \caption{caption 2}
    \label{labelname 2}
  \end{minipage}
\end{figure}

字幕 verbatim 您可以使用的环境 listings (这将不仅提供普通的字幕,语法突出显示和线路编号,也可以免费定义您自己的 float 使用 包裹 具有相同的名字。

一个例子(来自 Wikibooks):

\documentclass{article}

\usepackage{float}

\floatstyle{ruled}
\newfloat{program}{thp}{lop}
\floatname{program}{Program}

\begin{document}

\begin{program}
  \begin{verbatim}

class HelloWorldApp {
  public static void main(String[] args) {
    //Display the string
    System.out.println("Hello World!");
  }
}
\end{verbatim}
  \caption{The Hello World! program in Java.}
\end{program}

\end{document}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top