General LaTeX tips and tricks → Custom captions

## 19. How can you get nicer figure captions?

Use the caption package by Harald Axel Sommerfeldt.

### Example usage

In the preamble:


\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}



In the document:


\begin{figure}[htb]
\begin{center}
\includegraphics[scale=0.3]{fig/programmable-compiler}
\caption{A programmable compiler.}\label{fig:programmable-compiler}
\end{center}
\end{figure}



### Result, after

Not one of the most earth-shattering packages, perhaps, but I certainly like my captions a whole lot better this way.

Note that for a while, people often used the more experimental caption2 package instead of caption. The two versions were merged in December 2003, however, and from then on caption has become the single recommended package again.

### Things to watch out for

The custom package is frequently updated, and the newer versions sometimes break compatibility with older versions. If you try to compile my thesis sources with a different TeX distribution and you run into trouble, make sure that the caption version is not too old or too new. (Changing the preamble invocation to match a different version is fairly trivial -- just consult the excellent caption documentation.)

Leo Breebaart (leo@lspace.org)
Last updated: 27 June 2016