# Vertically align cell table in figure

I have the following figure:

\begin{figure}[ht!]
\centering
\begin{tabular}{|c|c|}
\end{tabular}
\caption{A combo box with and without showing the menu.}
\label{fig:combos}
\end{figure}


which produces:

The left image is significantly shorther than the right image. How do I vertically align the left image to the top of the cell?

I would already overheat Google with my searches on how to do it, if it would be possible. Nothing I do just seems to have any effect on it:

• \includegraphics{combo}\hfill does nothing
• \begin{tabular}{|p{3cm}|c|} does nothing, apart from setting the columnt width
• \raisebox{4.5\height}{\includegraphics{combo}} indeed moves the image up and down, but I just cannot seem to get the parameter right. Something between 5.5 and 6 it seems. But that's really not what I want, if I decide to change the second image, I would have to go through the painstaking alignment process again.
• Using minipages aligns the image to the top, but also adds more space to the right from both images and maybe pushes the images too far up, so that the vertical lines begin slightly off:

I specified the images' width in pixels, they are both 82 pixels wide.

The simplest way is to use the adjustbox package:

\documentclass{article}
\usepackage[demo]{graphicx} % just to provide mock figures

\begin{document}

\begin{tabular}{|c|c|}
\end{tabular}

\end{document}


Without any package,

\begin{tabular}{|c|c|}
\raisebox{\dimexpr-\height+\ht\strutbox}{\includegraphics[width=1cm,height=.5cm]{x}} &
\raisebox{\dimexpr-\height+\ht\strutbox}{\includegraphics[width=1cm,height=3cm]{x}} \\
\end{tabular}


would do the same.

• @JakubZaverka: If you load adjustbox (v0.8 or later) with the export option you can use the valign key directly with \includegraphics, after the size keys. – Martin Scharrer Feb 5 '13 at 22:51
• This works, but a note about something I needed some time to discover: you have to apply adjustbox to all cells in a row even if you only want to change the vertical alignment of one of them. – rumtscho Jan 13 '17 at 16:50

Another minipage solution with a few more optional arguments.

\documentclass{article}
\usepackage{graphicx}
\usepackage{mwe} %< -- For dummy images

\begin{document}%
\begin{figure}
\centering
\begin{tabular}{|c|c|}
\begin{minipage}[b][6cm][t]{2cm} %[minipage place][height][content align]{width}
\includegraphics[width=2cm,height=1cm]{example-image-a}%
\end{minipage}
& \includegraphics[width=2cm,height=6cm]{example-image-b}
\end{tabular}
\caption{A combo box with and without showing the menu.}
\label{fig:combos}
\end{figure}
\end{document}


I would put both \includegraphics commands inside minipages as follows:

\begin{minipage}[t]{<width-of-image>}
\vspace{-\baselineskip}\par
\includegraphics{combo}
\end{minipage}
&
\begin{minipage}[t]{<width-of-image>}
\vspace{-\baselineskip}\par
\end{minipage}


Though I might be wrong.

\documentclass{article}
\usepackage{graphicx}

\begin{document}%
\begin{figure}
\centering
\begin{tabular}{cc}
\includegraphics[width=2cm,height=1cm,valign=t]{example-image-a}%
&   \includegraphics[width=2cm,height=6cm,valign=t]{example-image-b}
\end{tabular}
\caption{A combo box with and without showing the menu.}
\label{fig:combos}
\end{figure}
\end{document}


gives the same result as shown in egreg answer