如何使用 hhline 將儲存格中垂直線的突出顯示部分變更為黑色或每條垂直線的不同顏色?請找到MWE檔案:
\documentclass{book}
\usepackage{colortbl}
\usepackage{array}
\usepackage{hhline}
\usepackage{ragged2e}
\usepackage[draft]{hyperref}
\usepackage{tabu}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash\hspace{0pt}}p{#1}}%\hangindent6pt
\begin{document}
\begin{tabu}{|L{50pt}|L{50pt}|L{50pt}|L{50pt}|L{50pt}|L{50pt}|}
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
\hhline{>{\arrayrulecolor{blue}}=>{\arrayrulecolor{red}}=>{\arrayrulecolor{yellow}}=>{\arrayrulecolor{green}}==>{\arrayrulecolor{red}}=}
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
%\hhline{|||||>{\arrayrulecolor{blue}}=|||||>{\arrayrulecolor{white}}|>{\arrayrulecolor{black}}|>{\arrayrulecolor{red}}=>{\arrayrulecolor{yellow}}=>{\arrayrulecolor{green}}===}
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
\hhline{|>{\arrayrulecolor{blue}}=|>{\arrayrulecolor{red}}=|>{\arrayrulecolor{blue}}=|>{\arrayrulecolor{red}}=|>{\arrayrulecolor{blue}}=|>{\arrayrulecolor{red}}=|}
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
%\hhline{>{\arrayrulecolor{black}}~~>{\arrayrulewidth3pt}=~~}
Sample 1 &Sample 2 &Sample 3 &Sample 4 &Sample 5&Sample 6\\
\end{tabu}
\end{document}
答案1
可以>{\arrayrulecolor{<color>}}
用在 vline 表格序言之前,例如|
。
在下面的範例中,我將所有三個 vline 設定為黃色。
\documentclass{book}
\usepackage{colortbl}
\usepackage{hhline}
\begin{document}
\setlength{\arrayrulewidth}{2pt} % to highlight array rules
\begin{tabular}{|c|c|}
\hline
a & b \\ \hline
c & d \\
% set all three vlines in yellow
\hhline{
>{\arrayrulecolor{yellow}} |
>{\arrayrulecolor{red}} =
>{\arrayrulecolor{yellow}} |
>{\arrayrulecolor{cyan}} =
>{\arrayrulecolor{yellow}} |
>{\arrayrulecolor{black}}
}
e & f \\ \hline
\end{tabular}
\end{document}