TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've used the subcaption package in the past without any problem. But now, i can't use it, which makes it impossible to compile some important documents.

If i try to compile

\begin{tabular}{l l}
\subfloat[\label{fig:g1} Figura 1]
   {\resizebox{0.45\textwidth}{!}{\includegraphics{img_a}}} &
\subfloat[\label{fig:g2} Figura 2]
   {\resizebox{0.45\textwidth}{!}{\includegraphics{img_a}}} \\
\caption{Figure caption.}

i get the error:

! Undefined control sequence.
l.14 \subfloat
[\label{fig:g1} Figura 1]

From the file log:

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian) (format=latex 2012.9.18)
Package: caption 2012/02/19 v3.2f Customizing captions (AR)
Package: caption3 2012/01/12 v1.4b caption3 kernel (AR)
Package: subcaption 2012/01/12 v1.1d Sub-captions (AR)

Any idea on what the problem might be?

share|improve this question
\subfloat appears in the subcaption package just in an error message testing if it is defined and saying subcaption may mot be used with subfig. If you comment out the subcaption line and replace it with \usepackage{subfig} it runs without error, don't know what layout you intended though.... – David Carlisle Sep 18 '12 at 0:18
Thanks. That solved the problem (for now, at least, and that's what i needed)... See the comment to cmhughes for more details. – joão gândara Sep 18 '12 at 0:59
up vote 4 down vote accepted

I think there's a bit of confusion here. The subcaption defines the subfigure environment, but the \subfloat command comes from the subfig package.

Personally, I'd recommend sticking with the subcaption package, and using a set up like the following for your MWE



   \caption{First subfigure}
   \caption{Second subfigure}
\caption{Figure caption.}

Note that the subfigure environment takes a mandatory <width> argument, which I have specified as .45\textwidth (what you used in your MNWE). The subfigure environment can also take the same optional arguments that the minipage argument can take.

This now means that the resizebox command for your images should be used with \textwidth which will match the width of the subfigure environment.

Using this approach also means that you can remove your tabular approach.

share|improve this answer
You could simplify your MWE in two ways: First, you don't need the \centering statement since the two subfigures are spread apart as much as is possible. Second, instead of \resizebox{\textwidth}{!}{\includegraphics{img_a}}, it may be more straightforward to write \includegraphics[width=\textwidth]{img_a}. – Mico Sep 18 '12 at 0:57
Yes. There was some confusion here. The problem is that i have a very large document (from where i got the MNWE) which compiled fine just a few months ago. The MNWE still compiles fine on a machine with an older TeX Live (2009). And that's where the problem came from...But thanks to you and David Carlisle for the quick and helpful solutions. I'll mark your answer as accepted, because i think it is better for new documents. But i'll go with David Carlisle suggestion, cause it is easier and quicker for a large existing document. – joão gândara Sep 18 '12 at 1:05
@Mico thanks a lot; you're absolutely right- have made edits :) – cmhughes Sep 18 '12 at 1:08
@joãogândara ok, no problem :) – cmhughes Sep 18 '12 at 1:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.