# How to make table with rotated table headers in LaTeX

I saw a table created in PowerPoint and wanted to know how to do it in LaTeX. The table is shown below. The aspects of the table that I'm most interested in are the rotated table headers as well as Knowledge Areas and Process labels outside the table.

Here is what I've come up with so far after seeing Rotated column titles in tabular suggested in the comments (thanks!)

\documentclass{article}
\usepackage{adjustbox}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}

\newcolumntype{R}[2]{%
>{\adjustbox{angle=#1,lap=\width-(#2)}\bgroup}%
l%
<{\egroup}%
}
\newcommand*\rot{\multicolumn{1}{R{90}{1em}}}% no optional argument here, please!

\begin{document}

\begin{table} \centering
\begin{tabular}{clcccccccccc}
& & \multicolumn{10}{c}{Knowledge Areas} \\
& & \rot{Integration} & \rot{Scope} & \rot{Time} & \rot{Cost}
& \rot{Quality} & \rot{Human Resource} & \rot{Communication}
& \rot{Risk} & \rot{Procurement} & \rot{Stakeholder Management} \\
\midrule
\multirow{5}{*}{{Processes}}
& Initiating             & * &   &   &   &   &   & * &   &   & * \\
& Planning               & * & * & * & * & * & * & * & * & * & * \\
& Executing              & * &   &   &   & * & * & * &   & * & * \\
& Monitoring and Control & * & * & * & * & * &   & * & * & * & * \\
& Closing                & * &   &   &   &   &   & * &   & * & * \\
\bottomrule
\end{tabular}
\caption{Some caption}
\end{table}

\end{document}

With the result looking like:

I'm not so concerned about the row coloring (sorry, should have mentioned that before). There are just a few things I don't know how to do:

1. How can I make Stakeholder Management stack on top of each other?
2. How can I rotate Processes on the left-hand side? The \rot command I used in the table header didn't work, presumably because it is in the \multirow command.
-
could you show what you've tried so far? perhaps Rotated Column Titles in Tabular will get you started.... –  cmhughes Feb 15 '13 at 18:03
Did you searched for suitable similar questions? Rowcoloring and rotating should be already covered. –  Martin Scharrer Feb 15 '13 at 18:03
those labels "Knowledge Areas" and "Process" are not really labels, there are just a further row and a further column, respectively. can be done with multirow and multicolumn. And this table has a flaw that I would not want to copy. Stuff should be readable when the head is tilted to the left. Like the process lable. All the stuf in the green part is the wrong way round. –  eject Feb 15 '13 at 19:20
@eject I tried to make the Process label on the left side rotated 90º like the table headers, but got an error. Do you know how to make it work? –  Jeremy Feb 16 '13 at 0:33

## 3 Answers

Using \rlap makes it easier to position text without additional space. And if you want the label "Processes" outside then use \cmidrule{2-12} and \cmidrule[1pt]{2-12} instead.

\documentclass{article}
\usepackage{array,graphicx}
\usepackage{booktabs}
\usepackage{pifont}

\newcommand*\rot{\rotatebox{90}}
\newcommand*\OK{\ding{51}}

\begin{document}

\begin{table} \centering
\begin{tabular}{@{} cl*{10}c @{}}
& & \multicolumn{10}{c}{Knowledge Areas} \\[2ex]
& & \rot{Integration} & \rot{Scope} & \rot{Time} & \rot{Cost}
& \rot{Quality} & \rot{Human Resource} & \rot{Communication}
& \rot{Risk} & \rot{Procurement} & \rot{\shortstack[l]{Stakeholder\\Management}} \\
\cmidrule{2-12}
& Initiating             & \OK &   &   &   &   &   & \OK &   &   & \OK \\
& Planning               & \OK & \OK & \OK & \OK & \OK & \OK & \OK & \OK & \OK & \OK \\
& Executing              & \OK &   &   &   & \OK & \OK & \OK &   & \OK & \OK \\
& Monitoring and Control & \OK & \OK & \OK & \OK & \OK &   & \OK & \OK & \OK & \OK \\
\rot{\rlap{~Processes}}
& Closing                & \OK &   &   &   &   &   & \OK &   & \OK & \OK \\
\cmidrule[1pt]{2-12}
\end{tabular}
\caption{Some caption}
\end{table}

\end{document}

and the same colored:

\documentclass{article}
\usepackage{array,graphicx}
\usepackage{booktabs}
\usepackage{pifont}
\usepackage[table]{xcolor}

\newcommand*\rot{\rotatebox{90}}
\newcommand*\OK{\ding{51}}

\begin{document}

\begin{table} \centering
\begin{tabular}{@{} cr*{10}c }
& & \multicolumn{10}{c}{Knowledge Areas} \\[2ex]
\rowcolor{blue!30} \cellcolor{white}
& & \rot{Integration} & \rot{Scope} & \rot{Time} & \rot{Cost}
& \rot{Quality} & \rot{Human Resource~} & \rot{Communication}
& \rot{Risk} & \rot{Procurement} & \rot{\shortstack[l]{Stakeholder\\Management}} \\
\cmidrule{2-12}
\rowcolor{black!15} \cellcolor{white}
& Initiating   &\OK &    &    &    &    &    &\OK &    &    &\OK \\
& Planning     &\OK &\OK &\OK &\OK &\OK &\OK &\OK &\OK &\OK &\OK \\
\rowcolor{black!15} \cellcolor{white}
& Executing    &\OK &    &    &    &\OK &\OK &\OK &    &\OK &\OK \\
& Monitoring and Control
&\OK &\OK &\OK &\OK &\OK &    &\OK &\OK &\OK &\OK \\
\rowcolor{black!15} \cellcolor{white}
\rot{\rlap{~Processes}}
& Closing      &\OK &    &    &    &    &    &\OK &    &\OK &\OK \\
\cmidrule[1pt]{2-12}
\end{tabular}
\caption{Some caption}
\end{table}

\end{document}

-
You didn't use pstricks? –  Marc van Dongen Feb 16 '13 at 10:41
Very nicely done. –  Jeremy Feb 17 '13 at 3:14
I’d use \cmidrule[\heavyrulewidth]{2-12} for the bottom line to have the same width as \bottomrule. –  Qrrbrbirlbel Feb 17 '13 at 19:26

When I tried to read your table, I found it impossible to read the column headings because of the rotation, which is why I recommend a solution without rotation. All it is is a simple reorganisation of the rows and columns.

It isn't perfect. Perhaps aligning the Processes to the right is better.

You can simplify the table as well because all knowledge areas require planning, so why put it in the table? Just mention it in the caption. Removing the column for planning should make the table less wide, which is always a good thing because it makes it easier to scan the table from left to right and back.

\documentclass{article}
\usepackage{booktabs}
\newcommand*\ON[0]{$\surd$}

\begin{document}

\begin{table}
\begin{center}
\begin{tabular}{@{}lccccc@{}}
& \multicolumn{5}{c}{\textbf{Processes}}
\\  \cmidrule{2-6}
& & & & \textbf{Monitoring}
\\       \textbf{Knowledge Areas}
& \textbf{Initiating}
& \textbf{Planning}
& \textbf{Executing}
& \textbf{\&\ Control}
& \textbf{Costing}
\\ \midrule
\textbf{Integration}    & \ON & \ON & \ON & \ON & \ON
\\ \textbf{Scope}          &     & \ON &     & \ON &
\\ \textbf{Time}           &     & \ON &     & \ON &
\\ \textbf{Cost}           &     & \ON &     & \ON &
\\ \textbf{Quality}        &     & \ON & \ON & \ON &
\\ \textbf{Human Resource} &     & \ON & \ON &     &
\\ \textbf{Communication}  & \ON & \ON & \ON & \ON & \ON
\\ \textbf{Risk}           &     & \ON &     & \ON &
\\ \textbf{Procurement}    &     & \ON & \ON & \ON & \ON
\\ \textbf{Stakeholder
Management}     & \ON & \ON & \ON & \ON & \ON
\\ \bottomrule
\end{tabular}
\caption{Some caption}
\end{center}
\end{table}

\end{document}

-
+1 For not having to turn my head to read anything. To be personally I would have left out the "Processes", as is self-evident. –  Yiannis Lazarides Feb 16 '13 at 9:15

I had made a similar table for my use.

\documentclass[oneside, 10pt, a4paper]{article}

\usepackage{multirow}
\usepackage{graphicx}
\usepackage{booktabs}

\newcommand{\mcrot}[4]{\multicolumn{#1}{#2}{\rlap{\rotatebox{#3}{#4}~}}}

\newcommand*{\twoelementtable}[3][l]%
{%
\renewcommand{\arraystretch}{0.8}%
\begin{tabular}[t]{@{}#1@{}}%
#2\tabularnewline
#3%
\end{tabular}%
}

\begin{document}

\begin{table}[h] \label{tab:activityTracking}
\centering
\caption{Tracking daily activities.}
\begin{tabular}{ *2{ll|} *6c | *6c }
\\
\multicolumn{2}{c}{Date}  & \multicolumn{1}{c}{Start} & \multicolumn{1}{c}{Stop}
& \mcrot{1}{l}{60}{Activity 1} & \mcrot{1}{l}{60}{Analysis} & \mcrot{1}{l}{60}{\twoelementtable{No. of}{processes}} & \phantom{p}& \mcrot{1}{l}{60}{Result} & \mcrot{1}{l}{60}{Backup}
& \mcrot{1}{l}{60}{Activity 2} & \mcrot{1}{l}{60}{Analysis} & \mcrot{1}{l}{60}{\twoelementtable{No. of}{processes}} & \phantom{p} & \mcrot{1}{l}{60}{Result} & \mcrot{1}{l}{60}{Backup} \\
\midrule \midrule

\multirow{4}{*}{\rotatebox{90}{\textbf{January}}}
& 11 & 1:30~am & 10:45~am
& x & x & \multicolumn{2}{c}{-} & - & x
& - & x & \multicolumn{2}{c}{x} & x & x \\
& 12 &          &
& - & - & \multicolumn{2}{c}{x} & - & -
& - & - & \multicolumn{2}{c}{x} & - & - \\
& 13 &          &
& - & - & \multicolumn{2}{c}{x} & - & -
& - & - & \multicolumn{2}{c}{x} & - & - \\
& 14 &          &
& - & - & \multicolumn{2}{c}{-} & - & -
& - & - & \multicolumn{2}{c}{x} & - & - \\
\bottomrule
\end{tabular}
\end{table}

\end{document}
-