[Tex/LaTex] Vertically center cells with fixed height

tablesvertical alignment

Consider the solution https://tex.stackexchange.com/a/12762/4011 to the problem of fixing the height of a cell in tabular. This essentially adds some space above the cell content, so it is not warranted that it is always vertically centered. Just changing p-cell to m-cell doesn't solve this. So how can I modify this to ensure a vertical centering of the every cell content?

\documentclass[a4paper]{article}
\usepackage{array}  

\begin{document} 

\newcolumntype{C}[1]{%
 >{\vbox to 5ex\bgroup\vfill\centering}%
 p{#1}%
 <{\egroup}}  

\begin{tabular}{|c | C{3cm} | C{5cm} |} 
 \hline 
 Short Text & Short Text & Short Text \tabularnewline \hline
Short Text  & Short Text & Loooooooooo  oooooooooooong Text \tabularnewline \hline  
Short Text  & Short Text & Loooooooooooooooooooooong Text \tabularnewline \hline 
\end{tabular}    
\end{document}

Best Answer

You can just add a \vfill before the \egroup, but then you will notice the result is too high, by about \baselineskip, so you should backup by this amount too:

Sample output

\documentclass[a4paper]{article}
\usepackage{array}  

\begin{document} 

\showoutput

\newcolumntype{C}[1]{%
 >{\vbox to 5ex\bgroup\vfill\centering\arraybackslash}%
 p{#1}%
 <{\vskip-\baselineskip\vfill\egroup}}  

 \begin{tabular}{|c | C{3cm} | C{5cm} |}
   \hline 
   Short Text & Short Text & Short Text \\ \hline
   Short Text  & Short Text & Loooooooooo  oooooooooooong Text \\ \hline  
   Short Text  & Short Text & Loooooooooooooooooooooong Text \\ \hline
   Short Text  & Several pieces of text to fill up this box & Not much
   \\ \hline   
 \end{tabular}    
\end{document}