I am trying to make the table with automatically centered, rotated multirow cells. Something like in the picture, but with cells automatically fitted to their content:
I tried to apply solutions given by @AboAmmar and @Seong, but these not ensure vertical centering within the specified number of rows. This answer is unclear, because \multirow
command under makecell
package accepts non-integer value of number of rows (?). Here is given some code, but the problem is that this engages fixed value (in \raisebox
argument) which is proper only for one specific cell content. The most similar question is without answer.
In fact I need some function which should be named \multirowrothead
- as a combination of \multirowthead
and \rothead
functions of the makecell
package.
My code:
\documentclass[table]{standalone}
\usepackage{siunitx}
\usepackage{makecell}
\usepackage{xcolor}
\usepackage{multirow}
\usepackage{hhline}
\renewcommand{\theadfont}{\normalsize\bfseries}
\renewcommand{\arraystretch}{1.3}
\begin{document}
\begin{tabular}{
|l|
S[table-format=2.1]|
S[table-format=1.2]|
S[table-format=2.1]|
S[table-format=1.2]|
S[table-format=2.1]|
S[table-format=1.2]|
}
\hline
% https://tex.stackexchange.com/questions/246889/how-to-color-column-heads-determined-width-makecell
\rowcolor{gray}
\multicolumn{3}{|c|}{\colorbox{gray}{\thead{First title in heading}}} &
\multicolumn{2}{c|}{\colorbox{gray}{\thead{Second title\\in heading}}} & &\\
\hhline{>{\arrayrulecolor{black}}|-----|>{\arrayrulecolor{gray}}-%
>{\arrayrulecolor{black}}|>{\arrayrulecolor{gray}}->{\arrayrulecolor{black}}|%
}
\rowcolor{gray}
& & & & \colorbox{gray}{\thead{data\\description}} &
{\multirowthead{-2}{Data\\description}} &\\
\hhline{%
>{\arrayrulecolor{black}}|>{\arrayrulecolor{gray}}-%
>{\arrayrulecolor{black}}|>{\arrayrulecolor{gray}}-%
>{\arrayrulecolor{black}}|>{\arrayrulecolor{gray}}-%
>{\arrayrulecolor{black}}|>{\arrayrulecolor{gray}}-%
>{\arrayrulecolor{black}}|-|-|%
>{\arrayrulecolor{gray}}->{\arrayrulecolor{black}}|%
}
\rowcolor{gray}
\colorbox{gray}{\multirowthead{-2}{side-heading\\description}} &
\colorbox{gray}{\multirowthead{-2}{data\\description}} &
\colorbox{gray}{\multirowthead{-2}{data\\description}} &
\colorbox{gray}{\multirowthead{-2}{data\\description}} &
\colorbox{gray}{\thead{A}} & \colorbox{gray}{\thead{B}} &
\colorbox{gray}{\multirowthead{-3}{Data description}}\\
\hline
Description 1 & 63.5 & 4.87 & 63.5 & 4.87 & 63.5 & 4.87\\
\hline
Description 2 & 88.4 & 5.13 & 88.4 & 5.13 & 88.4 & 5.13\\
\hline
\end{tabular}
\end{document}
a
smaller how will the wordDescription
fit in the first row – js bibra Sep 16 '20 at 5:06