The caption package

Changes the look of figure and table captions with \captionsetup and adds \caption* and \captionof.

Loading the package

\usepackage{caption}

The standard classes fix the caption layout: text in normal size, the label "Figure 1:" in normal weight, a short caption centred. caption turns each of these into an option: font size, bold label, separator, alignment, width and the distance to the figure.

Options go into \usepackage[...]{caption} or into \captionsetup{...}. \captionsetup[table]{...} applies to one float type, and \captionsetup inside a float applies to that float only.

\captionof{figure}{...} writes a numbered caption outside a float, for example in a minipage or a center environment.

Main commands

\captionsetup{font=small, labelfont=bf}Small caption text with a bold label, for all captions that follow.
labelsep=periodPeriod instead of the colon after the number: "Figure 1."
justification=raggedright, singlelinecheck=falseLeft-aligned captions, including those that fit on one line.
format=hangIndents the second and later lines to the start of the caption text.
\captionsetup[table]{skip=6pt}Options for one float type, here the distance between caption and table.
\caption*{Source: own measurement.}Caption without label and number, and without an entry in the list of figures.
\captionof{figure}{...}Numbered caption outside a figure environment.

Complete example

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{font=small, labelfont=bf, labelsep=period}
\begin{document}
\begin{figure}[ht]
  \centering
  \includegraphics[width=0.4\textwidth]{image.png}
  \caption{A caption in small type with a bold label.}
  \caption*{Source: own measurement.}
\end{figure}

\begin{center}
  \includegraphics[width=0.3\textwidth]{image-a.png}
  \captionof{figure}{A numbered caption without a float.}
\end{center}
\end{document}
Result
The compiled example

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages