
Es scheint, dass wenn ich>{\columncolor{green!30}}c
UndWenn sich in dieser Spalte Inhalt befindet \multirow
, landet die Farbe im Vordergrund.
Der einzige Unterschied zwischen diesen beiden Tabellen besteht darin, dass die zweite >{\columncolor{green!30}}
auf die erste Spalte angewendet wird und die erste Tabelle nicht.
Code:
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{multirow}
\newcommand*{\MyTabelContent}{%
\toprule
&$+$ & 0 & 1 & 2 & 3 & 4 & 5
\\
\multirow{6}{*}{\rotatebox{90}{Label}}
&0 & & & & & &
\\
&1 & & & & & &
\\
&2 & & & & & &
\\
&3 & & & & & &
\\
&4 & & & & & &
\\
&5 & & & & & &
\\
\bottomrule
}
\begin{document}
\noindent
\begin{tabular}{c >{\columncolor{cyan!30}}cccccc c @{}}
\MyTabelContent
\end{tabular}
\quad
\begin{tabular}{>{\columncolor{green!30}}c >{\columncolor{cyan!30}}cccccc c @{}}
\MyTabelContent
\end{tabular}%
\end{document}
Antwort1
Sie erhalten das gewünschte Ergebnis, indem Sie es \multirow
in der untersten Zeile verwenden und eine negative Zeilenanzahl angeben.
\documentclass{article}
\usepackage[table]{xcolor} % also loads colortbl
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multirow}
\newcommand*{\MyTabelContent}{%
\toprule
&$+$ & 0 & 1 & 2 & 3 & 4 & 5
\\
&0 & & & & & &
\\
&1 & & & & & &
\\
&2 & & & & & &
\\
&3 & & & & & &
\\
&4 & & & & & &
\\
\multirow{-6}{*}{\rotatebox{90}{Label}}
&5 & & & & & &
\\
\bottomrule
}
\begin{document}
\noindent
\begin{tabular}{c >{\columncolor{cyan!30}}cccccc c @{}}
\MyTabelContent
\end{tabular}
\quad
\begin{tabular}{>{\columncolor{green!30}}c >{\columncolor{cyan!30}}cccccc c @{}}
\MyTabelContent
\end{tabular}%
\end{document}
Antwort2
Mit {NiceTabular}
of nicematrix
(und der Taste colortbl-like
) erhalten Sie direkt das erwartete Ergebnis.
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{nicematrix}
\newcommand*{\MyTabelContent}{%
\toprule
&$+$ & 0 & 1 & 2 & 3 & 4 & 5
\\
\multirow{6}{*}{\rotatebox{90}{Label}}
&0 & & & & & &
\\
&1 & & & & & &
\\
&2 & & & & & &
\\
&3 & & & & & &
\\
&4 & & & & & &
\\
&5 & & & & & &
\\
\bottomrule
}
\begin{document}
\noindent
\begin{NiceTabular}{c >{\columncolor{cyan!30}}ccccccc@{}}[colortbl-like]
\MyTabelContent
\end{NiceTabular}
\quad
\begin{NiceTabular}{>{\columncolor{green!30}}c >{\columncolor{cyan!30}}ccccccc@{}}[colortbl-like]
\MyTabelContent
\end{NiceTabular}%
\end{document}
Die farbigen Tafeln erstrecken sich bis zu den Regeln der booktabs
Gestaltung von nicematrix
.
Sie benötigen mehrere Kompilierungen (da nicematrix
im Hintergrund PGF/Tikz-Knoten verwendet werden).