how to vertically align a cell in a table?

Use \topincludegraphics defined as follows

\newcommand{\topincludegraphics}[2][]{%
  \raisebox{\dimexpr-\height+\ht\strutbox\relax}{\includegraphics[#1]{#2}}}

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


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

\raisebox{-\height}{\includegraphics[width=7.3in]{imgX.pdf}}

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?.


\documentclass{article}
\usepackage{array}

\newsavebox\topalignbox
\newcolumntype{T}{%
  >{\begin{lrbox}\topalignbox
    \rule{0pt}{\ht\strutbox}}
  c
  <{\end{lrbox}%
    \raisebox{\dimexpr-\height+\ht\strutbox\relax}%
      {\usebox\topalignbox}}}

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

\begin{document}    

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

\end{document}

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:

\documentclass{article}
\usepackage{array}
\newcolumntype{M}{>{$\vcenter\bgroup\hbox\bgroup}c<{\egroup\egroup$}}
\begin{document}
\begin{tabular}{|M|M|} \hline
\rule{2cm}{3cm} & \rule{3cm}{4cm} \\ \hline
\rule{4cm}{5cm} & \rule{2cm}{2cm} \\ \hline
\end{tabular}
\end{document}

enter image description here