I want to put two pictures side by side in a two-column conference paper. The LaTeX code is as follows:
\documentclass[conference]{IEEEtran}
% Add the compsoc option for Computer Society conferences.
% *** GRAPHICS RELATED PACKAGES ***
%
\ifCLASSINFOpdf
\usepackage[pdftex]{graphicx}
% declare the path(s) where your graphic files are
% \graphicspath{{../pdf/}{../jpeg/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.eps}
\else
% or other class option (dvipsone, dvipdf, if not using dvips). graphicx
% will default to the driver specified in the system graphics.cfg if no
% driver is specified.
\usepackage[dvips]{graphicx}
% declare the path(s) where your graphic files are
% \graphicspath{{../eps/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
\DeclareGraphicsExtensions{.eps}
\fi
% correct bad hyphenation here
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage{lscape}
\usepackage{subfigure}
\begin{document}
%
% paper title
% can use linebreaks \\ within to get better formatting as desired
\title{0000}
\author{\IEEEauthorblockN{00000}}
% make the title area
\maketitle
\begin{abstract}
\end{abstract}
\IEEEpeerreviewmaketitle
\section{0000}
\begin{figure}
\centering
\begin{subfig}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{pic/interest.png}
\label{packet:interest}
\end{subfig}
\begin{subfig}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{pic/data.png}
\label{packet:data}
\end{subfig}
\caption{CPI packet structure}
\label{packet}
\end{figure}
\begin{thebibliography}{1}
\end{thebibliography}
\end{document}
I used a .cls
file IEEEtran.cls
:
www.ctan.org/tex-archive/macros/latex/contrib/IEEEtran/IEEEtran.cls
I got the following errors:
There's no line here to end.
Missing number, treated as zero
and the result is like this:
there are two unexpected .5
besides the subfigures and these 2 subfigures are aligned on the bottom, but I hope to align them
on the top.
How to modify the code?
Best Answer
You're mixing incompatible syntaxes. With the
subfigure
package you have a\subfig
command and not asubfig
environment.However, calling
\begin{subfig}
executes\subfig
which gets confused because it doesn't expect a length as argument.The environment form with a stated length is available with the
subcaption
package, but the environment is calledsubfigure
.Here is a compiling code. Note that I loaded the package
graphicx
with the optiondemo
just to show black blotches instead of the (unavailable) pictures. In the options for the pictures I added aheight=
statement in order to have them of different height; you don't need this statement, of course.Recall also that the paper is typeset in two column format, so you have two choices:
Use the
figure
environment and express the width as a fraction of\columnwidth
Use the
figure*
environment and express the width as a fraction of\textwidth
.I used the first form; the
lipsum
package is just to fill the pages with nonsense text.