3

I am having an issue with latex placing my figures incorrectly. I have 4 related plots that I want to appear together as a single figure (with a,b,c,d sub-references).

\begin{center}
\begin{figure}[h]
\subfigure[All instances]{
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/all_Q_time}
\label{fig:q_time_all}
}
\subfigure[SAT instances]{
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/all_sat_Q_time}
\label{fig:q_time_sat}
}
\subfigure[UNSAT instances]{
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/all_unsat_Q_time}
\label{fig:q_time_unsat}
}
\subfigure[Uniform Random Sample]{
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/sample_Q_time}
\label{fig:q_time_sample}
}
\caption{Q metric plotted against time}
\end{figure}
\end{center}

This should display an even 4*4 grid of plots, each the same size. However what happens is that the top right plot is offset on the x-axis, such that the left hand side of it is in the middle of the space (i.e. roughly offset by 50% of its width)enter image description here

Any suggestion of how to fix it?

3
  • Welcome to TeX.SX! Don't use center around figure, but rather \centering after \begin{figure}. You seem to be using the obsolete package subfigure. Please, make the example selfcontained, from \documentclass to \end{document}, with the packages necessary to reproduce the issue.
    – egreg
    Jan 31, 2014 at 20:35
  • That did the trick - thanks very much. I did try using a different package (cant remember the name) but it seemed a lot more complicated, and I couldn't make it work at all. This was an odd bug because when figure size was set to 0.5 it worked fine Jan 31, 2014 at 20:40
  • Spaces between "words" of a paragraph line are stretched equally, except the last line of the paragraph, which has all the stretch pushed to the end. Do the following: put the center environment inside the figure environment (but better to use \centering instead) and end the first line with a double backslash (after the second figure. If the figures end up too close together, add appropriate space commands between them (I would use \hfil).
    – Dan
    Jan 31, 2014 at 20:45

1 Answer 1

3

The centering should be declared after \begin{figure}. Use

\begin{figure}[htp] % not h only
\centering
\subfigure[All instances]{%
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/all_Q_time}%
\label{fig:q_time_all}%
}\hfil
\subfigure[SAT instances]{%
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/all_sat_Q_time}%
\label{fig:q_time_sat}%
}

\subfigure[UNSAT instances]{%
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/all_unsat_Q_time}%
\label{fig:q_time_unsat}%
}\hfil
\subfigure[Uniform Random Sample]{%
\includegraphics[width=0.4\textwidth]{timeregression/graphs/bucketing/sample_Q_time}%
\label{fig:q_time_sample}%
}

\caption{Q metric plotted against time}
\end{figure}

However, \subfigure is a command from the obsolete package subfigure. Load subfig, instead, and change \subfigure into \subfloat.

Note also the % in various places, to avoid spurious spaces creeping in. I split into two parts the subfloat inclusions and added \hfil between the two on the same line, so the spacing will be equally divided between left, center and right.

You can also consider the more recent and very powerful subcaption package (that requires a different syntax, though).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .