TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a table that I define

\includegraphics[width=7.3in]{img1.pdf} &
\includegraphics[width=7.3in]{img2.pdf} &
\includegraphics[width=7.3in]{img3.pdf} & 
\includegraphics[width=7.3in]{img4.pdf} &
\includegraphics[width=7.3in]{img5.pdf} &
\includegraphics[width=7.3in]{img6.pdf} \\
\includegraphics[width=7.3in]{img7.pdf} &
\includegraphics[width=7.3in]{img8.pdf} &
\includegraphics[width=7.3in]{img9.pdf} &
\includegraphics[width=7.3in]{img10.pdf} &
\includegraphics[width=7.3in]{img11.pdf} &
\includegraphics[width=7.3in]{img12.pdf} \\
\includegraphics[width=7.3in]{img13.pdf} & \multicolumn{12}{|c}{
\hspace{3cm} \includegraphics[width=92cm]{i3} }

Not all images are of the same height. I want all of the images to be aligned to the top of the tabular cell, instead of the bottom, which seems to be the case now. How would I do that?

share|improve this question
duplicate: tex.stackexchange.com/questions/7208/… – xport Jul 10 '11 at 15:38
@xport: Thanks for adding the link. However, IMHO this question can be taken as a special case of the more general question you linked and can be solved with much less code. – Martin Scharrer Jul 10 '11 at 16:06
Is it really just images or do you also have text? Especially multi-line text requires more work than when you have multiple images. It would be nice if you could rephrase your title if it's just about images. – Martin Scharrer Jul 10 '11 at 17:07
{lllllllllllll} represents there are 13 columns. But the first and second rows has 6 columns each. – xport Jul 10 '11 at 17:59
You are creating a poster? 7.3 inch / column x 6 columns x 2.54 cm = about 1.1 meter. – xport Jul 10 '11 at 18:01
up vote 4 down vote accepted

If you only have images in the cells you can use \raisebox to vertical shift all images below the baseline, so that they all get top aligned


However, if you have text in the same row it will be placed just above the images (baseline is on the top corner). In that more complicated case see How to vertically-center the text of the cells?.

share|improve this answer
PS: In the next release of adjustbox a new option raise for \includegraphics will be included, then you can use \includegraphics[width=7.3in,raise=-\height]{imgX.pdf} for short. I might also add a align=t or similar option which does the details for you. – Martin Scharrer Jul 10 '11 at 15:51

Use \topincludegraphics defined as follows


instead of \includegraphics; without \ht\strutbox there would be gaps, because each table row is always at least as high as a strut.

share|improve this answer
+1 I didn't thought about the automatically added strut. (I did however plan to have an align=t and align=T (see my comment above) for exactly this two different cases; so actually I should have known better) – Martin Scharrer Jul 10 '11 at 16:04


%%% or
%  >{\vtop\bgroup\vspace*{-\ht\strutbox}%
%    \hbox\bgroup\rule{0pt}{\ht\strutbox}}
%  c
%  <{\egroup\egroup}}


\begin{tabular}{|T|T|} \hline
  \rule{2cm}{3cm} & \rule{3cm}{4cm} \\ \hline
  \rule{4cm}{5cm} & \rule{2cm}{2cm} \\ \hline
  aabb & ccdd \\ \hline


enter image description here

This is somewhat complex. It is different with xport's solution since it ease the width calculation. The core code is the same as egreg's.

For vertical centering, it is better to use primitive TeX's \vcenter:

\begin{tabular}{|M|M|} \hline
\rule{2cm}{3cm} & \rule{3cm}{4cm} \\ \hline
\rule{4cm}{5cm} & \rule{2cm}{2cm} \\ \hline

enter image description here

share|improve this answer
Package varwidth Warning: Failed to reprocess entire contents on input line 15. – egreg Jul 10 '11 at 16:47
IMHO this answer would be better suited for How to vertically-center the text of the cells?. The idea was to have this similar question for the specific case of images with simpler answer and the linked question for the more complicated general case. (maybe I should merge the two question after all?) – Martin Scharrer Jul 10 '11 at 16:52
BTW: you could use the lrbox environment to box the whole cell and then use \raisebox on it. But the trick is to aligned in right. The geometric center or top seems to be not "the correct" (TM) one. – Martin Scharrer Jul 10 '11 at 16:54
@egreg: Yes, I noticed that. But the result seems OK, I didn't pry varwidth's code. varwidth here is certainly overused. I'm thinking about a new implementation. – Leo Liu Jul 10 '11 at 16:58
\newcolumntype{T}{>{\vtop\bgroup\vspace*{-\ht\strutbox}\hbox\bgroup}c<{\egroup\‌​egroup}} – egreg Jul 10 '11 at 17:03

Your Answer


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.