6

I'm trying to match the formatting between a word document and latex document. In the word doc, captions have the caption label at the left margin, the label separator is effectively a tab character with a tab stop at 2cm, and then the caption text is formatted with a hanging indent at 2cm from the left margin.

This results in all of the blocks of caption text lining up down the page. enter image description here

I can't work out how to replicate this in LaTeX. enter image description here

The hang caption format gets close, but it sets the hanging indent relative to the caption label. Is there anyway to set an absolute value?

1
  • 1
    Easily done with the caption package. But we don't know what you're using, so I hesitate to answer. Please provide a minimal example (or see here).
    – jon
    Nov 20, 2015 at 4:03

2 Answers 2

4

Something like this?

\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}
0
4

This sets up a 1in margin.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.