# Sideways (rotated 90 degrees) label for table

How can I create the following table in LaTeX? I created the table below using PowerPoint.

Here is my best attempt at using LaTeX to create the table:

\begin{tabular}{l|l|l|}
\cline{2-3}
& \multicolumn{2}{|c|}{Returning Week} \\ \cline{2-3}
& 1 & 2 \\ \hline
\multicolumn{1}{|l|}{1} & 0.3 & 0.2 \\ \hline
\multicolumn{1}{|l|}{2} & 0.1 & 0.1 \\ \hline
\end{tabular}


and the output

Similar tex.stackexchange posts:

• From the first linked question, all you need is the rotating package and its sideways environment. Please add your code for the table (without the rotated label, of course). Aug 22, 2013 at 16:53
• @karlkoeller Done! It does look ugly that the columns 1 and 2 have different widths. How should I fix that? Aug 22, 2013 at 18:41

\documentclass{article}
\usepackage{rotating}
\begin{document}
\raisebox{-.2in}{\rotatebox{90}{Arriving Week}}
\renewcommand\arraystretch{1.2}
\begin{tabular}[b]{p{0.8in}|p{0.8in}|p{0.8in}|}
\cline{2-3}
& \multicolumn{2}{|c|}{Returning Week} \\ \cline{2-3}
& 1 & 2 \\ \hline
\multicolumn{1}{|l|}{1} & 0.3 & 0.2 \\ \hline
\multicolumn{1}{|l|}{2} & 0.1 & 0.1 \\ \hline
\end{tabular}
\end{document}


Similar to Steven's solution, but reproduces almost exactly the table in your image.

You have to compile it with xelatex.

\documentclass{article}

\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Calibri}

\renewcommand\arraystretch{1.15}

\begin{document}

\raisebox{-1.4cm}{\rotatebox{90}{Arriving Week}}\hspace{3pt}
\begin{tabular}{|p{2.5cm}|p{2.5cm}|p{2.5cm}|}
\multicolumn{1}{l}{}  & \multicolumn{2}{l}{\hspace{1.1cm}Returning Week} \\ \cline{2-3}
\multicolumn{1}{l|}{} & 1 & 2 \\ \hline
1 & 0.3 & 0.2 \\ \hline
2 & 0.1 & 0.1 \\ \hline
\end{tabular}

\end{document}


You can easily construct that tabular with {NiceTabular} of nicematrix.

\documentclass{article}

\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}{*{3}{w{c}{2cm}}}[first-col,first-row,hvlines,corners=NW]
& & \Block{1-2}{Returning week} \\
\Block{3-1}<\rotate>{Arriving week}& & 1 & 2 \\
& 1 & 0.3 & 0.2 \\
& 2 & 0.1 & 0.1 \\
\end{NiceTabular}

\end{document}


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