Latex two subtitle surround boards side by side

How to get two verbatim environments inside floats with auto side-by-side header?

\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} ABC \end{filecontents} \caption{example.abc} \end{fileformat} \begin{fileformat} \begin{filecontents} CBA \end{filecontents} \caption{example.cba} \end{fileformat} 

So basically I just need these examples to be side by side (and while maintaining automatic font deletion). I tried for a while.

+7
layout latex tex
source share
3 answers

I finally found the spiritual.

 \usepackage{caption} \begin{fileformat}[h] \centering \begin{minipage}[b]{0.4\textwidth} \begin{filecontents} ABC \end{filecontents} \captionof{fileformat}{example.abc} \end{minipage} \quad \begin{minipage}[b]{0.4\textwidth} \begin{filecontents} CBA \end{filecontents} \captionof{fileformat}{example.cba} \end{minipage} \end{fileformat} 

The solution to this problem is to make an inscription regardless of the environment using the macro caption package \captionof{fileformat}{Our Caption} .

+3
source share

Use minipage, as in this example, which puts two images in the direction of the figure with separate captions

 \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} 
+2
source share

For verbatim subtitles verbatim you can use listings (which will offer much more than just subtitles, syntax highlighting and line numbering for free too) or define your own float using a package with the same name.

Example (from 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} 
+2
source share

All Articles