如何使用 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}