Skip to main content
v2026.11,986 entries · CC-BY 4.0

LaTeX subfig: How to Use \subfloat for Subfigures and Subtables

How to load subfig, write subfloat sub-captions, cross-reference with ef and subref, and fix alignment and list-of-figures problems.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

The subfig package lets you place several small figures or tables inside one LaTeX figure or table environment, each with its own sub-caption and its own label. This guide is for authors of papers and theses who have a template or an older document that loads subfig and need to use it correctly. After reading it you can load the package, write \subfloat entries, cross-reference them, and fix the usual spacing, alignment and list-of-figures problems. People also search for this as “subfig latex”; both phrasings mean the same package.

What subfig is used for in research writing

According to its manual, subfig “provides support for the inclusion of small ‘sub’ figures and tables” and simplifies positioning, captioning and labelling of those sub-floats inside a single figure or table, including continuing one figure over several pages and putting sub-captions on the list of figures or tables. The manual is “The Subfig Package” by Steven Douglas Cochran, dated 2005/07/05, and documents version 1.3. It states that the package requires the caption package and replaces the older subfigure package.

Do you need subfig at all?

The manual’s own first section asks this. If you only want to centre an image, use \centering (see centering in LaTeX). If you want images side by side without separate sub-captions, put them in minipage or \parbox boxes of short width inside one figure; a caption written inside such a box takes the box width. Use subfig when each sub-float needs its own caption, its own reference, or an entry on the list of floats. For the basics of the figure environment itself, see LaTeX figure: insert an image, caption it and add subfigures.

How to install or access it

subfig is published on CTAN, the Comprehensive TeX Archive Network, at ctan.org/pkg/subfig. The CTAN page (read 2026-11-08) lists version 1.3, the LaTeX Project Public License 1.3, copyright 2003-2005 Steven Douglas Cochran, and the bidi-tex GitHub organisation, Vafa Khalighi and Cochran (inactive) as maintainers. The README and PDF documentation are in the package directory on CTAN mirrors, and bug reports go to github.com/bidi-tex/subfig/issues. The package is free to use under that licence.

CTAN also states that the package’s functionality is “now provided by the subcaption package”, described there as more recent still.

Step-by-step: build a figure with sub-figures

1. Load the package

Put this in the preamble. Options are keyword=value pairs inside the square brackets and are optional:

\usepackage[KV-list]{subfig}

You can change settings later with \captionsetup[subfloat]{KV-list}, inspect them with \showcaptionsetup{subfloat} and reset them with \clearcaptionsetup[subfloat].

2. Write each sub-float with subfloat

The pattern from the manual’s simple example is a main figure environment containing one \subfloat per image, then a main \caption and \label:

\begin{figure}%
  \centering
  \subfloat[First.]{...}\qquad
  \subfloat[Second figure.]{...}\\
  \subfloat[Third.]{\label{3figs-c}...}%
  \caption{Three sub-floats.}
  \label{3figs}
\end{figure}

Replace each ... with the code that imports the image, for example an \includegraphics call. Sub-floats align along their baselines, and whitespace inside float environments is significant, so end lines with % to avoid stray spaces.

3. Choose the caption form

The syntax is \subfloat[list entry][sub-caption]{body}. How many optional arguments you give changes what is printed:

Call Result according to the manual
\subfloat[Text]{body} One optional argument: it becomes both the sub-caption and the list entry.
\subfloat[Short][Long caption]{body} Two optional arguments: the first is the list-of-floats entry, the second is the caption text.
\subfloat[][Long caption]{body} Empty first argument: nothing is printed on the list of floats.
\subfloat{body} No caption text; only the sub-label (a), (b) and so on is shown.

4. Cross-reference the sub-floats

Put \label inside the \subfloat body, as in \label{3figs-c} above, then refer to it in text. The manual’s example sentence reads: “Figure~\ref{3figs} contains two top sub-floats and sub-float~\ref{3figs-c}.”

Command What it returns
\ref{label} The main float number plus the sub number, for example “1a”.
\subref{label} The label as shown on the list of floats, for example “(a)”.
\subref*{label} By default only the sub number, for example “a”. Its format is set with the subrefformat option or \DeclareSubrefFormat.

Output and how to read it

Each \subfloat prints its image with a sub-label such as (a), (b), (c) and its sub-caption beneath it. The shared \caption appears once for the whole figure. Cross-references made with \ref combine the figure number and the sub-label, so the third image in Figure 1 is cited as 1c. If you use two optional arguments, the list of figures shows the short text rather than the long caption.

Show sub-captions on the list of figures or tables

Sub-captions appear on those lists only when the depth counter is at least 2. The manual’s table example sets \setcounter{lotdepth}{2} before \listoftables, or equivalently \captionsetup{lotdepth=2}; the manual’s option table also lists lofdepth for the list of figures.

Continue a figure across pages

Put \ContinuedFloat at the beginning of the next float environment so its \caption continues the last float caption of the same type. To keep the continuation off the list of figures, write \caption[]{...} with an empty optional argument, and suppress sub-caption entries with \subfloat[][]{...}.

Troubleshooting

Symptom Fix from the manual’s FAQ
Bottoms of sub-floats do not line up The baseline of a minipage, tabular, array or \includegraphics box sits at its centre by default. Add [t] or [b] to the environment.
Sub-floats jump to a new line or are spaced oddly Stray whitespace and blank lines (\par) move sub-floats. Remove blank lines and end lines with %.
Too many sub-floats for one page Split them across floats with \ContinuedFloat.
Garbled caption or an error when the caption contains a ] Wrap the caption in braces, for example \subfloat[{SHIFT: ``register[3] $<<=$ 3;''}]{...}, or brace only the bracket: register{[3]}.
Sub-captions missing from the list pages Raise the depth counter to 2 or more (see above).
A caption option has no effect It is being overridden at another level. Diagnose with \showcaptionsetup{table} or \showcaptionsetup{subfloat}.
A \captionsetup change affects only one figure A \captionsetup placed inside a float applies only to that float.

Migrating from the older subfigure package

The manual says compatibility with the old subfigure package is only near: spacing differs, and the old topskip and bottomskip controls are replaced by farskip and nearskip. The package ships a subfig.cfg that defines \subfigure and \subtable as \subfloat, so old documents mostly compile, but check their layout.

Free alternatives

All options below are free LaTeX packages or built-in constructs.

Option What the sources say
subcaption On CTAN (read 2026-11-08): version 1.6, 2023-08-13, by Axel Sommerfeldt, distributed with the caption package; it writes captions for subfigures and the like using the same options as caption. CTAN’s subfig page names it as the package now providing subfig‘s functionality.
minipage or \parbox inside one figure Recommended by the subfig manual when you want side-by-side images without separate sub-captions.
subfigure Older package that subfig supersedes; not recommended for new documents.

When choosing, follow what your journal template or thesis class already loads: the manual includes compatibility notes for the caption, float, floatrow, verbatim/fancyvrb packages and the IEEEtran class, so a conflict is more likely to come from the template than from subfig itself. Related reading: LaTeX bibliography styles explained and LaTeX and Overleaf collaborative writing.

FAQ

What is subfig in LaTeX?

It is a CTAN package, version 1.3, by Steven Douglas Cochran, for placing captioned sub-figures and sub-tables inside one float. It requires the caption package.

What is the subfig LaTeX command for a sub-figure?

\subfloat{body} inside a figure or table environment. The same command is used for sub-tables.

How do I reference a single sub-figure?

Label it inside the \subfloat body and use \ref for the combined number (for example 1a) or \subref for the bare sub-label (for example (a)).

Is subfig still maintained?

CTAN lists the bidi-tex GitHub organisation and Vafa Khalighi as maintainers and gives the version as 1.3 with copyright 2003-2005; it also says the functionality is now provided by subcaption.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about LaTeX subfig: How to Use \subfloat for Subfigures and Subtables

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →