[Tex/LaTex] Problem with Table Vertical Alignment

tablesvertical alignment

I want a table whose first column is aligned top, second column is aligned middle, and third column is aligned bottom; like this:

I wrote the following code:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{array}

\begin{document}

\begin{tabular}{| p{1cm} | m{1cm} | b{1cm} |}
    \hline
    x &
    A long text comes here &
    x \\
\hline
\end{tabular}

\end{document}

Yet, to my surprise, the outcome was "all columns aligned middle," as follows:

What did I do wrong?

Best Answer

You could use optional arguments of \parbox for vertical alignment and vertical size. Here's a small demonstration example, I just quickly estimated the height. Inserting \vspace{0pt} is a trick for changing the base line for the alignment. Without it, we would get a lot of additional whitespace.

\documentclass{article}
\newcommand*{\tabbox}[2][t]{%
    \vspace{0pt}\parbox[#1][3.7\baselineskip]{1cm}{\strut#2\strut}}
\begin{document}
\begin{tabular}{| p{1cm} | p{1cm} | p{1cm} |}
    \hline
    \tabbox{x} &
    \tabbox{A long text comes here} &
    \tabbox[b]{x} \\
    \hline
\end{tabular}
\end{document}

Output:

alt text