
제가 사용하면 그럴 것 같습니다>{\columncolor{green!30}}c
그리고\multirow
해당 열에 내용이 있으면 색상이 전경에 표시됩니다.
이 두 테이블의 유일한 차이점은 두 번째 테이블은 >{\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}
of nicematrix
(및 키 )를 사용하면 colortbl-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
컬러 패널은 by desing의 규칙까지 확장됩니다 nicematrix
.
여러 컴파일이 필요합니다( nicematrix
내부적으로 PGF/Tikz 노드를 사용하기 때문에).