[Tex/LaTex] Subfigure have problems putting figures in the same line

floatssubfloats

I am using the IEEEtran template, two columns. When I want to put 4 figures in the same line (spanning two columns) using the \subfigure package, with the width of each figure setting to 0.24\textwidth, these four figures cannot be placed in the same line. (see below latex code and the resulting figure.)

\begin{figure*}[!t]
  \centering
  \begin{minipage}[htp]{1\textwidth}
  \subfigure[\footnotesize x1.]{
    \includegraphics[width=0.24\textwidth]{x1.eps}
    \label{fig:x1}
  }
  \hfill
  \subfigure[\footnotesize x2.]{
    \includegraphics[width=0.24\textwidth]{x2.eps}
    \label{fig:x2}
  }
  \hfill
  \subfigure[\footnotesize x3.]{
    \includegraphics[width=0.24\textwidth]{x3.eps}
    \label{fig:x3}
  }
  \hfill
  \subfigure[\footnotesize x4.]{
    \includegraphics[width=0.24\textwidth]{x4.eps}
    \label{fig:x4}
  }
  \vspace{-0.2cm}
   \caption{\footnotesize xxxx.}\label{xxxx}
\end{minipage}
\end{figure*}

enter image description here

However, when I do not use the \subfigure package, 4 figures can be correctly reside in one line. (see below)

   \begin{figure*}[!t]
  \centering
  \begin{minipage}[htp]{0.24\textwidth}
    \centering
    \includegraphics[width=1\textwidth]{x1.eps}
    \vspace{-0.6cm}%
    \caption{\footnotesize x1.}
    \label{fig:x1}
  %\vspace{-0.2cm}%
  \end{minipage}
    \centering
  \begin{minipage}[htp]{0.24\textwidth}
    \centering
    \includegraphics[width=1\textwidth]{x2.eps}
    \vspace{-0.6cm}%
    \caption{\footnotesize x2.}\label{fig:x2}
  %\vspace{-0.2cm}%
  \end{minipage}
   \begin{minipage}[htp]{0.24\textwidth}
    \centering
    \includegraphics[width=1\textwidth]{x3.eps}
    \vspace{-0.6cm}%
    \caption{\footnotesize x3.}
    \label{fig:x3}
  %\vspace{-0.2cm}%
  \end{minipage}
    \centering
  \begin{minipage}[htp]{0.24\textwidth}
    \centering
    \includegraphics[width=1\textwidth]{x4.eps}
    \vspace{-0.6cm}%
    \caption{\footnotesize x4.}\label{fig:x4}
  %\vspace{-0.2cm}%
  \end{minipage}
  \vspace{-0.3cm}%
\end{figure*}

enter image description here

Why the same width leads to different formats?

Edit: I have upload the tex and eps files to here: http://pan.baidu.com/share/link?shareid=1594110695&uk=3776487005, which compose a MWE. Please open that link and click the button as shown in the figure below to download. (The opened page will be in Chinese.)

enter image description here

Best Answer

Inside subfigure, you're in horizontal mode, so you need to be careful of escaping your line ends. Where you have

\subfigure[\footnotesize x1.]{
  \includegraphics[width=0.24\textwidth]{x1.eps}
  \label{fig:x1}
}

you insert an additional space character every time a line doesn't end with %, and this is inserting just enough space to cause the boxes to overfill the line; see below.

\documentclass[a4paper]{article}
\usepackage[draft]{graphicx}
\usepackage{subfigure}
\begin{document}
\begin{figure*}
  \centering
  \subfigure[x1.]{%
    \includegraphics[width=0.24\textwidth]{x1.eps}%
    \label{fig:x1}%
  }%
  \hfill
  \subfigure[x2.]{%
    \includegraphics[width=0.24\textwidth]{x2.eps}%
    \label{fig:x2}%
  }%
  \hfill
  \subfigure[x3.]{%
    \includegraphics[width=0.24\textwidth]{x3.eps}%
    \label{fig:x3}%
  }%
  \hfill
  \subfigure[x4.]{%
    \includegraphics[width=0.24\textwidth]{x4.eps}%
    \label{fig:x4}%
  }%
  \caption{xxxx.}
  \label{xxxx}
\end{figure*}
\end{document}

As a side-note, you shouldn't be manually changing the font size inside each caption. Use the caption package (etc.) to do this automatically across your whole document.