# Vertically aligning figures inside table

I want to produce a table that includes figures of different heights. To the right of each figure there are multiple rows of text.

The best I can produce so far is:

Which has two flaws:

1. Both figures are not vertically aligned.
2. The second figure falls outside the table (I would like for lines 3 and 4 to be spaced farther apart from the rulers above and below, so as to create enough vertical space).

Is there a way to have LaTeX automatically center the figures and add vertical space when necesary?

The code I used is:

\documentclass[letter,11pt]{article}
\usepackage{setspace} \doublespacing
\usepackage[utf8]{inputenc}
\usepackage{graphicx,booktabs,multirow}

\begin{document}

\begin{tabular}{cc}
\toprule
\textbf{Figure} & \textbf{Descriptions} \\
\midrule
\multirow{2}{*}{\includegraphics[scale=0.5]{fig1.jpg}} & line 1 \\
& line 2 \\
\midrule
\multirow{2}{*}{\includegraphics[scale=0.5]{fig2.jpg}} & line 3 \\
& line 4 \\
\bottomrule
\end{tabular}

\end{document}


And the test figures are:

You can insert an invisible rule in the second column to change the cell height. A second solution is not to use \multirow, but the adjacent end of rows in a \makecell command, which allows for line breaks inside cells:

\documentclass[letter,11pt]{article}
\usepackage{setspace} \doublespacing
\usepackage[utf8]{inputenc}
\usepackage{graphicx, booktabs, multirow, makecell}

\begin{document}

\begin{tabular}{cc}
\toprule
\textbf{Figure} & \textbf{Descriptions} \\
\midrule
\multirow{2}{*}[-0.7ex]{\includegraphics[scale=0.5]{fig1.jpg}} & line 1 \\
& line 2 \\
\midrule
\multirow{2}{*}{\includegraphics[scale=0.5]{fig2.jpg}} & line 3 \\
& line 4 \rule{0pt}{8ex}\\
\bottomrule
\end{tabular}
\vspace{1cm}

\begin{tabular}{cc}
\toprule
\textbf{Figure} & \textbf{Descriptions} \\
\hline
\raisebox{-0.45\height}{\includegraphics[scale=0.5]{fig1.jpg}} & \makecell{ line 1 \\ line 2} \\
\midrule
\raisebox{-0.5\height}{\includegraphics[scale=0.5]{fig2.jpg}} &\makecell{ line 3 \\ line 4} \\
\bottomrule
\end{tabular}
\end{document}


• That's the output I want, but I need for this to be done automatically (i.e., no manual fiddling with the exact ruler size, as I need to create many of these tables). – scaramouche Oct 21 '16 at 21:16
• @scaramouche: I've added another solution, more automatic. It uses a \raisebox{-0.5\height}{\includegraphics{…}} command, which should theoretically give an automatic vertical centring, but may require some adjustment, probably due to a bad bounding box of the graphic file. – Bernard Oct 21 '16 at 21:43
• Thanks, this is better, but still requires manual adjustment (via the raisebox). The adjustbox approach by @Zarko is more automatic, although it does not provide perfect alignment. So far, there's no perfect approach. – scaramouche Nov 8 '16 at 10:37

An alternative, where is exploited makecell macro from makecell package and used valign=m macro from package adjustbox:

\documentclass[letter,11pt]{article}
\usepackage{setspace} \doublespacing
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{booktabs, makecell, multirow,}

\begin{document}

\begin{tabular}{cc}
\toprule
\textbf{Figure}     &   \textbf{Descriptions}                                             \\
\midrule
\includegraphics[width=30mm,height=15mm,valign=m]{example-image-a}  &   \makecell{line 1 \\
line 2}        \\
\midrule
\includegraphics[width=15mm,height=30mm,valign=m]{example-image-b}  &   \makecell{line 3 \\
line 4}        \\
\bottomrule
\end{tabular}

\end{document}

• This is almost right, except that the figure is not perfectly aligned (there's slightly more white space on one side). – scaramouche Nov 8 '16 at 10:35
• How you measure this? Images are perfectly centered in table, i.e.: better centering of cell content in table is not possible. Please elaborate your claim. – Zarko Nov 8 '16 at 11:26
• @scaramouche, any news? – Zarko Nov 12 '16 at 20:35