7

A continuation of this question.

I'm fighting a page-limit in a single-column layout and I need to put a Figure and a Table side-by-side and provide them with independent captions. However, the style guide for the publishers (LNCS) wants Figure captions below and Table captions above (probably something to do with this).

=======================================================

If I adapt @lockstep's floatrow example from this question accordingly to have a Table caption above ...

\documentclass{article}

\usepackage{floatrow}
% Table float box with bottom caption, box width adjusted to content

%% **********************************
%% just adding \captop to original example
%% **********************************
\newfloatcommand{capbtabbox}{table}[\captop][\FBwidth]

\usepackage{blindtext}


\begin{document}

\blindtext

\begin{figure}
\begin{floatrow}
\ffigbox{%
  \rule{3cm}{3cm}%
}{%
  \caption{A figure}%
}
\capbtabbox{%
  \begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}
}{%
  \caption{A table}%
}
\end{floatrow}
\end{figure}

\end{document}

=======================================================

The problem becomes clear ...

enter image description here

=======================================================

The floatrow doesn't correctly line up the Table and Caption. I reluctantly tried to use vspace to solve the problem, but it didn't work out.

Any suggestions on how to get these two to align? I'm happy to accept any alignment that ensures that the Table and Figure fit within the same "box".

(A similar-ish question was asked here, but specific for subfig and with a very localised problem it seems.)

2 Answers 2

8

If you want them vertically centered, you can use \CenterFloatBoxes, as in the following example:

\documentclass{article}
\usepackage{floatrow}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}
\CenterFloatBoxes
\begin{floatrow}
\ffigbox
  {\includegraphics{image}}
  {\caption{A caption for a figure in a figure and a table side by side}\label{fig:test}}
\killfloatstyle
\ttabbox
  {\begin{tabular}{ll}
    \hline
    column1a & column2a \\
    column1b & column2b \\
    column1c & column2c \\
    \hline
  \end{tabular}
  }
  {\caption{A caption for a table in a figure and a table side by side}\label{tab:test}}
\end{floatrow}
\end{figure}

\end{document}

enter image description here

There's also \TopFloatBoxes for alignment at the top and \BottomFloatBoxes, for alignment at the bottom.

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

3
  • I probably should have spotted that. Thanks!
    – badroit
    Mar 11, 2013 at 19:23
  • 1
    Is there an option similar to \CenterFloatBoxes, but where only the image/table size is used for centering and not the caption? For instance, if I have a large caption for one of the two objects, then it looks weird as the objects are not vertically centered at all. At least not based on their actual graphics.
    – pir
    Nov 16, 2015 at 21:24
  • Is there a simple way to have the table caption at the bottom?
    – runDOSrun
    Nov 27, 2017 at 15:20
9

Another solution, using package capt-of and parboxes:

\documentclass{article}
\usepackage{lipsum}
\usepackage{capt-of}
\begin{document}
\thispagestyle{empty}

\lipsum[1]

\begin{figure}
\parbox[t]{4cm}{\null
  \centering
  \rule{3cm}{3cm}%
  \captionof{figure}{A figure}%
}
\parbox[t]{8cm}{\null
\centering
  \vskip-\abovecaptionskip
  \captionof{table}[t]{A table}%
  \vskip\abovecaptionskip
  \begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}
}
\end{figure}
\end{document}

Result

2
  • Hadn't encountered the capt-of package before. Thanks for the pointer.
    – badroit
    Mar 11, 2013 at 19:42
  • floatrow seems to conflict with the figure package, which is included in subcaption among other packages, but capt-of works fine in that situation.
    – Erik
    Feb 10, 2017 at 1:04

You must log in to answer this question.

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