5

I'm having issues with my tables, specifically with alternating row colors. In my tables, I have a column in which I display the category of the row entry. E.g., for olympic weightlifting, I differentiate between the clean, jerk and snatch. Each category has five rows. When I limit coloring to the header row, everything works out fine. As soon as I expand coloring to all the rows (using the rowcolors command), the content of that first column gets overwritten (probably something with the z buffer). Can anyone point me into the right direction here? Any help is appreciated.

\usepackage[table]{xcolor}

\definecolor{weis}{rgb}{1.0,1.0,1.0}
\definecolor{dunkelgrau}{rgb}{0.8,0.8,0.8}
\definecolor{hellgrau}{rgb}{0.95,0.95,0.95}

\rowcolors{1}{weis}{hellgrau}

\begin{table}[tb]
    \centering
    \begin{tabular}{|p{0.02\textwidth}|p{0.02\textwidth}|p{0.4\textwidth}p{0.05\textwidth}p{0.25\textwidth}p{0.05\textwidth}|}\hline
        \rowcolor{dunkelgrau}& \# & Warmup & Seite &Training & Seite\\ \hline
        \multirow{5}{*}{\rotatebox[origin=c]{90}{Clean}}
        & 1 & Front Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
        & 2 & Scarecrow Clean (Brust) & \pageref{ex:tbolyscc} & Power Shrug & \pageref{ex:tbolypowershrug} \\
        & 3 & Scarecrow Clean (Nabel) & \pageref{ex:tbolyscc} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
        & 4 & Scarecrow Clean (Hüfte) & \pageref{ex:tbolyscc} & Clean High Pull & \pageref{ex:tobohcp} \\
        & 5 & \multicolumn{3}{c}{Hang Power Clean} & \pageref{ex:tbbbhpc}\\ \hline
        
        \multirow{5}{*}{\rotatebox[origin=c]{90}{Snatch}}
        & 1 & Overhead Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
        & 2 & Drop Snatch & \pageref{ex:tboolyds} & Power Shrug & \pageref{ex:tbolypowershrug}\\
        & 3 & Snatch Balance & \pageref{ex:tboolysb} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
        & 4 & Scarecrow Snatch & \pageref{ex:tboolyscs} & Snatch High Pull & \pageref{ex:tobohcp}\\ 
        & 5 & \multicolumn{3}{c}{Hang Power Snatch} & \pageref{ex:tbbbhps}\\ \hline
        
        \multirow{5}{*}{\rotatebox[origin=c]{90}{Jerk}}
        & 1 & Overhead Reverse Lunge & \pageref{ex:lbpasohsrevlunge} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
        & 2 & Behind the Neck Drop Jerk & \pageref{ex:tbolybtndj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
        & 3 & Drop Jerk & \pageref{ex:tbolydj} & Split Squat Jump & \pageref{ex:lbpsasssj} \\
        & 4 & Behind the Neck Split Jerk & \pageref{ex:tbolybtnsj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\ 
        & 5 & \multicolumn{3}{c}{Split Jerk} & \pageref{ex:tbolysj}\\ \hline
        
    \end{tabular}
\caption[Some Caption}
\label{some Label}
\end{table}

Result without the rowcolor command

Result with the rowcolor command

1
  • 2
    Where the problem lies is not very clear to me. You posted two imagess. Is the second what you'd like to obtain, and the first what you actually get? Also, what does tabularx have to do with your problem? – Bernard Dec 8 '20 at 16:20
1

I guess, you're interested in using \multirow{-5} instead of \multirow{5} to place the rotated text on top of the row colors. I also switched to tabularx to avoid manual calculation of column widths:

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{multirow}
\usepackage[table]{xcolor}

\definecolor{weis}{rgb}{1.0,1.0,1.0}
\definecolor{dunkelgrau}{rgb}{0.8,0.8,0.8}
\definecolor{hellgrau}{rgb}{0.95,0.95,0.95}

\begin{document}
\rowcolors{1}{weis}{hellgrau}
\begin{table}[tb]
    \centering
    \begin{tabularx}{\textwidth}{|l|l|Xlll|}\hline
        \rowcolor{dunkelgrau}& \# & Warmup & Seite &Training & Seite\\ \hline
        
        & 1 & Front Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
        & 2 & Scarecrow Clean (Brust) & \pageref{ex:tbolyscc} & Power Shrug & \pageref{ex:tbolypowershrug} \\
        & 3 & Scarecrow Clean (Nabel) & \pageref{ex:tbolyscc} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
        & 4 & Scarecrow Clean (Hüfte) & \pageref{ex:tbolyscc} & Clean High Pull & \pageref{ex:tobohcp} \\
        \multirow{-5}{*}{\rotatebox[origin=c]{90}{Clean}} 
        & 5 & \multicolumn{3}{c}{Hang Power Clean} & \pageref{ex:tbbbhpc}\\ \hline
               
        & 1 & Overhead Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
        & 2 & Drop Snatch & \pageref{ex:tboolyds} & Power Shrug & \pageref{ex:tbolypowershrug}\\
        & 3 & Snatch Balance & \pageref{ex:tboolysb} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
        & 4 & Scarecrow Snatch & \pageref{ex:tboolyscs} & Snatch High Pull & \pageref{ex:tobohcp}\\ 
        \multirow{-5}{*}{\rotatebox[origin=c]{90}{Snatch}} 
        & 5 & \multicolumn{3}{c}{Hang Power Snatch} & \pageref{ex:tbbbhps}\\ \hline
        
        
        & 1 & Overhead Reverse Lunge & \pageref{ex:lbpasohsrevlunge} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
        & 2 & Behind the Neck Drop Jerk & \pageref{ex:tbolybtndj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
        & 3 & Drop Jerk & \pageref{ex:tbolydj} & Split Squat Jump & \pageref{ex:lbpsasssj} \\
        & 4 & Behind the Neck Split Jerk & \pageref{ex:tbolybtnsj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\ 
        \multirow{-5}{*}{\rotatebox[origin=c]{90}{Jerk}} 
        & 5 & \multicolumn{3}{c}{Split Jerk} & \pageref{ex:tbolysj}\\ \hline
        
    \end{tabularx}
\caption{Some Caption}
\label{some Label}
\end{table}


\rowcolors{1}{weis}{hellgrau}
\begin{table}[tb]
    \centering
    \begin{tabularx}{\textwidth}{|l|l|Xlll|}\hline
        \rowcolor{dunkelgrau}& \# & Warmup & Seite &Training & Seite\\ \hline
        
        \cellcolor{weis} & 1 & Front Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
        \cellcolor{weis}& 2 & Scarecrow Clean (Brust) & \pageref{ex:tbolyscc} & Power Shrug & \pageref{ex:tbolypowershrug} \\
        \cellcolor{weis}& 3 & Scarecrow Clean (Nabel) & \pageref{ex:tbolyscc} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
        \cellcolor{weis}& 4 & Scarecrow Clean (Hüfte) & \pageref{ex:tbolyscc} & Clean High Pull & \pageref{ex:tobohcp} \\
        \cellcolor{weis}\multirow{-5}{*}{\rotatebox[origin=c]{90}{Clean}} 
        & 5 & \multicolumn{3}{c}{Hang Power Clean} & \pageref{ex:tbbbhpc}\\ \hline
               
        \cellcolor{weis}& 1 & Overhead Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
        \cellcolor{weis}& 2 & Drop Snatch & \pageref{ex:tboolyds} & Power Shrug & \pageref{ex:tbolypowershrug}\\
        \cellcolor{weis}& 3 & Snatch Balance & \pageref{ex:tboolysb} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
        \cellcolor{weis}& 4 & Scarecrow Snatch & \pageref{ex:tboolyscs} & Snatch High Pull & \pageref{ex:tobohcp}\\ 
        \multirow{-5}{*}{\rotatebox[origin=c]{90}{Snatch}} 
        \cellcolor{weis}& 5 & \multicolumn{3}{c}{Hang Power Snatch} & \pageref{ex:tbbbhps}\\ \hline
        
        
        \cellcolor{weis}& 1 & Overhead Reverse Lunge & \pageref{ex:lbpasohsrevlunge} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
        \cellcolor{weis}& 2 & Behind the Neck Drop Jerk & \pageref{ex:tbolybtndj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
        \cellcolor{weis}& 3 & Drop Jerk & \pageref{ex:tbolydj} & Split Squat Jump & \pageref{ex:lbpsasssj} \\
        \cellcolor{weis}& 4 & Behind the Neck Split Jerk & \pageref{ex:tbolybtnsj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\ 
        \cellcolor{weis}\multirow{-5}{*}{\rotatebox[origin=c]{90}{Jerk}} 
        & 5 & \multicolumn{3}{c}{Split Jerk} & \pageref{ex:tbolysj}\\ \hline
        
    \end{tabularxx}
\caption{Some Caption}
\label{some Label}
\end{table}

\end{document}
1
  • Brilliant, that solved it! Thank you very much! – Lukas Pezenka Dec 8 '20 at 19:27
1

Here is how you can do that with the latest version of nicematrix (v. 5.8 of 2021-01-01).

\documentclass{article}
\usepackage{nicematrix}
\usepackage{xcolor}

\definecolor{weis}{rgb}{1.0,1.0,1.0}
\definecolor{dunkelgrau}{rgb}{0.8,0.8,0.8}
\definecolor{hellgrau}{rgb}{0.95,0.95,0.95}

\begin{document}

\begin{table}[tb]
\centering
\begin{NiceTabular}{|c|p{0.02\textwidth}|p{0.4\textwidth}p{0.05\textwidth}p{0.25\textwidth}p{0.05\textwidth}|}%
[code-before = { \rowcolor{dunkelgrau}{1}\rowcolors{2}{weis}{hellgrau}[cols=2-]} ]
\Hline
&  & Warmup & Seite &Training & Seite\\ \Hline
\Block{5-1}<\rotate>{Clean}
& 1 & Front Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
& 2 & Scarecrow Clean (Brust) & \pageref{ex:tbolyscc} & Power Shrug & \pageref{ex:tbolypowershrug} \\
& 3 & Scarecrow Clean (Nabel) & \pageref{ex:tbolyscc} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
& 4 & Scarecrow Clean (Hüfte) & \pageref{ex:tbolyscc} & Clean High Pull & \pageref{ex:tobohcp} \\
& 5 & \Block{1-3}{Hang Power Clean} & & & \pageref{ex:tbbbhpc}\\ \Hline
\Block{5-1}<\rotate>{Snatch}
& 1 & Overhead Squat & \pageref{ex:slbpbbfs} & Shrug & \pageref{ex:tbolyshrug}\\
& 2 & Drop Snatch & \pageref{ex:tboolyds} & Power Shrug & \pageref{ex:tbolypowershrug}\\
& 3 & Snatch Balance & \pageref{ex:tboolysb} & Jump Shrug & \pageref{ex:tbolyjumpshrug}\\
& 4 & Scarecrow Snatch & \pageref{ex:tboolyscs} & Snatch High Pull & \pageref{ex:tobohcp}\\ 
& 5 & \Block{1-3}{Hang Power Snatch} & & & \pageref{ex:tbbbhps}\\ \Hline
\Block{5-1}<\rotate>{Jerk}
& 1 & Overhead Reverse Lunge & \pageref{ex:lbpasohsrevlunge} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
& 2 & Behind the Neck Drop Jerk & \pageref{ex:tbolybtndj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\
& 3 & Drop Jerk & \pageref{ex:tbolydj} & Split Squat Jump & \pageref{ex:lbpsasssj} \\
& 4 & Behind the Neck Split Jerk & \pageref{ex:tbolybtnsj} & Split Squat Jump & \pageref{ex:lbpsasssj}\\ 
& 5 & \Block{1-3}{Split Jerk} & & & \pageref{ex:tbolysj}\\ \Hline
\end{NiceTabular}
\label{some Label}
\end{table}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.