5

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.

  • Sorry, I missed that \ entering the problem. – trmillertr Oct 06 '14 at 04:57
  • Welcome to TeX.SX! What happens if you omit the .png extension? – Adam Liter Oct 06 '14 at 05:05
  • Same error omitting the extension. – trmillertr Oct 06 '14 at 05:06
  • What about using subfig instead of subfigure? subfigure is a deprecated package. See http://tex.stackexchange.com/questions/13625/subcaption-vs-subfig-best-package-for-referencing-a-subfigure – Adam Liter Oct 06 '14 at 05:11
  • In using subfig, I get undefined subfigure error. I changed subfigure to subfloat and get the original error. – trmillertr Oct 06 '14 at 05:14
  • Hmm, I'm not sure what's going on, but putting a line break between \begin{subfigure} and \includegraphics{...} in the source code eliminates the error for me. This also solves the problem with subfig, too. – Adam Liter Oct 06 '14 at 05:18
  • @AdamLiter - The subfigure environment takes a mandatory argument -- its intended width. Because that piece of information is missing in the OP's code, LaTeX ends up producing a near-incomprehensible error message... – Mico Oct 06 '14 at 05:23

1 Answers1

5

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.

Mico
  • 506,678