[Tex/LaTex] subfigures don’t show (a) and (b)

captionssubfloats

I want to insert to graphs into a paper. I want to make these two graphs arranged like the top 2 graphs in the following pic

example

however, using the following source, I can't see (a) and (b)
what are potential problems? thanks!

the source codes are with a IEEEtran.cls

    \documentclass[conference]{IEEEtran}

    \ifCLASSINFOpdf
       \usepackage[pdftex]{graphicx}
       \DeclareGraphicsExtensions{.pdf,.jpeg,.png,.eps}
    \else
       \usepackage[dvips]{graphicx}
       \DeclareGraphicsExtensions{.eps}
    \fi


    \usepackage{lscape}
    %\usepackage{subfigure}
    \usepackage{subcaption}

    \begin{document}

    \title{0000}

    \author{\IEEEauthorblockN{00000}}

    \maketitle
    \end{abstract}

    \IEEEpeerreviewmaketitle

    \section{0000}

      \begin{figure}[!htb]
        \begin{subfigure}[b]{0.45\textwidth}
          \includegraphics[width=.5\linewidth]{pic/loop.png}
          \caption{First}
          \label{subfig-1:dummy}
        \end{subfigure}
        \hfill
        \begin{subfigure}[b]{0.45\textwidth}
          \includegraphics[width=.3\linewidth]{pic/twopath.png}
          \caption{Second}
          \label{subfig-2:dummy}
        \end{subfigure}
        \caption{Dummy figure}
        \label{fig:dummy}
      \end{figure}

    \begin{thebibliography}{1}

    \end{thebibliography}

    \end{document}

Best Answer

Your error was to use the subfigure package with a wrong syntax; but the subfigure has been obsolete for several years and its author released a successor package, subfig, in 1999.

You have two alternatives. The first is using the more modern subcaption package; here's an example based on your sample code.

\documentclass[conference]{IEEEtran}

\usepackage[demo]{graphicx} % demo is just for this example, remove it
\usepackage{subcaption}

\begin{document}

\title{0000}

\author{\IEEEauthorblockN{00000}}

\maketitle
\begin{abstract}
X
\end{abstract}

\IEEEpeerreviewmaketitle

\section{0000}

\begin{figure}[!htbp]
\centering
\begin{subfigure}[b]{0.5\columnwidth}
\includegraphics[width=\linewidth]{pic/loop.png}
\caption{First}
\label{subfig-1:dummy}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\columnwidth}
  \includegraphics[width=\linewidth]{pic/twopath.png}
  \caption{Second}
  \label{subfig-2:dummy}
\end{subfigure}
\caption{Dummy figure}
\label{fig:dummy}
\end{figure}

\end{document}

One important point to note: you can use \columnwidth to set the width of the subfigures and \linewidth in the argument to \includegraphics for using the whole reserved space. Or, for bigger pictures, use \textwidth but in the enclosing figure* environment, that will make a float as wide as the two columns.

enter image description here

The second possibility is with subfig.

\documentclass[conference]{IEEEtran}

\usepackage[demo]{graphicx} % demo is just for this example, remove it
\usepackage{subfig}

\begin{document}

\title{0000}

\author{\IEEEauthorblockN{00000}}

\maketitle
\begin{abstract}
X
\end{abstract}

\IEEEpeerreviewmaketitle

\section{0000}

\begin{figure}[!htbp]
\centering
\subfloat[title1]{\includegraphics[width=.5\linewidth]{pic/loop.png}\label{fig:loop}}\hfill
\subfloat[title2]{\includegraphics[width=.3\linewidth]{pic/twopath.png}\label{fig:twopath}}
\caption{packet structure}
\label{fig:routing}
\end{figure}
\end{document}

The difference is that you don't have to specify a width for the subfloats like with subcaption. The syntax is quite different, as you can see. The output is just the same as before.