# How to vertically center text with an image in the same row of a table

I want to create a table with multiple rows of the following form: a cell that contains text and then multiple cells that contain images. The text should be vertically centered and the contents of every column should also be centered horizontally. I am aware of the m{} column type but somehow this seems to fail if an image is contained in the row and determines the row height. Any ideas?

Minimal example:

\documentclass{article}
\usepackage{graphicx}
\usepackage{array}
\begin{document}
\begin{figure}
\begin{tabular}{m{3cm}c}
(a) & \includegraphics{some_picture.pdf}\\
\end{tabular}
\end{figure}
\end{document}

• Welcome to tex.sx! A tip: you can use backticks  to mark your inline code as I did in my edit. Also, it isn't really a custom here to sign with a "thanks". Finally a suggestion: Maybe change your username to something more telling than "user5506"? – doncherry May 26 '11 at 9:15

The baseline of an image is at the bottom. You could use \raisebox to shift it up. Use half of \height, which stands for the height of the box to be raised.

\raisebox{-.5\height}{\includegraphics{some_picture}}


For example:

\documentclass{article}
\usepackage{mwe}
\begin{document}
\begin{tabular}{lll}
\raisebox{-.5\height}{\includegraphics[scale=0.25]{example-image}} & text & text\\
\end{tabular}
\end{document}


yields:

The new graphbox package introduces a new (vertical) align key which can be used in \includegraphics options. Using it there's no need for \raisebox, \parbox or taking care of distinguishing between c or m columns in tabulars.

\documentclass{article}
\usepackage{mwe}
\begin{document}
\begin{tabular}{ccc}
text & \includegraphics[scale=0.25]{example-image} & text\\
text & \includegraphics[align=c,scale=0.25]{example-image} & text\\
text & \includegraphics[align=t,scale=0.25]{example-image} & text\\
\end{tabular}
\end{document}


As egreg reminded me, adjustbox package provides a similar funcionality. Loading it with export option, a new key valign={t|m|b|T|M|B} can be used as \includegraphics option.

\documentclass{article}
\usepackage{mwe}
\begin{document}
\begin{tabular}{ccc}
text & \includegraphics[valign=m,scale=0.25]{example-image} & text \\
\end{tabular}
\end{document}

• The same functionality (with the key valign) is available with \usepackage[export]{adjustbox}. – egreg Sep 5 '14 at 10:41
• @egreg Thank you for reminding me about adjustbox. – Ignasi Sep 5 '14 at 12:03
• And thank you for advertising a new package! – egreg Sep 5 '14 at 12:08

use the m column type for the image, eg:

\begin{tabular}{c m{4cm}}


A variant of @Herbert's answer that gives vertically and horizontally centered column alignment is the following. (This is my preferred method when not using \includegraphics.)

\begin{tabular}{
>{\centering\arraybackslash}m{.4\linewidth} % col width
>{\centering\arraybackslash}m{.4\linewidth} % col width
}
% an image, tikz picture, etc.
&
% another image, tikz picture, etc.
\end{tabular}
`