Size of the Rotated Table Cells

I want to create a custom table with tabularray package. I have used makecell and rotating packages to rotate some of the table cells. Additionally, the length of the rotated cells are set with \setlength\rotheadsize{} command and as it is expected, it affects all rotated cells. However, I want to set the size individually.

MWE:

\documentclass{article}
\usepackage[paperheight=6in,
paperwidth=5in,
top=10mm,
bottom=20mm,
left=10mm,
right=10mm]{geometry}

\usepackage{tabularx}
\usepackage{tabularray}
\usepackage{makecell}
\usepackage{rotating}

\begin{document}
\begin{table}[ht]
\begin{center}
\begin{talltblr}[
caption = {Example Table},
label = {tbl:example},
]{
width=\linewidth,
colspec={X[1]X[12]|X[1]|X[1]|X[1]|X[1]|},
vline{1}={3-Z}{solid},
vline{2}={3-Z}{solid},
rows = {c},
column{2} = {l},
}
\cline{3-6}
&  & \SetCell[c=4]{c} Some Text \\
\cline{3-6}
&  & Column 1 & Column 2 & Column 3 & Column 4 \\
\cline{1-6}
\SetCell[r=7]{c} Some longer text & Row 1        & X & X &   \\
\cline{2-6}
& Row 2        & X & X &   \\
\cline{2-6}
& Row 3        & X & X &   \\
\cline{2-6}
& Row 4       & X & X & X \\
\cline{2-6}
& Row 5     & X &   & X \\
\cline{2-6}
& Row 6     & X &   & X \\
\cline{2-6}
& Row 7     & X &   & X \\
\hline
\end{talltblr}
\end{center}
\end{table}
\end{document}


When the size is set for the rotated cells in 2nd row, the text in the 1st column becomes multiline. On the other hand, the height of the 2nd column becomes too high, when the size is set according to 1st column.

• Welcome to TeX.SE! Good question! Sep 28, 2022 at 23:12

Using your interesting answer as starting point, the possible (more consistent) solution for your problem can be :

\documentclass{article}
\usepackage{tabularray}
\usepackage{makecell}
\usepackage{rotating}

\begin{document}
\begin{table}[ht]
\caption{Example Table}
\label{tbl:example}
\centering
\begin{tblr}{hline{1,2} = {3-Z}{solid}, vline{1,2} = {3-Z}{solid},
hline{3-Z} = {solid}, vline{3-Z}={solid},
colspec = {c X[l] *{4}{c} },
}
&   & \SetCell[c=4]{c} Some Text
&   &   &           \\
&   & Column 1
& Column 2
& Column 3
& Column 4   \\
\SetCell[r=7]{c}  Some longer text
& Row 1     & X &   &   &   \\
& Row 2     &   & X &   &   \\
& Row 3     &   &   & X &   \\
& Row 4     &   &   &   & X \\
& Row 5     &   &   & X &   \\
& Row 6     &   & X &   &   \\
& Row 7     & X &   &   &   \\
\end{tblr}
\end{table}
\end{document}


which gives

As can be seen, in above MWE in table body is preserved usual way for writing cells contents and command for rotating is merged with settings of rotated cell sizes in table preamble.

Perhaps there is a better solution for this. For the time being, I would simply use \rotatebox[origin=c]{90}{...} in the affected cell

\documentclass{article}
\usepackage[paperheight=6in,
paperwidth=5in,
top=10mm,
bottom=20mm,
left=10mm,
right=10mm]{geometry}

\usepackage{tabularray}
\usepackage{makecell}
\usepackage{rotating}

\begin{document}
\begin{table}[ht]
\begin{center}
\begin{talltblr}[
caption = {Example Table},
label = {tbl:example},
]{
width = 0.8\linewidth,
colspec = {X X[12] *4{X}},
vline{1} = {3-Z}{solid},
vline{2} = {3-Z}{solid},
vline{3-Z} = {},
hline{1,2} = {3-6}{},
hline{3-Z} = {},
rows = {c},
column{2} = {l},
}
&  & \SetCell[c=4]{c} Some Text \\
&  & Column 1 & Column 2 & Column 3 & Column 4 \\
\SetCell[r=7]{} \rotatebox[origin=c]{90}{Some longer text}
& Row 1 & X & X &   &   \\
& Row 2 &   & X & X &   \\
& Row 3 &   & X & X &   \\
& Row 4 &   & X & X & X \\
& Row 5 &   & X &   & X \\
& Row 6 &   & X &   & X \\
& Row 7 &   & X &   & X \\
\end{talltblr}
\end{center}
\end{table}
\end{document}


Instead of using \rothead command as a parameter of cell, I used it in place and gave \setlength and \settowidth commands as a cell parameter.

\documentclass{article}
% Using the geometry package with a small
% page size to create the article graphic
\usepackage[paperheight=6in,
paperwidth=5in,
top=10mm,
bottom=20mm,
left=10mm,
right=10mm]{geometry}

\usepackage{tabularx}
\usepackage{tabularray}
\usepackage{makecell}
\usepackage{rotating}

\begin{document}
\begin{table}[ht]
\begin{center}
\begin{talltblr}[
caption = {Example Table},
label = {tbl:example},
]{
width=\linewidth,
colspec={X[1]X[12]|X[1]|X[1]|X[1]|X[1]|},
vline{1}={3-Z}{solid},
vline{2}={3-Z}{solid},
rows = {c},
column{2} = {l},
}
\cline{3-6}
&  & \SetCell[c=4]{c} Some Text \\
\cline{3-6}
\cline{1-6}
\SetCell[r=7]{c} \rothead{Some longer text} & Row 1        & X & X &   \\
\cline{2-6}
& Row 2        & X & X &   \\
\cline{2-6}
& Row 3        & X & X &   \\
\cline{2-6}
& Row 4       & X & X & X \\
\cline{2-6}
& Row 5     & X &   & X \\
\cline{2-6}
& Row 6     & X &   & X \\
\cline{2-6}
& Row 7     & X &   & X \\
\hline
\end{talltblr}
\end{center}
\end{table}
\end{document}