有人知道如何缩进 captionof 中的文本吗?我有一个很长的标题,我想将其分成两段,但缩进似乎不起作用。
\documentclass{article}
\usepackage{caption}
\usepackage[demo]{graphicx}
% make demo figure
\makeatletter
\AtBeginDocument{%
\def\Ginclude@graphics#1{%
\begingroup\fboxsep=-\fboxrule
\fbox{\rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}{0pt}%
\rule{0pt}{\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}\endgroup}}
\makeatother
\begin{document}
\noindent
\begin{minipage}[c]{\linewidth}
\centering
\includegraphics{}
\captionof{figure}{\textbf{Title} \newline
\indent Paragraph 1 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text \newline
\indent Paragraph 2 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text}
\label{fig:angio}
\end{minipage}
\end{document}
答案1
这是因为两个原因。首先, 会使minipage
的值无效\parindent
。其次,标题通常也以避免缩进的方式设置。您可以保存当前\parindent
并手动强制对齐:
\documentclass{article}
\usepackage{caption}
\usepackage{graphicx}
\newlength{\savedparindent}
% Save \parindent
\AtBeginDocument{\setlength{\savedparindent}{\parindent}}
\begin{document}
\noindent
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=.5\linewidth]{example-image}
\captionof{figure}[Title]{\textbf{Title} \newline
\hspace*{\savedparindent}Paragraph 1 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text \newline
\hspace*{\savedparindent}Paragraph 2 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text}
\end{minipage}
\end{document}
您可以使用以下功能caption
使用选项 自行存储[parindent=\parindent]
。但是,这要求您将每个段落指定为段落- 在它们之间留一行空行:
\captionof{figure}[Title]{\textbf{Title}
Paragraph 1 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text
Paragraph 2 is found here with a lot of text lot of text lot of text lot of text lot of text lot of text}
请注意,我使用了可选标题Title
来避免 LoF 中的内容复杂化。
答案2
我不会使用\newline
(不开始新段落) 但\par
(或空白行) 来获取真正的段落。然后我会设置\captionsetup{parindent=\parindent}
并删除\indent
。需要在可选参数中指定一个较短的版本,而没有段落分隔符,以避免错误:
\documentclass{article}
\usepackage{caption}
\captionsetup{parindent=\parindent}
\usepackage[demo]{graphicx}
\begin{document}
\begin{center}
\includegraphics{foo}
\captionof{figure}[\textbf{Title}: shorter version]{\textbf{Title}\par
Paragraph 1 is found here with a lot of text lot of text lot of text lot
of text lot of text lot of text \par
Paragraph 2 is found here with a lot of text lot of text lot of text lot of
text lot of text lot of text.}
\label{fig:angio}
\end{center}