tabular vertical alignment to top?

I'm trying to create a simple tabular with two cells of text and two images below them like so:

\begin{tabular}[h]{ c | c}
    \emph{Normal} & \emph{Cone} \\
    \includegraphics[width=0.39\textwidth]{images/pipe1} &
    \includegraphics[width=0.61\textwidth]{images/pipe2}        
\end{tabular}

The first image is shorter than the second and I want it to be aligned at the top of the cell but for some reason it gets aligned to the bottom of the cell instead.

I've tried using the array package and do this:

\begin{tabular}[h]{ p{0.39\textwidth} | p{0.61\textwidth} }
    \emph{Normal} & \emph{Cone} \\
    \includegraphics[width=0.39\textwidth]{images/pipe1} &
    \includegraphics[width=0.61\textwidth]{images/pipe2}        
\end{tabular}

But this doesn't change anything. The first image is still aligned to the bottom. Why is that? Could there be something else going on which forces the alignment to stick to the bottom?

Answers


\def\imagetop#1{\vtop{\null\hbox{#1}}}

\begin{tabular}{c|c}
  \emph{Normal} & \emph{Cone} \\
  \imagetop{\includegraphics[width=0.39\textwidth]{images/pipe1}}&
  \imagetop{\includegraphics[width=0.61\textwidth]{images/pipe1}}
\end{tabular}

The topic has been discussed (and solved) in German here: http://www.matheplanet.com/matheplanet/nuke/html/viewtopic.php?topic=133671

In your case, try:

\begin{tabular}[h]{ c | c}
    \emph{Normal} & \emph{Cone} \\
    \raisebox{-\height+\baselineskip}{\includegraphics[width=0.39\textwidth]{images/pipe1}} &
    \raisebox{-\height+\baselineskip}{\includegraphics[width=0.61\textwidth]{images/pipe2}}
\end{tabular}

This should also solve the problem of the empty line above.

If you would like to stick with the imagetop command, try:

\def\imagetop#1{\raisebox{-\height+\baselineskip}{#1}}

Regarding WLanger's question about Alexey's solution: to adjust for the empty line on top of the image, put the text into a \parbox, and use \raisebox (with a negative value) to adjust it's vertical position.

\raisebox{value}{your text here} % will lower text if it has a negative value.

\parbox{width}{your text here} % will allow for text wrapping

You will have to nest them, like this:

\raisebox{value}{\parbox{width}{your text goes here}}

So the result will be this:

\def\imagetop#1{\vtop{\null\hbox{#1}}}

\begin{tabular}[h]{c|c}        
  \emph{Normal} & \emph{Cone} \\        
  \imagetop{\includegraphics[width=0.39\textwidth]{images/pipe1}} & \raisebox{-1cm}{\parbox{8cm}{Replace this with your text, and adjust the raisebox and parbox values to your liking. I don't know the measurements of the images you're using or I'd do it for you.}
  \imagetop{\includegraphics[width=0.61\textwidth]{images/pipe1}}
\end{tabular}

It isn't elegant, but it works!


Need Your Help

Apply changes for bound datagridview back to SQL Server CE

c# datagridview sql-server-ce

So I've been following this great guide for SQL Server CE:

single sign on possible for already logged in user on intranet?

asp.net security single-sign-on

I have an asp.net intranet application where a user is logged into. I would like to authenticate this same user on another asp.net application which is public and in a diffrenent domain.