[Tex/LaTex] Problems with Subfigures

ieeetransubfloats

As a newbie to LaTeX, I am currently preparing my very first paper. Since the conference to which I am going to submit my paper to requires the authors to use the IEEE conference paper template.

I encounter problems with the subfigures. The following is my code.

\documentclass[conference]{IEEEtran}
\usepackage{natbib} % for the bibliography
\usepackage[pdftex]{graphicx}
\usepackage[cmex10]{amsmath} % http://www.ctan.org/tex-archive/macros/latex/required/amslatex/math/
\usepackage{algorithm} % http://ctan.org/pkg/algorithms
\usepackage{algpseudocode} % http://ctan.org/pkg/algorithmicx
\usepackage{array} % http://www.ctan.org/tex-archive/macros/latex/required/tools/
\usepackage{mdwmath}
\usepackage{mdwtab} % http://www.ctan.org/tex-archive/macros/latex/contrib/mdwtools/
\usepackage{eqparbox} % http://www.ctan.org/tex-archive/macros/latex/contrib/eqparbox/
\usepackage[tight,footnotesize]{subfigure} % http://www.ctan.org/tex-archive/obsolete/macros/latex/contrib/subfigure/
\usepackage{fixltx2e} % http://www.ctan.org/tex-archive/macros/latex/base/
\usepackage{stfloats} % http://www.ctan.org/tex-archive/macros/latex/contrib/sttools/
\usepackage{url} % http://www.ctan.org/tex-archive/macros/latex/contrib/misc/

\begin{document}

\title{Title}

\author{
\IEEEauthorblockN{
    Name1\IEEEauthorrefmark{1},
    Name2\IEEEauthorrefmark{2},
    Name3\IEEEauthorrefmark{3} and
    Name4\IEEEauthorrefmark{4}}
\IEEEauthorblockA{\IEEEauthorrefmark{1}institute1\\ Email1}
\IEEEauthorblockA{\IEEEauthorrefmark{2}institute2\\ Email2}}

% make the title area
\maketitle

\begin{abstract}
%\boldmath
The abstract goes here.
\end{abstract}

\section{Conclusion}
% An example of a double column floating figure using two subfigures.
% (The subfig.sty package must be loaded for this to work.)
% The subfigure \label commands are set within each subfloat command, the
% \label for the overall figure must come after \caption.
% \hfil must be used as a separator to get equal spacing.
% The subfigure.sty package works much the same way, except \subfigure is
% used instead of \subfloat.
%
\begin{figure*}[!t]
\centerline{\subfloat[Case I]\includegraphics[width=2.5in]{subfigcase1}%
\label{fig_first_case}}
\hfil
\subfloat[Case II]{\includegraphics[width=2.5in]{subfigcase2}%
\label{fig_second_case}}}
\caption{Simulation results}
\label{fig_sim}
\end{figure*}

\end{document}

Error Messages:

! Undefined control sequence.<argument> \subfloat[Case I]\includegraphics [width=2.5in]{subfigcase1}\lab... \label{fig_first_case}}
! Undefined control sequence. \subfloat
! Extra }, or forgotten \endgroup.\@endfloatbox ...pagefalse \outer@nobreak \egroup\color@endbox \end{figure}
! Extra }, or forgotten \endgroup.\@endfloatbox ...pagefalse \outer@nobreak \egroup\color@endbox \end{figure}
Label `fig_sim' multiply defined.
There were multiply-defined labels.

Where did I do wrong?

Best Answer

You have done some minor mistakes in the syntax for the sub-figures. Replacing »subfigure« by »subfig« works in the below approach.

\documentclass[conference]{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}  % drop `demo` option in actual document!
\usepackage[caption=false]{subfig}

\title{Title}
\author{
  \IEEEauthorblockN{
    Name1\IEEEauthorrefmark{1},
    Name2\IEEEauthorrefmark{2},
    Name3\IEEEauthorrefmark{3} and
    Name4\IEEEauthorrefmark{4}
  }
  \IEEEauthorblockA{\IEEEauthorrefmark{1}institute1\\ Email1}
  \IEEEauthorblockA{\IEEEauthorrefmark{2}institute2\\ Email2}
}

\begin{document}
  \maketitle

  \begin{abstract}
    The abstract goes here.
  \end{abstract}

  \section{Conclusion}
    \begin{figure*}[!tb]
      \centering
      \subfloat[Case I\label{fig:first-case}]{%
        \includegraphics[width=2.5in]{subfigcase1}%
      }
      \hfill
      \subfloat[Case II\label{fig:second-case}]{%
        \includegraphics[width=2.5in]{subfigcase2}%
      }
      \caption{Simulation results}
      \label{fig:sim}
    \end{figure*}
\end{document}

Note that the figure will be shifted to the next page.

Related Question