Graphics, Figures & TablesVertically Centering Images in longtable?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
EFaden
Posts: 24
Joined: Thu Jun 04, 2009 2:58 am

Vertically Centering Images in longtable?

Post by EFaden »

So I am using longtable to produce a... longtable. The table has a bunch of columns, one of which has images in it. I am trying to get the images vertically centered. Anyone know how to do it? I have tried the m/b/p etc column types, but nothing seems to work....

Basically I have:

Code: Select all

\begin{longtable}[c] { | c | c | }
  \hline
  Col A & Col B\endhead
  \hline
  Something & \includegraphics{blah.pdf}\\
etc...
I am trying to get the graphics to be vertically and horizontally centered in their cells. Any ideas?

-Eric

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertically Centering Images in longtable?

Post by localghost »

You can try the following.

Code: Select all

\raisebox{-0.5\height}{\inlcudegraphics{filename}}

Best regards
Thorsten
EFaden
Posts: 24
Joined: Thu Jun 04, 2009 2:58 am

Re: Vertically Centering Images in longtable?

Post by EFaden »

Didn't seem to work. Made the row height smaller, but its still aligned to the top edge of the cell.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertically Centering Images in longtable?

Post by localghost »

I didn't test it, but you can try the following.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{array,longtable,ragged2e}

\begin{document}
  \begin{longtable}[c]{|*{2}{>{\Centering}m{0.5\linewidth}|}}\hline
    Col A & Col B \endhead \hline
    Something & \rule{4cm}{4cm} \\
  \end{longtable}
\end{document}
Post Reply