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 have table with text in the first column and image in second. I want both columns to be top aligned. I use following code:

\begin{tabular}{p{3cm}l}
Internal state after adding 2 elements & \includegraphics[scale=0.4]{pics/queue_after_add.png} \\
Internal state non-concurrent execution & \includegraphics[scale=0.4]{pics/queue_sequential.png} \\
Internal state concurrent execution & \includegraphics[scale=0.4]{pics/queue_concurrent.png}\\
\end{tabular}

The result looks like this: enter image description here

I also tried to insert \vspace{0pt} as some thread suggests, but result was the same.

share|improve this question
    
have you tried adding \vfill underneath the text? I seem to recall that that has worked for me before. –  myrtille Feb 5 '13 at 15:29
1  
\vspace{0pt} would work if the graphics were in a column of type p{..}. In l-columns you will have to move the graphics below the baseline with \raisebox{-\height}{....}. –  Ulrike Fischer Feb 5 '13 at 15:31
    
@UlrikeFischer It helped! Thank you! I just thought that I don't need p for image, since it doesn't need wrapping. –  damluar Feb 5 '13 at 15:37
    
@UlrikeFischer Could you make that an answer here? –  Joseph Wright Aug 6 '13 at 15:23
add comment

2 Answers

up vote 4 down vote accepted

\vspace{0pt} would work if the graphics were in a column of type p{..}. In l-columns you will have to move the graphics below the baseline with \raisebox{-\height}{....}.

share|improve this answer
add comment

The solution is to use the package 'array'. And then use m instead of the p boxes you have in argument of tabular environment.

\usepackage{array}        
\begin{tabular}{m{3cm}m{5cm}}
    Internal state after adding 2 elements & \includegraphics[scale=0.4]{pics/queue_after_add.png} \\
    Internal state non-concurrent execution & \includegraphics[scale=0.4]{pics/queue_sequential.png} \\
    Internal state concurrent execution & \includegraphics[scale=0.4]{pics/queue_concurrent.png}\\
    \end{tabular}

Now I have no idea how this works. I found this solution online, after a painful 4 hours of trying to fix a similar issue. And no forum seems to explain why tabular environment by itself cannot fix this. So counter-intuitive!

share|improve this answer
add comment

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.