3

How can I ensure that the four plots (which are all the same size pdfs) appear with the same spacing: see they are offset here:

Offset Image % Actual versus predicted plots

\begin{figure}[H]
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth]{figs/immediate_formula_s_avp.pdf}
\hspace{0.1cm}
\end{minipage}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth]{figs/immediate_formula_s_avp.pdf}
\end{minipage}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth]{figs/immediate_formula_s_avp.pdf}
\hspace{0.1cm}
\end{minipage}
\begin{minipage}[b]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth]{figs/immediate_formula_s_avp.pdf}
\end{minipage}
\caption{Actual Versus Predicted Plots}\label{multiavp}
\end{figure}
mike
  • 505
  • Try with removing the empty lines in between. They are starting a new line. For the captions see the subcaption package. That would also fix the minipage problem completely. – percusse Dec 11 '12 at 16:24
  • Awesome @percusse, you've helped me out again. Is there a good way to only reference the entire figure with a single caption/label? – mike Dec 11 '12 at 16:27
  • Yes subcaption package has a \phantomcaption command which will hide the individual one to which it is provided but leaves the main caption untouched. – percusse Dec 11 '12 at 16:28
  • Great, all set on the captions -- any chance you could shed some light on the offset nature of the plots? – mike Dec 11 '12 at 16:35
  • @mike Try a run with all four images being the same .pdf or with [demo]{graphicx}, problem is your second image is not the same size. – yannisl Dec 11 '12 at 16:56
  • I've tried with all 4 being the same .pdf, and the second one is still offset -- what can I adjust to fix this? – mike Dec 11 '12 at 16:58
  • I would try \hfill between the first two and the second two figures and adding a manual linebreak. Having three \hspaces is weird. I'm not saying it's to blame but it can't help. – Christian Dec 11 '12 at 17:03
  • \hfill makes them both off-set. Removing all of the \hspaces also doesn't work -- what am I missing here? I've updated the code and image. – mike Dec 11 '12 at 17:08

1 Answers1

4

I've taken your code and made a few modifications, such as removing all \centering statements: They're not needed if you (i) use \hspace{\fill} directives between the first and second and between the third and fourth minipages and (ii) set the width of the graphs inside each minipage to \linewidth. Incidentally, I would use the \textwidth parameter to specify the width of minipage environments, and \linewidth (or a fraction thereof) for measurements inside a minipage environment.

enter image description here

\documentclass{article}
\usepackage[demo]{graphicx} % leave off demo option in real program
\begin{document}

\begin{figure}    
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{figs/immediate_formula_s_avp.pdf}
\caption{Actual Versus Predicted: Immediate}
\label{fig:immediate}
\end{minipage}
\hspace{\fill}
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{figs/proximal_formula_s_avp.pdf}
\caption{Actual Versus Predicted: Proximal}
\label{fig:proximal}
\end{minipage}

\vspace*{0.5cm} % (or whatever vertical separation you prefer)
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{figs/distal_formula_s_avp.pdf}
\caption{Actual Versus Predicted: Distal}
\label{fig:distal}
\end{minipage}
\hspace{\fill}
\begin{minipage}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{figs/combined_formula_s_avp.pdf}
\caption{Actual Versus Predicted: Combined}
\label{fig:combined}
\end{minipage}

\end{figure}
\end{document}
Mico
  • 506,678
  • Hi Mico, I really like your solution, its extremely elegant but I was just wondering if I can modify this for a two column document format ? – CutestPenguin Oct 30 '15 at 20:56
  • 1
    @CutestPenguin - Have you tried replacing the figure environment with a figure* environment? – Mico Oct 30 '15 at 21:33