悬挂标题,首行也缩进

悬挂标题,首行也缩进

我正在尝试匹配 Word 文档和 Latex 文档之间的格式。在 Word 文档中,标题的标题标签位于左边距,标签分隔符实际上是制表符,制表位位于 2cm,然后标题文本的格式为距左边距 2cm 处的悬挂缩进。

这会导致所有标题文本块沿页面排列。 在此处输入图片描述

我不知道如何在 LaTeX 中复制这个。 在此处输入图片描述

悬挂字幕格式比较接近,但它设置了相对于字幕标签的悬挂缩进。有没有办法设置绝对值?

答案1

像这样吗?

\documentclass{article}
\usepackage[format=hang]{caption}

% Create a length
\newlength\caphang
% Set length as wanted
\setlength\caphang{2cm}

% caption.sty allows us to create our own format
% note: this version assumes the caption is only one paragraph!
\DeclareCaptionFormat{hangit}{%
  \hangindent=\caphang\hangafter=1%
  \makebox[\caphang][l]{#1#2}#3\par}

\captionsetup{format=hangit, singlelinecheck=no,
labelfont=sf, % if you want the label a different font, etc.
}

\def\dummytext{A figure or table caption mainly consists of three
  parts: the caption label, which says if this object is a ‘Figure’ or
  ‘Table’ and what number is associated with it, the caption text
  itself, which is normally a short description of contents, and the
  caption separator which separates the text from the label.}

\begin{document}

\dummytext

\begin{figure}[h]
  \caption{\dummytext}
\end{figure}

\setcounter{figure}{123}

\begin{figure}[h]
  \caption{\dummytext}
\end{figure}

\begin{table}[h]
  % \begin{tabular}{ll}
  %   one & two\\
  % \end{tabular}
    \caption{\dummytext}
\end{table}

\dummytext

\end{document}

答案2

这样就设置了 1 英寸的边距。

\documentclass{article}
\usepackage{caption}
\usepackage{mwe}

\DeclareCaptionFormat{myformat}{\makebox[1in][l]{#1#2}\parbox[t]{\dimexpr \textwidth-1in}{#3}}

\captionsetup{format=myformat}

\begin{document}

\captionof{figure}{\blindtext}

\end{document}

在此处输入图片描述

相关内容