\multirow を使用する場合は前景に \columncolor を使用します

\multirow を使用する場合は前景に \columncolor を使用します

どうやら私が使うと>{\columncolor{green!30}}c そしてその列にコンテンツがある場合\multirow、その色は前景に表示されます。

これら 2 つの表の唯一の違いは、2 番目の表が>{\columncolor{green!30}}最初の列に適用されているのに対し、最初の表は適用されていないことです。

ここに画像の説明を入力してください

コード:

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

答え1

\multirow一番下の行で を使用し、負の行数を指定することで、必要なものを取得できます。

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

ここに画像の説明を入力してください

答え2

(およびキー){NiceTabular}を使用すると、期待される結果が直接得られます。nicematrixcolortbl-like

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

booktabs色付きのパネルは、 の設計によりのルールまで拡張されますnicematrix

複数のコンパイルが必要です (nicematrix内部で PGF/Tikz ノードが使用されるため)。

上記コードの出力

関連情報