I want to get my vertical table heading ("Rows") to be centered.
The table looks like this
and it is created with that code:
\documentclass{scrreprt}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{makecell}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabularx}{.3\textwidth}{@{}Y|*{4}{Y}@{}}
\toprule
\multicolumn{2}{c}{} & \multicolumn{3}{c@{}}{\thead{Columns}} \\
\cmidrule(l){3-5}
\multicolumn{2}{c}{} & \thead{X} & \thead{Y} & \thead{Z} \\
\multirow{4}{*}{\rotatebox[origin=c]{90}{\thead{Rows}}}
& \thead{A} & ax & ay & az \\
& \thead{B} & bx & by & bz \\
& \thead{C} & cx & cy & cz \\
& \thead{D} & dx & dy & dz \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
I know that \multirow
has the option [<vmove>]
and with that I could try and play around with some random values to get it looking almost centered. For example with this line \multirow{4}{*}[-.81em]{\rotatebox[origin=c]{90}{\thead{Rows}}}
.
But this will not be exact and always when I add or delete a row, I have to find a new value for the vertical alignment. That can't be the right solution.
What is the proper way to center a multirow table heading? Thank you in advance!