[Tex/LaTex] Rotating text in a table, and getting hlines in the right place

rotatingtables

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?

Best Answer

\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}

enter image description here

Related Question