[Tex/LaTex] IEEEtran and subfig – figures overflow onto second column

ieeetransubfloats

\documentclass[final,journal,letterpaper,twocolumn]{IEEEtran}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\usepackage{fixltx2e}

\begin{document}
\section{Introduction}

some moo text
\\
\begin{figure}
  \subfloat[]{\label{subfig:a} \includegraphics[height=6cm]{test.png}}% < shame we need to force the linebreak
  \subfloat[]{\label{subfig:b} \includegraphics[height=6cm]{test.png}}
\end{figure}

\newpage

more moo text

\end{document}

I start with my MWE because I think if this is compiled and run it is easier to see the problem. Basically, the figure overflows onto the second column. I can fix this by forcing a line break – but should I have to? Can I get this to behave appropriately by some other means?

P.S to run the MWE just create a small png file called test.png with a filled colour. I wasn't sure of other means to demonstrate the problem.

Best Answer

You have scaled the height which means that the width depends on the initial image size which we don't know, however latex positions graphics just the same way ot positions letters or boxes. If there is not enough flexibility in the white space to stretch a line Tex will not leave it short, it will make the line over-full and complain.

You could use \raggedright or \centering so there is stretchability in the lines and they will break if necessary.

\documentclass[final,journal,letterpaper,twocolumn]{IEEEtran}
\usepackage[demo]{graphicx}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{fixltx2e}

\begin{document}
\section{Introduction}

some moo text
\\
\begin{figure}
\centering
  \mbox{\subfloat[]{\label{subfig:a} \includegraphics[height=6cm]{test.png}}}
  \mbox{\subfloat[]{\label{subfig:b} \includegraphics[height=6cm]{test.png}}}
\end{figure}

\newpage

more moo text

\end{document}

enter image description here