Question

Comment obtenir deux environnements verbatim à l'intérieur des flotteurs avec côte à côte le sous-titrage automatique?

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

Donc, fondamentalement, je viens besoin de ces exemples pour être installés côte à côte (et en gardant nunbering automatique des sous-titres). Je l'ai essayé pendant un certain temps maintenant.

Était-ce utile?

La solution

Nous avons trouvé l'Soulution enfin.

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

La solution du problème est de faire une légende indépendamment dans l'environnement en utilisant paquet caption macro \captionof{fileformat}{Our Caption}.

Autres conseils

Utilisez minipage comme dans cet exemple, qui place deux images côte à l'intérieur d'un flotteur figure avec des sous-titres séparés

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

Pour le sous-titrage des environnements de verbatim vous pouvez soit utiliser listings (qui offrira beaucoup plus que le sous-titrage tout simplement, la coloration syntaxique et la numérotation des lignes venir gratuitement aussi) ou définir votre propre environnement float utilisant le package avec le même nom.

Un exemple (de 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}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top