Tabularx、rowcolors、表格中的旋转多行文本

Tabularx、rowcolors、表格中的旋转多行文本

我的表格有问题,特别是交替行颜色的问题。在我的表格中,我有一列显示行条目的类别。例如,对于奥运会举重,我区分了挺举和抓举。每个类别有五行。当我将颜色限制在标题行时,一切都正常。一旦我将颜色扩展到所有行(使用 rowcolors 命令),第一列的内容就会被覆盖(可能是 z 缓冲区的问题)。有人能给我指出正确的方向吗?任何帮助我都会很感激。

\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}

没有使用 rowcolor 命令的结果

使用 rowcolor 命令的结果

答案1

我猜,您感兴趣的是使用\multirow{-5}而不是\multirow{5}将旋转的文本放在行颜色之上。我还切换到tabularx以避免手动计算列宽:

在此处输入图片描述

\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}

答案2

nicematrix使用最新版本(2021-08-10 的 v 6.0)执行此操作的方法如下,该版本具有X列 (样式为tabularx)。

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

\begin{document}

\begin{table}[tb]
\centering
\begin{NiceTabular}{|c|c|Xlll|}
\CodeBefore
  \rowcolor[rgb]{0.8,0.8,0.8}{1}
  \rowcolors[rgb]{2}{}{0.95,0.95,0.95}[cols=2-] 
\Body
  \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}

您需要多次编译(因为nicematrix使用 PGF/Tikz 节点)。

上述代码的输出

相关内容