[Tex/LaTex] How to make table with rotated table headers in LaTeX

colorrotatingtables

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.

screenshot

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:

enter image description here

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.

Best Answer

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}

enter image description here

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}

enter image description here

Related Question