# Use the “caption” package to customize your tables and figures in LaTeX

The “caption” package is one of the first packages I found when I began learning LaTeX. After discovering how to include graphics and attach a caption to any figure, I likely Googled “latex bold caption labels” when I noticed that the default LaTeX behavior did not match that of many of the chemistry journals I was seeking to emulate.

The default look of a LaTeX caption is:

(Note: for instructions on how to create beautiful native LaTeX figures using GNUplot, see my post here!)

Not bad – but there are a few ways we can make it better. To start, you can invoke the “caption” package in your preamble.

`\usepackage{caption}`

Now, that won’t do anything yet; we need to tell it what to do. First: bold labels. Modify the line above:

`\usepackage[font=normalsize,labelfont={bf}]{caption}`

As you see, a couple options we have are “font=” and “labelfont=”. In this case, I prefer normal size font (relative to that defined in your document class) but you can set it to any standard font size family (small, footnotesize, scriptsize, tiny, etc.) The other option lets us specify our font family – in this case, boldface (bf). Note that you can combine font families here; to make labels bold and italic, use labelfont={bf,it}, etc. Here’s how it looks in bold:

For more details on these formatting options, see Peter Yu’s helpful tutorial.

But wait – there’s more! The figure is still not quite right. Do you see it? The spacing between the x-axis and its label (pH) is smaller than the distance between the x-axis label and the caption! This can be visually jarring in an otherwise symmetrically spaced page, and depending on other settings in your preamble, can put the caption closer to the body text than the figure to which it is actually referring! (Why the typesetting engine would not safeguard against this in the first place is beyond me.)

Fortunately, the caption package gives us access to more sophisticated parameters (per the CTAN documentation) so we can tighten things up a bit. In your preamble (ideally immediately after your package declaration), put:

`\captionsetup[figure]{skip=6pt}`

You can change the “skip=” parameter to whatever distance suits your document layout, and you can also apply the same modifications to table captions (change “figure” to “table” and, if your preference is to put your table captions above your table, as is proper, [ahem…], use “aboveskip=2pt” instead of  “skip=6pt”). Thus, we get a more visually pleasing spacing:

And for tables:

Hope this helps, and happy typesetting!