5

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.

  • 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
  • Other two solutions: tex.stackexchange.com/a/199644/1952 – Ignasi Apr 19 '16 at 8:46
5

\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}{....}.

0

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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