62

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.
Moriambar
  • 11,466
jlconlin
  • 10,172
  • 5
    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
  • 12
    Did you searched for suitable similar questions? Rowcoloring and rotating should be already covered. – Martin Scharrer Feb 15 '13 at 18:03
  • 2
    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. – nonsense 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? – jlconlin Feb 16 '13 at 00:33
  • I tried using your code and I kept getting unrecognized command errors (so I presume it does not survive entering an \input), so I substituted it directly in the table (a longtable, in fact). Like this: \multicolumn{1}{>{\adjustbox{angle=90,lap=\width-(1em)}\bgroup}<{\egroup}}{\textbf{Header1}}& And this yields: ! Package array Error: <{..} at wrong position: changed to !{..}. – Urhixidur Apr 21 '22 at 20:45

4 Answers4

63

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

Moriambar
  • 11,466
29

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}

Table

  • 4
    +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. – yannisl Feb 16 '13 at 09:15
26

I had made a similar table for my use.

enter image description here

\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}
Moriambar
  • 11,466
mythealias
  • 3,621
  • Is there a way to apply this to rotated cells at the very bottom of the table? – oarfish Apr 06 '16 at 15:42
  • The only thing I really do not like with your approach is that you have with multiple line boxes a bad alignment of the header! – TimK Feb 05 '17 at 11:21
3

You can easily create that table with {NiceTabular} of nicematrix (≥ 6.22 of 2023-08-14).

\documentclass{article}
\usepackage{booktabs}
\usepackage{nicematrix}

\begin{document}

\begin{table} \centering \begin{NiceTabular}{cl{10}{c}} & & \Block{1-10}{Knowledge Areas} \[1mm] \RowStyle{\rotate} & & Integration & Scope & Time & Cost & Quality & Human Resource & Communication & Risk & Procurement & \Block{}{Stakeholder \ Management} \ \midrule \Block{-1}{\rotate Processes} & Initiating & * & & & & & & * & & & * \ & Planning & * & * & * & * & * & * & * & * & * & * \ & Executing & * & & & & * & * & * & & * & * \ & Monitoring and Control & * & * & * & * & * & & * & * & * & * \ & Closing & * & & & & & & * & & * & * \ \bottomrule \end{NiceTabular} \caption{Some caption} \end{table}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

F. Pantigny
  • 40,250