# Subfigure: error “Missing number, treated as zero”

\begin{figure} \center
\begin{subfigure}[b]
\includegraphics[width=60mm]{a}
\label{fig:a}
\end{subfigure} %

\begin{subfigure}[b]
\includegraphics[width=60mm]{b}
\label{fig:b}
\end{subfigure}
\caption{my caption}
\end{figure}


I get an error

! Missing number, treated as zero.
\let
\includegraphics
[width=60mm]{a}


What's wrong?

-

This is how you should be using it.

\documentclass{article}
\usepackage{graphicx,subfigure}
\begin{document}
\begin{figure}
\centering     %%% not \center
\subfigure[Figure A]{\label{fig:a}\includegraphics[width=60mm]{example-image-a}}
\subfigure[Figure B]{\label{fig:b}\includegraphics[width=60mm]{example-image-b}}
\caption{my caption}
\end{figure}
\end{document}


Note: subfigure is outdated and new one is subfig which introduces subfloat command. You may consider using subfig instead of subfigure.

-
This does not actually answer the questions topic, does it? The actual solution to this mismatch would be to rename the question to "How should I use subfigures?" –  Jukka Dahlbom Jan 22 '13 at 10:09
@JukkaDahlbom A lot of users seem to find this question through searching for the error, and having a straightforward example of how the package should be used is likely to solve many problems. Thus, I’d leave the title as it is. –  doncherry May 16 '13 at 5:02
By the way, you can use \hfill between the subfigures to spread them evenly horizontally. –  mcb Jul 15 at 15:13

I believe you're using the subcaption package. The problem you have is that as a second argument to \begin{subfigure} you should tell it how wide you want your figure to be; e.g.

\begin{figure} \centering
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=60mm]{a}
\label{fig:a}
\end{subfigure} %

\begin{subfigure}[b]{\linewidth}
\includegraphics[width=60mm]{b}
\label{fig:b}
\end{subfigure}
\caption{my caption}
\end{figure}


If you have further problems you can refer to the package documentation.

Hope that helps!

-
Right, so if I understood correctly, the problem was with \begin{subfigure} missing a required argument, but LaTeX highlighted \includegraphics as the problematic area. Is it theoretically possible to write a preprocessor to spot such errors and report them properly? –  Evgeni Sergeev Aug 1 '13 at 2:04