Title in tables with linebreaks and proper gaps

I want my table headers to be centered, aligned at the top & without any manual adjustments.

After alot of searching i was able to achieve most of it. As u can see i still have the problem that when we have more than one line, the bottom gap sticks to the text whereas it should be as big as the top gap. Is there a way to fix this programatically? If i do it manually like \\[1cm] i have to be a) eyeballing and b) redo it incase i change the arraystretch.


\documentclass{article}
\usepackage{booktabs}

\usepackage{pbox}
\begin{document}
\newcommand{\ct}[1]{\pbox[t]{3cm}{\relax\ifvmode\centering\fi#1}}

\begin{table} \centering
\renewcommand*{\arraystretch}{6}
{\small
\begin{tabular}{ccc}

\midrule
{\ct{Data}}   &  { \ct{aa \\aaaaa } }  &  { \ct{A nice heading \\is worth (\%)\\alot}  } \\
\midrule
{cc}   &  { aa }  &  { ss } \\
{cc}   &  { aa }  &  { ss } \\
{cc}   &  { aa }  &  { ss } \\

\midrule
\end{tabular}}
\end{table}

\end{document}
-
\newcommand{\ct}[1]{\tabular[t]{@{}c@{}}#1\endtabular} –  egreg Dec 2 '12 at 20:45
Ah, i already tried that before but i didnt realize that u can always adjust the arraystretch before a \tabular env. Therefore i can use your snippet and place e.g \renewcommand*{\arraystretch}{1}within. For the rest i can leave another arraystretch value active. –  bioslime Dec 2 '12 at 20:48
Mh unfortunately, that didnt work out as i thought. I updated my post. –  bioslime Dec 2 '12 at 21:04
Why are you enclosing each table cell in braces? It's surely not necessary. –  egreg Dec 2 '12 at 21:07

You have to reset \arraystretch, but also to add some depth at the end of the multiline entries. Here's a way:

\documentclass{article}
\usepackage{booktabs}

\makeatletter
\newcommand{\ct}[1]{%
\edef\ct@depth{\the\dp\@arstrutbox}%
\renewcommand{\arraystretch}{1}%
\tabular[t]{@{}c@{}}#1\vrule width\z@ depth\ct@depth\relax\endtabular}
\makeatother

\begin{document}
\renewcommand\arraystretch{2}
\begin{tabular}{ccc}
\toprule
Data & \ct{aa \\aaaaa}  & \ct{A nice heading \\is worth (\%)\\alot} \\
\midrule
1 & 2 & 3 \\
4 & 5 & 6 \\
\bottomrule
\end{tabular}
%%% The following one is for comparison
\begin{tabular}{ccc}
\toprule
Data & aa & alot \\
\midrule
1 & 2 & 3 \\
4 & 5 & 6 \\
\bottomrule
\end{tabular}
\end{document}

However my advice is not to set \arraystretch to big values; better not to set it at all.

-