# Rotating text in a table, and getting hlines in the right place.

I have a table where the first line includes quite some text, and then each of the other cells is fairly small (a symbol or two maximum). At the moment, my code looks like this:

\documentclass{standalone}
\usepackage{rotating}
\begin{document}
\begin{tabular}{lrrrrrrrr}
& \begin{rotate}{45}Better measurements\end{rotate} & \begin{rotate}{45}Theory\end{rotate} & \begin{rotate}{45}Intervals\end{rotate}
&\begin{rotate}{45} Ensembles\end{rotate} &\begin{rotate}{45}Training\end{rotate} & \begin{rotate}{45}Robustness\end{rotate}
& \begin{rotate}{45}Past Success\end{rotate} \\
Imprecision & x & y & z & a & b & c & x \\
Inaccuracy & x & y & z & a & b & c &x\\
Deeper & x & y & z & a & b & c &x\\
Parameter & x & y & z & a & b & c&x \\
Structure & x & y & z & a & b & c &x \\
Overfitting& x & y & z & a & b & c&x \\
Discretisation & x & y & z & a & b & c &x\\
Resolution & x & y & z & a & b & c &x\\
Implementation & x & y & z & a & b & c&x \\
\end{tabular}
\end{document}


This uses the rotating package for the turn environment. The problem is that the turn environment does not leave space for the rotated text. (which is good, because the labels "overlap" vertically, which is what I want. However, when I input it in a bigger document the labels overlap the text above. I can just add vspace manually but this is suboptimal. Also, when I try and put hlines at the top, they go through the text. (also, it's not great that I have to put the environment in each table cell in the top row)

Are there package that do a better job of dealing with these sorts of tables?

-
How about a code sample that is compilable? ;-) –  lockstep Feb 27 '11 at 18:35
@lockstep how about you add the three lines yourself –  Seamus Feb 27 '11 at 20:50
Four lines. ;-) –  lockstep Feb 27 '11 at 20:53

\documentclass{article}
\usepackage{rotating}
\def\Rot#1#2{\rlap{\rotatebox{#1}{#2}~}}
\begin{document}

\hrulefill

\begin{tabular}{*9l}
& \Rot{45}{Better measurements} & \Rot{45}{Theory} & \Rot{45}{Intervals}
& \Rot{45}{Ensembles} & \Rot{45}{Training} & \Rot{45}{Robustness} & \Rot{45}{Past Success} \\
Imprecision & x & y & z & a & b & c & x \\
Inaccuracy & x & y & z & a & b & c &x\\
Deeper & x & y & z & a & b & c &x\\
Parameter & x & y & z & a & b & c&x \\
Structure & x & y & z & a & b & c &x \\
Overfitting& x & y & z & a & b & c&x \\
Discretisation & x & y & z & a & b & c &x\\
Resolution & x & y & z & a & b & c &x\\
Implementation & x & y & z & a & b & c&x \\
\end{tabular}

\end{document}


-
Then I haven't understood how your code is working. Could you explain? –  Seamus Feb 27 '11 at 20:51
Also, \hrulefill doesn't look right if I put a \hline at the bottom inside the tabular... –  Seamus Feb 27 '11 at 20:52
the \hrulefill has nothing to do with the tabular itself ... it shows you the setting of the headers. –  Herbert Feb 27 '11 at 20:56
@Herbert exactly. So if I want a \hline above my table this method won't work, since it relies on things outside the tabular environment for the spacing. –  Seamus Feb 28 '11 at 10:52
@Seamus, again: the \hrulefill has nothing to do with the tabular, it shows only that the top of the table headers do not overwrite the current text above the tabular. If you want a \hline, then use a \hline!!! And if it is too short, then add a dummy column ... –  Herbert Feb 28 '11 at 10:58