
我想將對角線顏色更改為白色(在我的情況下是左上角的顏色)。
這是圖像
這是程式碼
\documentclass[12pt, a4paper,twoside]{memoir}
\begin{document}
\setlength{\arrayrulewidth}{1pt}
\setlength{\extrarowheight}{1.2pt}
\arrayrulecolor{white}
\begin{table}[H]
\centering
\caption{Table}
\label{tb35}
\noindent
\begin{tabular}{|r|*{3}{c|}}\hline
\rowcolor{c1}
\backslashbox{\color{c2}Q\\\color{c2}Metric~}{\color{c2}base~~}
& \color{c2}3A & \color{c2}1A & \color{c2}3A \\
\hline
\rowcolor{c1}
\color{c2}Q & & & \\
\hline
\rowcolor{c1}
\color{c2}Proposed & & & \\
\hline
\end{tabular}
\end{table}
\結束{文件}
答案1
黑色對角線設定為目前字體顏色(黑色)。在方塊中,您可以明確設定顏色(c2)。因此,可以透過在 之前添加顏色設定(白色)來擴展此範例\backslashbox
。然後以當前顏色(白色)繪製對角線:
\documentclass[12pt, a4paper,twoside]{memoir}
\usepackage{colortbl}
\usepackage{diagbox}
\definecolor{c1}{rgb}{0,0,1}
\definecolor{c2}{rgb}{1,1,0}
\begin{document}
\setlength{\arrayrulewidth}{1pt}
\setlength{\extrarowheight}{1.2pt}
\arrayrulecolor{white}
\begin{table}[H]
\centering
\caption{Table}
\label{tb35}
\noindent
\begin{tabular}{|r|*{3}{c|}}\hline
\rowcolor{c1}
\color{white}
\backslashbox{\color{c2}Q\\\color{c2}Metric~}{\color{c2}base~~}
& \color{c2}3A & \color{c2}1A & \color{c2}3A \\
\hline
\rowcolor{c1}
\color{c2}Q & & & \\
\hline
\rowcolor{c1}
\color{c2}Proposed & & & \\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
供參考。{NiceTabular}
的環境nicematrix
有自己的內建指令\diagbox
。使用該命令,對角線規則的顏色是表格規則的標準顏色(由 設定\arrayrulecolor
)。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\arrayrulecolor{white}
\begin{NiceTabular}{cccc}[hvlines-except-borders]
\CodeBefore
\arraycolor{blue!30}
\Body
\diagbox{\small R}{\small C} & A & B & C \\
1 \\
2 \\
3 \\
\end{NiceTabular}
\end{document}