0

How to change highlighted portion of vertical line black or different color of each vertical line in the cell using hhline? Please find MWE file:

enter image description here

\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

The >{\arrayrulecolor{<color>}} can be used before vline tabular preambles like |.

In the following example, I set all three vlines in yellow.

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

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.