How to vertically center text with an image in the same row of a table
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}
\usepackage{graphbox} %loads graphicx package
\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}
\usepackage[export]{adjustbox}
\begin{document}
\begin{tabular}{ccc}
text & \includegraphics[valign=m,scale=0.25]{example-image} & text \\
\end{tabular}
\end{document}
use the m column type for the image, eg:
\begin{tabular}{c m{4cm}}