# Styling captions in LaTeX (subfig and caption packages)

This page is outdated. Please see Formatting captions and subcaptions in LaTeX instead.

This page shows how to customize the captions for figures, tables, subfigures and subtables in LaTeX. Many examples here involve the now outdated and deprecated \subfig package so it is recommended that you head to Formatting captions and subcaptions in LaTeX to see more up to date examples that use the \subcaption package. I am keeping this page mostly for reference.

Formatting captions and subcaptions in LaTeX (up to date version of this page)

## Getting started

Here is what the captions look like for a figure with subfigures in a basic article class document:

The letters and numbers (“a”, “b” and “1”) that enumerate the captions and subcaptions are caption labels. In the above, the subfigure caption label is enclosed by parentheses and the figure caption label is separated from the caption text by a colon.

Just for reference, the code that produces the above figure is:

\begin{figure}[tbp]
\centering
\subfloat[Caption 1]{\includegraphics[width=1in]{placeholder}}\quad
\subfloat[Caption 2]{\includegraphics[width=1in]{placeholder}}\\
\caption{Main figure caption.}
\end{figure}

For examples involving captionsetup, be sure to include the caption package: \usepackage{caption}

For examples involving subfloats (subfigures and subtables), be sure to include the subfig package: \usepackage{subfig}

The captionsetup command does not work with the subfigure package, so use the subfig package instead.

## Set caption label numbering style

You can change the numbering or lettering style of the caption label by using variants of the following commands in your document:

% change the style of the caption numbering.
\renewcommand{\thetable}{\alph{table}}
\renewcommand{\thefigure}{\Alph{table}}
\renewcommand{\thesubtable}{\Roman{subtable}}
\renewcommand{\thesubfigure}{\arabic{subfigure}}

Each command specifies the label you want to modify (e.g. \thetable) and what you want to appear as the label (e.g. \alph{table}, which means to show the table counter as a lower case letter like a, b, c, etc.). Each type of float has its own label (\thetable) and counter variable (table). Anything that appears after you issue these commands will have the new label numbering / lettering style.

There are five ways you can show the counters (replace counter with the actual counter you want to show, such as table):

Counter styleCodeExample
Arabic numerals\arabic{counter}1, 2
Lower case letters\alph{counter}a, b
Upper case letters\Alph{counter}A, B
Lower case Roman numerals\roman{counter}i, ii
Upper case Roman numerals\Roman{counter}I, II

Here is an example of changing the figure and subfigure caption label numbering / lettering:

\renewcommand{\thefigure}{\Roman{figure}}
\renewcommand{\thesubfigure}{\arabic{subfigure}}
\begin{figure}[tbp]
\centering
\subfloat[Arabic numerals]{\includegraphics[width=1in]{placeholder}}\quad
\subfloat[Arabic numerals]{\includegraphics[width=1in]{placeholder}}\\
\caption{Capital Roman numerals.}
\end{figure}

The above produces Arabic numerals for the subfigure captions and upper case Roman numerals for the figure caption:

If your document has chapters, then the caption labels would be something like 1.1, 1.2, 2.1, etc. You can customize the numbering or lettering style in these cases. For example:

\renewcommand{\thefigure}{\thechapter.\Alph{figure}} % set caption label style like 1.A

\renewcommand{\thesubfigure}{\arabic{subfigure}}
\begin{figure}[tbp]
\centering
\subfloat[Arabic numerals]{\includegraphics[width=1in]{placeholder}}\quad
\subfloat[Arabic numerals]{\includegraphics[width=1in]{placeholder}}\\
\caption{Chapter number dot figure letter}
\end{figure}

This code would produce:

The output differs from a standard caption in that the figure label is now a capital letter rather than a number. The subcaptions are also using arabic numerals. You can also change the period to another character if you want.

The \thechapter command produces the chapter label, just like \thefigure produces the figure label. By including \thechapter in the \thefigure command, you can reference the chapter in the figure label.

If you want to change the style of the chapter labels, you can in fact override the \thechapter command just as you override the \thefigure command. Alternatively, if you want to change the style of the chapter labels only for figure labels, you can do this:

\renewcommand{\thefigure}{\Alph{chapter}.\Alph{figure}}

The above examples were all using figures or subfigures, but the same ideas apply for tables and subtables. Just use \thetable and \thesubtable instead of \thefigure and \thesubfigure and use the table and subtable counters instead of figure and subfigure.

## Label format and label separator

If you look at the captions, you can see that the subfigure labels are surrounded by parentheses and a colon separates “Figure 1” from the rest of the caption.

Both of these aspects (the label format and the label separator) can be customized by options in the caption package. The label format controls how the label shows up: whether it is visible at all, appears plainly or enclosed by parentheses. The label separator is simply the character that appears after the label. You can set the label format and label separator (amongst other options) for each of the figure, table, subfigure and subtable floats individually using the \captionsetup command. When you use the command in your document, all subsequent captions will use the options you specify.

First, include the caption package:

\usepackage{caption}

