# How to arrange a table and figure side by side with all captions on one side

To maximize space, I'm trying to put an table and image side-by-side in a document. As the image is longer than the table, I want to put both captions under the table (if possible). I envisage this looking something like as follows.

I've followed the steps in this example. However I can't find a way to move the figure caption under the table. Here is some working code:

\documentclass{article}

\usepackage[demo]{graphicx} % for inclusion of graphics
\usepackage{floatrow}
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\usepackage{booktabs}

\begin{document}

\begin{figure}[t]
\begin{floatrow}
\TopFloatBoxes
\capbtabbox{
\begin{tabular}{ccc} \toprule
1 & $\{1\}$ & A  \\
2 & $\{1,2\}$ & B   \\
3 & $\{1,2,3\}$ & C  \\
4 & $\{1,2,3,4\}$ & D  \\
5 & $\{1,2,3,4,5\}$ & E  \\
6 & $\{1,2,3,4,5,6\}$ & F  \\
7 & $\{1,2,3,4,5,6,7\}$ & G  \\
8 & $\{1,2,3,4,5,6,7,8\}$ & H  \\
9 & $\{1,2,3,4,5,6,7,8,9\}$ & I  \\
10 & $\{1,2,3,4,5,6,7,8,9,10\}$ & J  \\ \bottomrule
\end{tabular}
}{
{\caption{A caption for a table in a figure and a table side by side}\label{fig:test}}
}
\ffigbox{
\includegraphics[height=8cm]{Images/preNet.pdf}
}{
{\caption{A caption for a figure in a figure and a table side by side}\label{fig:test}}
}
\end{floatrow}
\end{figure}

\end{document}


This is similar to Gonzalo's answer, but has the advantage of not requiring explicit computations nor strange adjustments.

\documentclass{article}

\usepackage[demo]{graphicx} % for inclusion of graphics
\usepackage{booktabs}
\usepackage{capt-of,calc}

\newsavebox{\figurebox}

\begin{document}

\begin{figure}[t]
%% get the dimensions of the figure
\sbox{\figurebox}{\includegraphics[height=8cm]{Images/preNet.pdf}}

\begin{minipage}[t][\ht\figurebox]{\textwidth-\wd\figurebox-1em}
\centering\footnotesize
\vspace*{0pt}% to set the top
\begin{tabular}{ccc} \toprule
1 & $\{1\}$ & A  \\
2 & $\{1,2\}$ & B   \\
3 & $\{1,2,3\}$ & C  \\
4 & $\{1,2,3,4\}$ & D  \\
5 & $\{1,2,3,4,5\}$ & E  \\
6 & $\{1,2,3,4,5,6\}$ & F  \\
7 & $\{1,2,3,4,5,6,7\}$ & G  \\ \bottomrule
\end{tabular}
\captionof{table}{A caption for a table in a figure and a table side by side}
\label{tab:test}

\vfill

\captionof{figure}{A caption for a figure in a figure and a table side by side}
\label{fig:test}
\end{minipage}\hfill
\begin{minipage}[t]{\wd\figurebox}
\centering
\vspace*{0pt}% to set the top
\usebox{\figurebox}
\end{minipage}
\end{figure}

\end{document}


Instead of capt-of one can load caption that has other advantages; however, some classes don't allow using caption.

I think that using minipages of fixed height is easier here; captions were provided using \captionof from the caption package:

\documentclass{article}
\usepackage[margin=3.5cm]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{booktabs}

\begin{document}

\begin{figure}
\begin{minipage}[c][8cm][t]{.67\linewidth}
\centering
\begin{tabular}{ccc} \toprule
1 & $\{1\}$ & A  \\
2 & $\{1,2\}$ & B   \\
3 & $\{1,2,3\}$ & C  \\
4 & $\{1,2,3,4\}$ & D  \\
5 & $\{1,2,3,4,5\}$ & E  \\
6 & $\{1,2,3,4,5,6\}$ & F  \\
7 & $\{1,2,3,4,5,6,7\}$ & G  \\
8 & $\{1,2,3,4,5,6,7,8\}$ & H  \\
9 & $\{1,2,3,4,5,6,7,8,9\}$ & I  \\
10 & $\{1,2,3,4,5,6,7,8,9,10\}$ & J  \\ \bottomrule
\end{tabular}
\captionof{table}{a caption for a table side-by-side with a figure}
\vfill
\captionof{figure}{a caption for a figure side-by-side with a figure}
\end{minipage}%
\begin{minipage}[c][8cm][t]{.33\linewidth}
\centering
\includegraphics[height=8cm,width=\linewidth]{example-image-a}}
\end{minipage}
\end{figure}

\end{document}


Boxing the image and measuring the total height of the box allows you to find the required height for the minipages in an automatic way

Use of \floatbox \capbeside and \thisfloatsetup from floatrow, inspired and learned from Gonzalo Medina's work https://tex.stackexchange.com/a/29144/34618

Code

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage[demo]{graphicx} % for inclusion of graphics
\usepackage{floatrow}
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\usepackage{booktabs}

\begin{document}

\begin{figure}[t]
\begin{floatrow}
\TopFloatBoxes
\capbtabbox{
\begin{tabular}{ccc} \toprule
1 & $\{1\}$ & A  \\
2 & $\{1,2\}$ & B   \\
3 & $\{1,2,3\}$ & C  \\
4 & $\{1,2,3,4\}$ & D  \\
5 & $\{1,2,3,4,5\}$ & E  \\
6 & $\{1,2,3,4,5,6\}$ & F  \\
7 & $\{1,2,3,4,5,6,7\}$ & G  \\
8 & $\{1,2,3,4,5,6,7,8\}$ & H  \\
9 & $\{1,2,3,4,5,6,7,8,9\}$ & I  \\
10 & $\{1,2,3,4,5,6,7,8,9,10\}$ & J  \\ \bottomrule
\end{tabular}
}{
{\caption{A caption for a table in a figure and a table side by side}\label{tab:test}}
}
\hspace{-9cm}
\ffigbox{
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={left,bottom},capbesidewidth=9cm}}]{figure}
{
\includegraphics[height=8cm]{Images/preNet.pdf}
}
}{
{\caption{A caption for a figure in a figure and a table side by side}\label{fig:test}}
}
\end{floatrow}
\end{figure}

\end{document}