ラテックス2つのキャプション付き逐語的環境
質問
自動キャプションを並べてフロート内に2つの逐語環境を取得するにはどうすればよいですか?
\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
を使用した環境 パッケージ 同じ名前で。
例(から ウィキブークス):
\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}
所属していません StackOverflow