I am trying to arrange two rows of sub-figures using subfig
and floatrow
. The captions are aligned as I wish and the vertical alignment of the objects is also fine. However, I cannot figure out how to get the horizontal spacing between the sub-figures even. In the bottom row, there is no problem: 2 figures with some space between. Fine. In the top row, however, there is more space between the first two figures than there is between the second and third figures. And I cannot figure out why.
What am I missing?
\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}
\begin{document}
\begin{figure}[!htbp]
\captionsetup[subfigure]{justification=centering}
\floatbox{figure}{%
\caption{%
Components of the system: Penguins (\ref{fig:a}), Jumpers (\ref{fig:b}), Thingies (\ref{fig:c}), Cabbages (\ref{fig:d}) and Nuclear Warheads (\ref{fig:e})%
}\label{fig:x}%
}{%
\begin{subfloatrow}%
\subfloat[Penguins were here and here and here]{%
\includegraphics[height=.1\textheight]{example-image-a}\label{fig:a}}
\qquad
\subfloat[Penguin]{%
\includegraphics[height=.15\textheight]{example-image-b}\label{fig:b}}
\qquad
\subfloat[Penguin]{%
\includegraphics[height=.125\textheight]{example-image-a}\label{fig:c}}
\end{subfloatrow}
\begin{subfloatrow}
\subfloat[Penguin]{%
\includegraphics[height=.15\textheight]{example-image-b}\label{fig:d}}
\qquad
\subfloat[Penguins were here, there and everywhere!]{%
\includegraphics[height=.2\textheight]{example-image-a}\label{fig:e}}
\end{subfloatrow}}
\end{figure}
\end{document}
Note that I am aware of alternatives to subfig
. If no solution is available for subfig
, I'll hack something for now and look into other options for the future.
Best Answer
Update
The
subfloatrowsep
,floatrowsep
keys give you control on the horizontal separation between subfloats (floats) when using floatrow; however, simply using something likein your current code will not produce the desired result since you are using
\subfloat
(from thesubfig
package). The solution is not to use\subfloat
and usefloatrow
's\ffigbox
instead. This makesbehave as expected and also solves a problem with the counters (further discussed in How can I get correct labelling of sub-figures with subfig and floatrow?).
The output:
Initial version
I've also had problems with horizontal positioning of figures using
floatrow
and thefloatrowsep
,subfloatrowsep
keys seem to not always behave as expected.One option that I've found to work in problematic cases is to kill the default separation with
subfloatrowsep=none
and then use\quad
or any other spacing command to manually control the separation (one would think thatsubfloatrowsep=quad
would handle this automatically, but this is not always the case). Anyways, my suggestion: