缩进图片标题的第一行

缩进图片标题的第一行

我想在图表标题的第一行创建一个小的缩进,类似于 LaTeX 缩进段落第一行的方式。

caption软件包似乎不支持这一点。

这可行吗?

答案1

使用caption包:

\documentclass{article}
\usepackage{caption}
\newlength\myindention
\DeclareCaptionFormat{myformat}%
{\hspace*{\myindention}#1#2#3}
\setlength\myindention{1cm}
\captionsetup{format=myformat}

\begin{document}
\begin{figure}
\caption{White sand beaches. The pink smoothness of the conch shell. A sea abundant
  with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play
  your favorite game of golf amidst the tropical greens on one of the many championship
  courses.}
\end{figure}
\end{document}​

在此处输入图片描述

table上述方法对s也适用。

正如所指出的贡萨洛,这也可以通过使用包中的可用选项来完成caption

\documentclass{article}
\usepackage{caption}
\captionsetup[figure]{format=hang,indention=-60pt,margin=20pt}

\begin{document}
\begin{figure}
\caption{White sand beaches. The pink smoothness of the conch shell. A sea abundant
  with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play
  your favorite game of golf amidst the tropical greens on one of the many championship
  courses.}
\end{figure}
\end{document}​

答案2

在标准文档类中,您可以重新定义打印标题的宏,称为\@makecaption

我已将其定义\captionindent为与默认的相同\parindent。将其存储在不同长度中的原因是因为字幕通常不设置\parindent

在此处输入图片描述

\documentclass{article}
\makeatletter
\newlength{\captionindent}\setlength{\captionindent}{\parindent}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1: #2}%
  \ifdim \wd\@tempboxa >\hsize
    \hspace*{\captionindent}#1: #2\par% Added \captionindent
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
\makeatother
\begin{document}
\begin{figure}
\caption{White sand beaches. The pink smoothness of the conch shell. A sea abundant
  with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play
  your favorite game of golf amidst the tropical greens on one of the many championship
  courses.}
\end{figure}
\end{document}​

这适用于所有字幕。如果您使用的是caption包裹

相关内容