Next, use the \captionsetup command to set the labelformat and labelsep options:

\captionsetup[FLOAT_TYPE]{labelformat=simple, labelsep=colon}

FLOAT_TYPE can be table, figure, subtable and subfigure. The labelformat option can be set to:

Label FormatResult
labelformat = emptyNo label is shown - i.e. no number or letter
labelformat = simpleShows number or letter in caption
labelformat = parensShows number or letter in caption in parentheses - i.e. (1), (A)

The labelsep option can be set to:

Label Separator
labelsep = none
labelsep = colon
labelsep = period
labelsep = space
labelsep = quad
labelsep = newline

There are many other options that can be set with \captionsetup, so see the caption package documentation for details.

Here is an example where the labelformat and labelsep for the figure caption and subfigure caption are changed individually:

% set up labelformat and labelsep for figure
\captionsetup[figure]{labelformat=parens, labelsep=newline}
% set up labelformat and labelsep for subfigure
\captionsetup[subfigure]{labelformat=simple, labelsep=colon}

\begin{figure}[tbp]
\centering
\subfloat[Simple]{\includegraphics[width=1in]{placeholder}}\quad
\subfloat[Simple]{\includegraphics[width=1in]{placeholder}}\\
\caption{Parentheses, newline separator.}
\end{figure}

The above code produces:

The labelformat of the subfigure captions is set to simple, which produces only the caption letter without parentheses. The labelsep is colon for subfigure captions and a newline for the figure.

## Subfloat, subfigure and subtable captions with no number or letter

By setting the labelformat to “empty”, you can disable the display of the number or letter label in subfloats. Here is an example that produces subfigures with no caption numbering or lettering:

% no subfigure caption label.
\captionsetup[subfigure]{labelformat=empty}

\begin{figure}[tbp]
\centering
\subfloat[No caption label]{\includegraphics[width=1in]{placeholder}}\quad
\subfloat[No caption label]{\includegraphics[width=1in]{placeholder}}\\
\caption{Main figure caption}
\end{figure}

The above code produces:

The same command applies for subtables, tables and figures (just make the appropriate substitution in the captionsetup command). However, for tables and figures, you can also simply use the \caption* command to produce captions with no numbers.

## No caption number for figures and tables

You can disable the caption number for figures and tables by using the \caption* command:

\begin{figure}[tbp]
\centering
\includegraphics[width=1in]{placeholder}
\caption*{Unnumbered figure caption.}
\end{figure}

The code will produce this:

The \caption* command will produce a caption that has no label or number at all, not even in the List of Figures.

## Set caption position for subfigures, subtables and subfloats

For regular floats such as tables and figures, the caption position can be set to above or below the float by simply issuing the caption command above or below the float contents.

For subfloats using the subfig package, the caption position is controlled by the \captionsetup command of the \caption package. The subfig documentation was a bit confusing about this but \captionsetup can be used as follows. First, include the caption package:

\usepackage{caption}

Then, issue a \captionsetup command, either right after \usepackage{caption} or just before the figure or table for which you want to control the subcaption position:

\captionsetup[FLOAT_TYPE]{position=POSITION}

FLOAT_TYPE can be subfigure or subtable for controlling the caption position for the corresponding type of float. POSITION can be top or bottom.

The following code will put the subcaptions on top of the subfigures (remember to replace placeholder with the name of a graphic file that you want to include):

\captionsetup[subfigure]{position=top}
\begin{figure}[tbp]
\centering
\subfloat[Caption 1]{\includegraphics[width=1in]{placeholder}}\quad
\subfloat[Caption 2]{\includegraphics[width=1in]{placeholder}}
\caption{Main figure caption.}
\end{figure}

The result is this:

The default is to put the caption below the subfigure, but you can explicitly specify this by changing the \captionsetup command:

\captionsetup[subfigure]{position=bottom}

The result will look like this:

## Putting it all together with a table example

This example shows the above techniques with a table and subtable example:

% set numbering style
\renewcommand{\thetable}{\Roman{table}}
\renewcommand{\thesubtable}{\arabic{subtable}}

% set up labelformat and labelsep for table
\captionsetup[table]{labelformat=simple, labelsep=period}
% set up labelformat and labelsep for subtable
\captionsetup[subtable]{labelformat=simple, labelsep=colon}

\begin{table}[tbp]

\centering

\subfloat[Caption 1]{

\begin{tabular}{|l|l|}
\hline
100 & 200\\
\hline
\end{tabular}

}\quad
\subfloat[Caption 2]{

\begin{tabular}{|l|l|}
\hline
100 & 200\\
\hline
\end{tabular}

}

\caption{Table caption text.}
\end{table}

The output looks like this:

## Change the caption name

If you want to change the name of the figure or table caption from “Fig.” to “Figure” or “Table” to “Tab.” or anything else you want, you can use \renewcommand with \figurename or \tablename:

\renewcommand{\tablename}{Tbl}

\renewcommand{\figurename}{Image}

