I want to typeset a table with rotatetd column headers (so far it works) stretching over multiple rows.
The problem seems to be that multirow
does not adjust the tables row heights, thus I have to do this by hand, and I struggle with this.
Using a slightly adopted solution from Werner (https://tex.stackexchange.com/a/32687/19326), I get the rotating and can have line breaks.
I now want to calculate the height by which I have to stretch my "stretch column". The value I need to calculate is obviously the height of my rotated box, minus the heights of the rows that I am spanning.
How do I retrieve the height of a row?
What is the easiest way to calculate objectheight - rowheight1 -rowheight2
?
Here is the code I have so far:
\documentclass{report}
\usepackage{xparse}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{pbox}
\usepackage{rotating}
\usepackage{calc}
%\NewDocumentCommand{\rot}{O{90} O{1em} m}{\makebox[#2][l]{\rotatebox{#1}{\pbox[t]{\textwidth}{#3}}}}%
\NewDocumentCommand{\rot}{O{90} O{1em} m}{\makebox[#2][l]{\begin{turn}{#1}{\pbox[t]{\textwidth}{#3}}\end{turn}}}%
\begin{document}
\newlength{\myl}
\settowidth{\myl}{Long Long}
\the\myl
\begin{tabular}{cccc}
\toprule
& \multirow{3}{*}{\rot{Long Long\\ text}}& & \\[\the\myl] %column which I want to stretch
Sample & & \multicolumn{2}{c}{Group} \\
\rot{a} & & A & B \\
\midrule
data & data & data & data \\
\bottomrule
\end{tabular}
\widthof{test}
\end{document}
Note: I would like to use \widthof{test}
since this appears easier to me than the length fiddling, however the \widthof{test}
command actually typesets test
in my case.
I looked at Text in rotated multirow cell crosses table border (Basically where I got the idea to adjust the row height from, however I am not sure that my rowheight will always be \normalbaselineskip
) and How to rotate text in multirow table? which does not help since it is concerned about the positioning of the rotated text rather than stretching the group of rows to accomodate the text.