37
\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.
<to be read again>
\let
           \includegraphics
                            [width=60mm]{a}

What's wrong?

43

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}

enter image description here

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

  • 1
    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
  • 3
    @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. – Lenar Hoyt Jul 15 '14 at 15:13
14

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!

  • 1
    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
  • It should say: "Environment subfigure is missing required argument". – user877329 Jul 25 '15 at 8:40
  • I get confused between subcaption and subfigure regularly as they have different numbers of arguments for the open environment. Thanks :) – Aaron Dec 13 '18 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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