Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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?

share|improve this question

2 Answers 2

up vote 21 down vote accepted

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.

share|improve this answer
    
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
2  
@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!

share|improve this answer
    
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

Your Answer

 
discard

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.