Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
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

3 Answers 3

up vote 11 down vote accepted

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:

enter image description here

share|improve this answer
    
You're the man! Thanks for that! –  Prine Aug 18 '11 at 14:08

use the m column type for the image, eg:

\begin{tabular}{c m{4cm}}
share|improve this answer

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}

enter image description here

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}
share|improve this answer
    
The same functionality (with the key valign) is available with \usepackage[export]{adjustbox}. –  egreg Sep 5 at 10:41
    
@egreg Thank you for reminding me about adjustbox. –  Ignasi Sep 5 at 12:03
    
And thank you for advertising a new package! –  egreg Sep 5 at 12:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.