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.

I'm trying to insert a nested figure using the environment subfigure following the example in http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats

I added the following extra packages: \usepackage{subfigure}, \usepackage{caption} and \usepackage{subcaption}.

this is my MWE:

\begin{figure}
    \begin{subfigure}%[b]{0.5\textwidth}
            \centering
            \includegraphics[width=\textwidth]{SR4000}
            \caption{SwissRanger by MESA}
            \label{fig:SRl}
    \end{subfigure}%
     %add desired spacing between images, e. g. ~, \quad, \qquad etc.
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}%[b]{0.5\textwidth}
            \centering
            \includegraphics[width=\textwidth]{D-Imager}
            \caption{D-Imager by Panasonic}
            \label{fig:D-Imager}
    \end{subfigure}
    \caption{TOF depth cameras}\label{fig:TOF}
\end{figure}

but I am getting the following error

! Use of \@subfloat doesn't match its definition. \reserved@c
->\@subfloat {
                          sub\@captype }[\@empty {\@empty }][{\@empty }] 
l.64                 \centering

line 64 here is:

\includegraphics[width=\textwidth]{SR4000}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Don't use subfigure and subcaption both. Also, subfigure is obsolete. Newer one is subfig.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
    \begin{subfigure}[b]{0.5\textwidth}            
            \includegraphics[width=\textwidth]{example-image-a}
            \caption{SwissRanger by MESA}
            \label{fig:SRl}
    \end{subfigure}%
     %add desired spacing between images, e. g. ~, \quad, \qquad etc.
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}[b]{0.5\textwidth}
            \centering
            \includegraphics[width=\textwidth]{example-image-b}
            \caption{D-Imager by Panasonic}
            \label{fig:D-Imager}
    \end{subfigure}
    \caption{TOF depth cameras}\label{fig:TOF}
\end{figure}
\end{document}

enter image description here

share|improve this answer
    
it worked with the packages you mentioned, but I had to add the {caption} package, but then when I compile i get an error that I cant find, it just tells me there are one error ' PDFTeXify Compilation Report (Pages: 45) Errors: 1 Warnings: 8 Bad Boxes: 8' –  SalamKh Nov 21 '12 at 13:08
    
And the error is ` ! Package subcaption Error: This package can't be used in cooperation (subcaption) with the subfig package.` –  Harish Kumar Nov 21 '12 at 13:15

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.