vertically align rotated text in table
1,535
With a convenient \raisebox
, you can have the rotated text vertically centred. Please don't use the deprecated \bf
. Use \bfseries
or \textbf{…}
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{tabularx, booktabs, rotating, caption}
\begin{document}
\begin{table}
\caption{ bababalbablab}
\setlength{\extrarowheight}{.5ex}
\begin{tabularx}{\linewidth}{*{4}{>{\raggedright\arraybackslash}X}c}%>{\raggedright\arraybackslash}p{3cm}}
\toprule
\multicolumn{1}{c}{\bf{XXX}} & \multicolumn{3}{c}{\bf{XXX}} \\
\cmidrule(lr){11}\cmidrule(lr){24}
\emph{Monday} & \emph{Monday} & \emph{Monday} & \emph{Monday} & \emph{Tuesday} \\
%
\textbf{July} (i.e. Monday, Tuesday Thursday) & \textbf{August} (i.e. Tuesday Saturday Sunday) & \textbf{September} (i.e. Sunday Sunday Sunday)%
& \textbf{October} (i.e. Wednesday Wednesday Wednesday)& \raisebox{0.85\height}{\rotatebox{90}{{\emph {December}}}}
\\\addlinespace
\textbf{February} (i.e. Sunday Sunday Sunday Sunday )& \textbf{January} (i.e. Friday Friday Friday)& \textbf{March} (i.e. Thursday Thursday Thursday) %
& \textbf{November} (i.e. Tuesday Tuesday Tuesday) & \raisebox{0.85\height }{\rotatebox[origin=l]{90}{\emph {December}}} \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
Related videos on Youtube
Author by
Stefan Pinnow
Updated on November 22, 2022Comments

Stefan Pinnow 6 months
I have the following table (see code of working example below). In column 5 there are two cells that include some rotated text. I would like this rotated text to be centered or aligned at the bottom of the cell rather than having it shifted upwards. I've looked at the examples in this forums but couldn't find a solution so far. Any hints? Thanks.
\begin{table}\caption{ bababalbablab} \begin{tabular}{p{3cm}p{3cm}p{3cm}p{3cm}p{0.25cm}} \multicolumn{1}{c}{\bf{XXX}} & \multicolumn{3}{c}{\bf{XXX}} & \\ \emph{Monday} & \emph{Monday} & \emph{Monday} & \emph{Monday} & \emph{Tuesday} \\ {\bf July} (i.e. Monday, tuesday thursday) & {\bf August} (i.e. Tuesday Saturday Sunday) & {\bf September} (i.e. Sunday sunday sunday)& {\bf October} (i.e. Wednesday Wednesday Wednesday )& {\rotatebox{90}{\emph {December}}} \\ {\bf February} (i.e. Sunday Sunday Sunday Sunday )& {\bf January } (i.e. Friday Friday Friday)& {\bf March} (i.e. Thursday Thursday Thursday) & {\bf November} (i.e. Tuesday Tuesday Tuesday ) & {\rotatebox[origin=l]{90}{\emph {December}}} \\ \hline \end{tabular} \end{table}

Steven B. Segletes almost 7 yearsSince all the data in the individual cells are topaligned, using the
[origin=r]
option on\rotatebox
will likewise topalign the rotated material to the top of the cell like all the other columns. To get it centered in the cell, use ac
column for the last column, instead ofp{0.25cm}
.
