我在 LaTeX 中有一个图形,其标题不适合一行,例如
\begin{figure}
\includegraphics{}
\caption{This is a very long caption that does not fit into one line}
\end{figure}
生成的 PDF 如下图所示:
Figure 1: This is a very long caption that does not fit
into one line
我希望标题的第二行与标题的开头对齐(而不是文本“图 1”),以使其看起来像
Figure 1: This is a very long caption that does not fit
into one line
我怎样才能做到这一点?
答案1
您需要使用适当的字幕设置。例如:
\documentclass{book}
\usepackage{graphicx}% <-- for more options, read caption manual
\usepackage[hang]{caption}% <-- for more options, read caption manual
\setlength\textwidth{77mm}
%\usepackage[active,floats,tightpage]{preview}% just for see figure
%\setlength\PreviewBorder{1em}
\listoffigures
\begin{document}
\begin{figure}
\includegraphics[width=\hsize]{example-image}
\caption{This is a very long caption that does not fit into one line}
\end{figure}
\end{document}
编辑(1):
我在下面添加了一个图。为了便于查看图片,我添加了graphicx
包并使用了包。preview
这就是你要找的吗?
编辑(2):
现在我明白了,你喜欢格式图列表。在文档类中,book
这是默认功能(但没有Figure
图号前的名称)。并且,如评论中所述,提供 MWE,以显示您的问题。
答案2
您可以通过以下方式实现此目的titletoc
:
\documentclass[a4paper,10pt]{article}
\usepackage{titletoc,geometry}
\geometry{textwidth=10cm,showframe}
\contentsmargin{0.5cm}
\titlecontents{figure}
[1.7cm]
{}
{\makebox[0pt][r]{%
\makebox[1.7cm][l]{Figure~\thecontentslabel:}%
}%
}
{\hspace{-1.7cm}}
{\titlerule*[6pt]{.}\contentspage}
\begin{document}
\listoffigures
\begin{figure}
\centering\rule{4cm}{1.5cm}
\caption{This is a very long caption that does not fit into one line}
\end{figure}
\begin{figure}
\centering\rule{4cm}{1.5cm}
\caption{This is the next very long caption that does not fit into
one line}
\end{figure}
\end{document}