# [Tex/LaTex] Rotated column titles in tabular

rotatingtables

I'd like to create a chart where the column titles are rotated, as per this toy example:

I used the rotating package to generate the above. It has certain shortcomings: the rotate command doesn't leave space for the titles, so I have to manually space things to prevent overlaps. The turn command, by contrast, creates too much space, where each column is the width of the entire rotated column title.

There is also no easy way to have long titles be split into multiple lines.

Is there a package for creating tables of this sort, or at least one that would relieve some of the manual placing and spacing that goes into creating such a table?

This question is more to make sure I don't miss any easy way of doing what I want than seeking help on manually doing it, but the code for above is included anyways:

\begin{tabular}{r|ccc}
&
\begin{rotate}{60} Property 1 \end{rotate} &
\begin{rotate}{60} Property 2 \end{rotate} &
\begin{rotate}{60} Property 3 \end{rotate} \\ \hline
System 1        &       &       &  X    \\
System 2        & X     & X     &  X    \\
System 3        & X &   &  X    \\ \hline
\end{tabular}


You can use the adjustbox package to rotate the content and limit it official width. I would also recommend to use a separate \newcolumntype for it as well as a \rot macro which inserts the required \multicolumn command. You won't avoid that one. However, such a macro must be fully expandable and start directly with \multicolumn. If you want multi line headings add the minipage=<width> option to \adjustbox.

\documentclass{article}

\usepackage{array}

\newcolumntype{R}[2]{%
l%
<{\egroup}%
}
\newcommand*\rot{\multicolumn{1}{R{45}{1em}}}% no optional argument here, please!

\begin{document}

\begin{tabular}{r|ccc}
&
\rot{Property 1} &
\rot{Property 2} &
\rot{Property 3}
\\ \hline
System 1        &       &       &  X    \\
System 2        & X     & X     &  X    \\
System 3        & X &   &  X    \\ \hline
\end{tabular}

\renewcommand*\rot{\multicolumn{1}{R{60}{1em}}}% no optional argument here, please!

\begin{tabular}{r|ccc}
&
\rot{Property 1} &
\rot{Property 2} &
\rot{Property 3}
\\ \hline
System 1        &       &       &  X    \\
System 2        & X     & X     &  X    \\
System 3        & X &   &  X    \\ \hline
\end{tabular}

\renewcommand*\rot[2]{\multicolumn{1}{R{#1}{#2}}}% no optional argument here, please!

\begin{tabular}{r|ccc}
&
\rot{90}{1em}{Property 1} &
\rot{60}{1em}{Property 2} &
\rot{45}{2em}{Property 3}
\\ \hline
System 1        &       &       &  X    \\
System 2        & X     & X     &  X    \\
System 3        & X &   &  X    \\ \hline
\end{tabular}

\end{document}