[Tex/LaTex] Problem with Subfigure

subfloats

Could someone please tell me why this

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfigure}
\begin{document}
\begin{figure}
\begin{subfigure}
\includegraphics{ngc3242fullslitmag.png}
\end{subfigure}
\end{figure}
\end{document}

gives this error message?

! Argument of \Gin@ii has an extra }.
<inserted text> 
                \par 
l.7 \includegraphics
                    {ngc3242fullslitmag.png}

Thank you.

Best Answer

The subfigure environment is defined by the subcaption package. Importantly, it takes one mandatory argument -- the intended width. The following code works fine:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption} % not 'subfigure'

\begin{document}
\begin{figure}
  \centering
  \begin{subfigure}{3in} % choose intended width here
    \includegraphics[width=\linewidth]{ngc3242fullslitmag.png}
  \end{subfigure}
\end{figure}
\end{document}

Incidentally, the subfigure package is seriously deprecated. Don't use it. You should work with either the subcaption (as above) or subfig package instead.