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 have a figure with several subfigures. The figure has a \caption, which is messy in the List of Figures. I'd prefer to put \captions on each of the \subfigures. The code I'm using at the moment:

\begin{figure}[htpb] \centering \subfigure[]{ \includegraphics[width=.45\columnwidth]{../Images/GloveOfDoom/RFIDTag_Testing_Side_s} } \caption{My caption!} \end{figure}

This works. However, when I put a \caption in any of the \subfigures, using this example as a reference, I'm getting errors:

\begin{figure}[htpb]
  \centering
  \subfigure[]{
      \caption{Subfloat caption dies with error.}
  \includegraphics[width=.45\columnwidth]{../Images/GloveOfDoom/RFIDTag_Testing_Side_s}
  }
  \caption{My caption!}
\end{figure} 

The errors I'm getting:

<../Images/GloveOfDoom/RFIDTag_Testing_Side_s.jpg, id=4, 520.94624pt x 347.2975
pt> <use ../Images/GloveOfDoom/RFIDTag_Testing_Side_s.jpg>
Overfull \hbox (7.1944pt too wide) in paragraph at lines 51--51
[]\OT1/cmr/m/n/9 () 
! Extra }, or forgotten \endgroup.
\@subfloat ...use {c@\@captype }\m@ne \fi \egroup 

l.51   }

! Extra }, or forgotten \endgroup.
\@endfloatbox ...pagefalse \outer@nobreak \egroup 
                                                  \color@endbox 
l.53 \end{figure}

! Too many }'s.
\color@endbox ->\color@endgroup \egroup 

l.53 \end{figure}


! LaTeX Error: \begin{document} ended by \end{figure}.

When I comment out the line containing the added \caption, everything compiles and looks fine. How can I fix this? I have no idea where to look or why this is occurring.

A minimal example demonstrating this error:

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
\documentclass[11pt]{report} % use larger type; default would be 10pt

%\usepackage{refcheck}
\usepackage[pdftex]{graphicx}
\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)
\usepackage{array} % for better arrays (eg matrices) in maths
\usepackage{color}     % Colorize code listings
\usepackage{fixltx2e}
\usepackage{geometry} % to change the page dimensions
\usepackage{hyperref}
\usepackage{listings}  % Code listings
\usepackage{mathtools} % Math Equations
\usepackage{mdwlist}
\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
\usepackage{rotating}
\usepackage{setspace}
\usepackage{subfigure}
\geometry{a4paper} % or letterpaper (US) or a5paper or....
\linespread{1.5}

\begin{document}

\begin{figure}[htpb]
  \centering
  \subfigure[]{
      \caption{Subfloat caption dies with error.}
  \includegraphics[width=.45\columnwidth]{../Images/GloveOfDoom/RFIDTag_Testing_Side_s}
  }
  \caption{My caption!}
\end{figure}
}
\end{document}
share|improve this question
    
! Extra }, or forgotten \endgroup.\@endfloatbox usually means you have a float package designed for latex2.09 (ie before 1993) that doesn't work properly with latex2e. But you haven't posted a complete document showing your preamble so hard to guess –  David Carlisle Dec 21 '12 at 8:53
    
@DavidCarlisle Thanks. I've added the preamble. I guess I should make sure I'm using each of the packages, remove the ones I'm not, and then if I'm still getting this error change float packages. –  simont Dec 21 '12 at 8:57
    
Do you have math in the caption, a smallmatrix for example? They don't work well with the list of figures, you should give 2 caoptions (thats even better, if your caption is bloated): \caption[short for list of figures]{long caption containing your math 'n' stuff} –  Ronny Dec 21 '12 at 8:59
2  
@simont Maybe you should take a look at how to make a minimal working example (MWE). Your actual question is a whole load of code where the people that want to help you have to find their way through. Please reduce it to the code that is needed to reproduce your behaviour. –  Benedikt Bauer Dec 21 '12 at 8:59
    
@Ronny No, no math in the caption. I didn't know I could do that with the \caption[short]{long} - I think that solves what I'm trying to do without the use of any subfigure \captions. –  simont Dec 21 '12 at 9:20

2 Answers 2

up vote 6 down vote accepted

You should simply use one figure environment:

\begin{figure}
\centering
\begin{minipage}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{A}
\caption{First caption}\label{first}
\end{minipage}\hfill
\begin{minipage}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{B}
\caption{Second caption}\label{second}
\end{minipage}
\end{figure}

The horizontal alignment can be varied. There can be some problems for the vertical alignment in case the two captions end with a different number of lines.

share|improve this answer

So the error you are getting is what i got, when i used a smallmatrix environment in the caption. The thing to structure your List of Figures is, to use

\caption[short text for the list]
  {complete description, that's 3 lines long below the image}

That also resolves the problem with inline math, i.e. you only use inline math in the second argument.

Looking at your packages, you might consider to switch to subcaption, because subfigure is obsolete, see for example here What is the difference between \subfigure and \subfloat?.

share|improve this answer
    
You could also use subfig as a replacement for subfigure. –  mafp Dec 21 '12 at 10:01
    
Personally I would not use any of the three packages (subfigure, subfig, subcaption) for this purpose. The purpose of any of these packages is to provide sub-captions (with sub-figure numbering) which is not desired by the questioner at all. So why not simply use minipages with \caption? –  Axel Sommerfeldt Dec 21 '12 at 11:15
    
@AxelSommerfeldt ??? The second line of the question reads: "I'd prefer to put \captions on each of the \subfigures", which sounds a lot like sub-captions. –  mafp Dec 21 '12 at 12:44
    
Since \subfigure is already putting a sub-caption below its sub-figure there is no need to use \caption if a sub-caption is what the questioner would like to have. Therefore I assume he wants to have an ordinary caption instead of a sub-caption. (But you are right, the questioner is only using the subfigure package in a very strange way without clear statement what result he would like to achieve.) –  Axel Sommerfeldt Dec 21 '12 at 14:11

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.