2

I'm using this code to put a large table next to a figure.

\begin{figure}%[t!]
\centering
\begin{minipage}[c]{0.95\textwidth}
\begin{tabular}{cc}
\resizebox{0.45\textwidth}{!}{
\begin{tabular}{c c c c c c}
 % ... all the lines and stuff
\end{tabular} } & \includegraphics[width=0.45\textwidth]{./image.pdf}\\
(a) & (b) \\
\end{tabular}
\end{minipage}
\end{figure}

However the code results in the table and the figure not being aligned correctly, as you can see below:

enter image description here

What is the problem?

Werner
  • 603,163
Matteo
  • 1,787
  • 1
    Use 2 minipages with the option [c] and appropriate widths and get rid of the outer tabular. But resizing like this, especially the table, is a really bad idea in terms of readability! You might like the subcaption or floatrow packages or something like that to help with creating sub-figures, though. – cfr May 01 '15 at 02:16
  • For your inner-tabular, use \begin{tabular}[b]... – Werner May 01 '15 at 02:21
  • @Werner - could you please explain why does that work? – Matteo May 01 '15 at 02:26

1 Answers1

3

If the tabular and image has roughly the same height, then align them at their baselines. By default, \includegraphics is aligned at the base, but tabular is aligned at the vertical centre. Using \begin{tabular}[b] would suffice as it changes the vertical centre alignment to be aligned with the last line's baseline...

Other options include adding

\usepackage[export]{adjustbox}

to your preamble and using

\includegraphics[valign=c,...]{<image>}

This would align the image to the tabulars (default) vertical centre.

Werner
  • 603,163