The above will change all table captions to be called “Tbl [Table Number]” or “Image [Figure Number]”.

One potential issue you may run into is that the various document classes use a command other than \figurename or \tablename in the table captions. For example, the thesis document class will use \figureshortname or \tableshortname in the captions instead. In these cases, renew the corresponding command. To find out what the command is, you can look into the .cls file of your document class. You can look for the specific string (e.g. “Fig.”) and find out what command was defined for it. Then you can override it. You could also just create a new document class based on the original .cls file.

## Discussion

, 2011/05/11 16:46
Hello, it is a very good web, but I have a little problem with the tables captions. I need place a caption on left of the page and I don't know what can do it!! Could you send me some information about this? Thank you very much!!

Emanuel
from Argentina
, 2011/05/11 21:16
Emanuel - look into the sidecap package. It lets you put captions beside a figure, table or float.
, 2011/05/24 10:03
Hi Peter,

very nice site. I really like that you have example tex code accompanied by resulting pictures. I have one comment about "Subfloat, subfigure and subtable captions with no number or letter", I hope it can be useful. I tried to remove the caption numbering using the following latex code:

\documentclass{beamer}
\usepackage{beamerthemesplit}
\usepackage{url}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage{multimedia}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{rotate}
\usepackage{verbatim}
\usepackage{amsfonts}
\usepackage{hyperref}
\usepackage{subfigure}
\usepackage{caption}

\begin{document}

\captionsetup[subfigure]{labelformat=empty}

\begin{figure}\centering
\subfigure[\tiny{5 h}]{\includegraphics[width=.35\textwidth]{201101211600sdsF2ds}}
\subfigure[\tiny{5 h }]{\includegraphics[width=.35\textwidth]{201101181730sdsC10ds}}
\subfigure[\tiny{30 h}]{\includegraphics[width=.35\textwidth]{201101191030sdsC2ds}}
\end{figure}

\end{document}

but in my case, latex refuses to remove the caption:

Package caption Warning: Unused \captionsetup[subfigure] on input line 19. See the caption package documentation for explanation.

If you can see what is wrong in this example, maybe you can write some more on the site about how to use the code/where to put it in the document?

Kind regards
Pia from Denmark.
, 2011/05/24 16:16
Pia - I think it is because you are using the subfigure package. All of my examples were based on using the subfig package:

\usepackage{subfig}

and using \subfloat for the actual subfigures.
, 2011/09/12 20:23
Dear Peter,

I used the \renewcommand{\thesubfigure}{\arabic{subfigure}} to caption the subfigures with numbers. Also, I used \captionsetup[subfigure]{labelformat = parens, labelsep=colon} to put the numbers inside parentheses but it does not do that i.e. No parentheses.
I have to use subfigure package is there anyway by which the \captionsetup works with subfigure package??

Thank you
Ahmad from Canada
, 2011/09/15 22:08
I don't think \captionsetup works with the subfigure package at all.
, 2011/10/04 00:33
I used \caption* command to produce a caption that has no label or number at all, not even in the List of Figures. But it produces Figure 1: * name of the caption
, 2011/11/21 01:11
So, this is a related question. I'm trying to learn the Beamer document class to make some nicer looking presentations. However, I'm trying to get subfloats and numbered captions (like you have). But I believe the code you have here is for just an article or non-presentations?

I've started my code with:
\documentclass{beamer}
\setbeamertemplate{caption}[numbered]
\usepackage{graphicx,fancyhdr,lastpage}
\usepackage{subfig}

but cannot seem to get numbering. Hopefully I haven't missed anything and hopefully you can help.
Thanks
, 2011/11/24 21:12
I've never used the Beamer class before, so I don't know how if any of this will work with it.
, 2011/12/02 23:34
This is a very informative web. May I ask a question?
To enter the title for a table, I use
\caption{Conclusion Drawn}
Instead of having

Table 1: Conclusion Drawn

I got

Tab. 1: Conclusion Drawn

How can I have "Table 1" instead of "Tab. 1"?

Many thanks.
Siu Chow
, 2011/12/02 23:59
This will allow you to change the name of the table caption:

\renewcommand{\tablename}{Table}

\renewcommand{\figurename}{Figure}

I updated the page to reflect that.
, 2013/08/02 00:13
salam,,
I need to start the subfigure with caption (i) to (n)..... six subfigures

thanx
, 2013/10/26 17:55
Thank you! very informative about sub figure captions.
I would love to hear your feedback. Enter your comment below [ Terms of Use ]:
KBVKM

About Peter Yu I am a research and development professional with expertise in the areas of image processing, remote sensing and computer vision. I received BASc and MASc degrees in Systems Design Engineering at the University of Waterloo. My working experience covers industries ranging from district energy to medical imaging to cinematic visual effects. I like to dabble in 3D artwork, I enjoy cycling recreationally and I am interested in sustainable technology. More about me...

Feel free to contact me with any questions about this site at [user]@[host] where [user]=web and [host]=peteryu.ca

Copyright © 1997 - 2019 Peter Yu