Latex: Table: Problems with Rotated Text in stacked multirow commands

3.4k views Asked by At

Result

Currently I am working on a Latex table which uses multiple stacked multirow commands in combination with rotated text. I am not able to automaticcaly change the height of the lines corresponding the rotated text for stacked multirow commands. I have used the following code:

\documentclass{book}
\usepackage{rotating}

\usepackage{array,multirow,graphicx}
\usepackage{tabularx}


\newcommand{\STAB}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}

\begin{document}
\begin{table}
    \centering
    \caption{lala}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
        \hline  
    \multicolumn{3}{|c|}{Test}& \multicolumn{1}{c|}{Test}& \multicolumn{6}{c|}{Test}\\  
    \hline
       \STAB{\rotatebox[origin=c]{90}{ Long word }}&\STAB{\rotatebox[origin=c]{90}{Long word }}&\STAB{\rotatebox[origin=c]{90}{Long word }}&
    Long word &\STAB{\rotatebox[origin=c]{90}{Long word }}&\STAB{\rotatebox[origin=c]{90}{Long word l}}&
    \STAB{\rotatebox[origin=c]{90}{Long word }}&\STAB{\rotatebox[origin=c]{90}{Long word }}& \STAB{\rotatebox[origin=c]{90}{Long word }}&
    \STAB{\rotatebox[origin=c]{90}{Long word }}\\
    \hline

    \multirow{8}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}&\multirow{5}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}&\multirow{4}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}    &Long Text Tex&X&X&X&$<10$& &Long Text Tex\\\cline{4-10}
                                                                                    &&&Long Text Tex    &  &X& &$10-100$&X&Long Text Tex\\\cline{4-10}
                                                                                    &&&Long Text Tex&  &X& &$10-100$&X&Long Text Tex\\\cline{4-10}
                                                                                    &&&Long Text Tex&&X&X&$>200$&&Long Text Tex\\\cline{3-10}
                                                                                    &&\multirow{1}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}&Word&X&&X&$>100$&&Long Text Tex\\\cline{2-10}

        &\multirow{2}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}&\multirow{2}{*}{\STAB{\rotatebox[origin=c]{90}{Long Word}}}&Long Text Tex&X& & &$10-100$&X&Long Text Tex\\\cline{4-10}
                                                                                    &&&Long Text Tex&&X&&$>200$&&Long Text Tex\\\cline{2-10}
        &\multirow{1}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}&\multirow{1}{*}{\STAB{\rotatebox[origin=c]{90}{Long Word}}}&Long Text Tex&X&X&X&10-100&X&Nein\\
        \hline
        \multirow{4}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}&\multirow{4}{*}{\STAB{\rotatebox[origin=c]{90}{Word}}}&\multirow{4}{*}{\STAB{\rotatebox[origin=c]{90}{Wo}}}  &Long Text Tex      &X& &X&$<10$&X&Long Text Tex\\\cline{4-10}
                                                                                &&&Long Text Tex&X& &X&$10-100$&X&Long Text Tex\\\cline{4-10}       
                                                                                &&&Long Text Texn&X& &(X)&$<1$&&Long Text Tex\\\cline{4-10}
                                                                                &&&Long Text Text&X& &X&$10-100$&X&Long Text Tex\\
        \hline  
\end{tabular}
\end{table}

\end{document}

Which results in the attached image

1

There are 1 answers

0
Phimor On

I modified your example using a spaceholder \dummy as a non-elegant vertical spacing and an optional argument for the \multirow command. E.g. \multirow{8}{*}[-3em]{\rotatebox[origin=c]{90}{Word}} vertically moves the rotated Word by -3em. The result is the picture below.

\documentclass{book}
\usepackage{rotating}
\usepackage{multirow}

\begin{document}
\begin{table}
    \centering
    \caption{lala}
\newcommand{\dummy}{\rule[-1em]{0pt}{3em}}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
        \hline  
    \multicolumn{3}{|c|}{Test}& \multicolumn{1}{c|}{Test}& \multicolumn{6}{c|}{Test}\\  
    \hline
       \rotatebox[origin=c]{90}{Long word} & \rotatebox[origin=c]{90}{Long word} & \rotatebox[origin=c]{90}{Long word}&
    Long word &\rotatebox[origin=c]{90}{Long word}&\rotatebox[origin=c]{90}{Long word}&
    \rotatebox[origin=c]{90}{Long word}&\rotatebox[origin=c]{90}{Long word}& \rotatebox[origin=c]{90}{Long word}&
    \rotatebox[origin=c]{90}{Long word}\\
    \hline

    \multirow{8}{*}[-3em]{\rotatebox[origin=c]{90}{Word}}&\multirow{5}{*}[-1em]{\rotatebox[origin=c]{90}{Word}}&\multirow{4}{*}{\rotatebox[origin=c]{90}{Word}}    &Long Text Text&X&X&X&$<10$& &Long Text Text\\\cline{4-10}
                                                                                    &&&Long Text Text    &  &X& &$10-100$&X&Long Text Text\\\cline{4-10}
                                                                                    &&&Long Text Text&  &X& &$10-100$&X&Long Text Text\\\cline{4-10}
                                                                                    &&&Long Text Text&&X&X&$>200$&&Long Text Text\\\cline{3-10}
\dummy                                                                              &&\rotatebox[origin=c]{90}{Word}&Word&X&&X&$>100$&&Long Text Text\\\cline{2-10}
\dummy        &\multirow{2}{*}[-1em]{\rotatebox[origin=c]{90}{Word}}&\multirow{2}{*}[1em]{\rotatebox[origin=c]{90}{Long Word}}&Long Text Text&X& & &$10-100$&X&Long Text Text\\\cline{4-10}
\dummy                                                                              &&&Long Text Text&&X&&$>200$&&Long Text Text\\\cline{2-10}
\dummy        &\rotatebox[origin=c]{90}{Word}&\rotatebox[origin=c]{90}{Long Word}&Long Text Text&X&X&X&10-100&X&Word\\
        \hline
        \multirow{4}{*}{\rotatebox[origin=c]{90}{Word}}&\multirow{4}{*}{\rotatebox[origin=c]{90}{Word}}&\multirow{4}{*}{\rotatebox[origin=c]{90}{Wo}}  &Long Text Text      &X& &X&$<10$&X&Long Text Text\\\cline{4-10}
                                                                                &&&Long Text Text&X& &X&$10-100$&X&Long Text Text\\\cline{4-10}       
                                                                                &&&Long Text Text&X& &(X)&$<1$&&Long Text Text\\\cline{4-10}
                                                                                &&&Long Text Text&X& &X&$10-100$&X&Long Text Text\\
        \hline  
\end{tabular}
\end{table}

\end{document}

Table with manually adjusted spacing