I'm trying to place a figure and a table side by side so that the baselines, rather than the captions, of both are aligned:
The answer to this question does this \stackunder
with minipages, but uses
a table with a bottom caption. I tweaked the code, but I can't seem to get the minipage
[b]
s and [t]
s right. I want the bottom of the table to be exactly at the bottom of the image:
Here's the code that produces the image above:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{stackengine}
\begin{document}
\stackunder{
\begin{minipage}[b]{0.49\textwidth}\vspace{0pt}
\centering
\includegraphics[width=\textwidth]{example-image-a.pdf}
\end{minipage}
}
{
\begin{minipage}[]{0.49\textwidth}\vspace{0pt}
\captionof{figure}{A figure with a long caption. A figure with a long caption. A figure with a long caption.}
\end{minipage}
}
\hfill
\stackunder{
\begin{minipage}[b]{0.49\textwidth}\vspace{0pt}
\captionof{table}{A table with a long caption. A table with a long caption. A table with a long caption.
A table with a long caption. A table with a long caption. A table with a long caption. }
\end{minipage}
}
{
\begin{minipage}[]{0.49\textwidth}\vspace{0pt}
\centering
\begin{tabular}[b]{|c|c|c|}\hline
a & b & c\\\hline
1 & 2 & 3\\
4 & 5 & 6\\
7 & 8 & 9\\\hline
\end{tabular}
\end{minipage}
}
\end{document}
Best Answer
The MWE requires only small changes. For the tabular, you used
\stackunder{<caption>}{<tabular}
which associates the overall baseline with the<caption>
. Instead, use\stackon{<tabular>}{<caption>}
so that the tabular is associated with the baseline. Then, to get the proper baseline alignment of thetabular
, you need to make the surroundingminipage
bottom-aligned, with the[b]
option.