我知道这\captionsetup{format=hang}
会给我一个像这样的图形标题:
Figure 1.3: Example: This is an example that is shown here. Look at the details of this
picture!
但是我怎么会有这样的事情:
Figure 1.3: Example: This is an example that is shown here. Look at the details of this
picture!
答案1
下面声明了包addlabel
的一个新选项caption
,用于为标签设置附加文本和使用此文本的新标题标签格式(也addlabel
与 一起使用labelformat
)。这样,文本如下例子:可以作为标签的一部分,并将hang
其包含在内。
代码:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\makeatletter
% command from caption.sty
\DeclareCaptionOption{addlabel}{\def\caption@addlabel{#1}}
% new format
\DeclareCaptionLabelFormat{addlabel}{#1~#2:~\caption@addlabel}
\makeatother
\captionsetup{%
labelformat=addlabel,
addlabel={Example}, % additional label text
format=hang
}
\begin{document}
\begin{figure}[htbp]
\centering
\includegraphics[height=2cm]{example-image}
\caption{A very long caption text, which needs more than one line. Just some more text to fill it.}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[height=2cm]{example-image}
% additional label text set locally
\captionsetup{addlabel={Result}}
\caption{A very long caption text, which needs more than one line. Just some more text to fill it.}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[height=2cm]{example-image}
\caption{A very long caption text, which needs more than one line. Just some more text to fill it.}
\end{figure}
\end{document}