# I can't change \hhline color with \arrayrulecolor{}

I have created a table with tabular and cellcolor, and you know what hapends: the cell color overlap the border.

I have found that this is often solved with hhline. In order to change the color in lines over colored cells I've read that it's useful to use arrayrulecolor. In other words, to avoid this:

The previous table is defined by the following LaTex code:

\begin{table}[h]
\centering
\setlength\arrayrulewidth{0.8pt}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hhline{-------}

\rowcolor[HTML]{EFEFEF} \cellcolor[HTML]{EFEFEF} & \cellcolor[HTML]{EFEFEF} & \cellcolor[HTML]{EFEFEF} &
\multicolumn{4}{c|}{\cellcolor[HTML]{EFEFEF}\textbf{Acción}} \\

\hhline{~~~----}

\rowcolor[HTML]{EFEFEF} \multirow{-2}{*}{\cellcolor[HTML]{EFEFEF}\textbf{$n_{d}$}} &
\multirow{-2}{*}{\cellcolor[HTML]{EFEFEF}\textbf{$n_{o}$}} &
\textbf{Avance} &\textbf{Retroceso} &
\textbf{\begin{tabular}[c]{@{}c@{}}Giro\\ Antihorario\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}Giro\\ Horario\end{tabular}} \\

\hhline{-------}

\cellcolor[HTML]{FFF1F1} 0 & \cellcolor[HTML]{FFF1F1}\textbf{0} & \cellcolor[HTML]{FFF1F1}\textbf{0} &
\textit{0} & \textit{0} & \textit{0} & \textit{0} \\

\hhline{~------}

\cellcolor[HTML]{FFF1F1} & \cellcolor[HTML]{FFF1F1}\textbf{1} & \cellcolor[HTML]{FFF1F1}\textbf{1} &
\textit{0} & \textit{0} & \textit{0} & \textit{0} \\

\hhline{-------}
\end{tabular}
\end{table}


I've try to avoid the white lines (without success) using this:

\definecolor{tgray}{HTML}{EFEFEF}
\definecolor{tblack}{HTML}{000000}

[...]

\hhline{>{\arrayrulecolor{tgray}}->{\arrayrulecolor{tgray}}->{\arrayrulecolor{tgray}}->{\arrayrulecolor{tblack}}----}


The result is a whole black line:

As you can see, my problem is not solve with arrayrulecolor. Do you know how to make this successfully?

Even so, if you know another way to make tables which don't depends on the pdf viewer (with the solution I exposed here, with some levels of ZOOM some lines still don't apperar), it would be too profitable to me.

Thanks.

I have edited this answer because, with the latest version of nicematrix (5.6), we don't need makecell any longer here.

You can easily do that with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{nicematrix}

\begin{document}

\NiceMatrixOptions{cell-space-top-limit=2pt,cell-space-bottom-limit=1pt}

\begin{NiceTabular}{ccccccc}[hvlines]
\CodeBefore
\rowcolor{Gainsboro!50}{1,2}
\rectanglecolor{MistyRose!50}{3-1}{4-3}
\Body
\Block{2-1}{$n_d$}&\Block{2-1}{$n_0$}& \Block{2-1}{Estado} & \Block{1-4}{Acción} \\
&&& Avance & Retroceso & \Block{}{Giro\\ Antihorario} & \Block{}{Giro\\Horario} \\
\Block{2-1}{0}
& 0 & 0 & 0 & 0 & 0 & 0 \\
& 1 & 1 & 0 & 0 & 0 & 0 \\
\end{NiceTabular}
\end{document}

• In {NiceTabular}, you can merge cells with \Block, both horizontally and vertically.

• You can also use \Block for only one cell if you want to use \\.

• With the key hvlines, you draw all the rules excepted in the blocks.

• You have tools to color, rows columns and cells. With these tools, you won't have artefacts in some PDF viewers as you have sometimes with the tools of colortbl.

• wow This solve all my problems with tables, thanks so much! – franarx Aug 4 '20 at 10:42

Here's how to do it with hhline. I replaced, for the coloured part of the lines, your colours with named colours from svgnames (nearly the same as yours) to have a shorter code.

\documentclass{article}
\usepackage{array, multirow}
\usepackage[table, svgnames]{xcolor}
\usepackage{hhline}
\newcommand*{\arb}{\arrayrulecolor{black}}
\newcommand*{\argr}{\arrayrulecolor{Gainsboro!50}}

\begin{document}

\begin{table}[h]
\centering
\setlength\arrayrulewidth{0.8pt}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hhline{-------}

\rowcolor{Gainsboro!50} & & &
\multicolumn{4}{c|}{\textbf{Acción}} \\%[HTML]{EFEFEF}r[HTML]{EFEFEF} \cellcolor[HTML]{EFEFEF}

\hhline{|>{\argr}->{\arb}|>{\argr}->{\arb}|>{\argr}->{\arb}|----|}

\rowcolor{Gainsboro!50} \multirow{-2}{*}{\textbf{$n_{d}$}} &
\multirow{-2}{*}{\textbf{$n_{o}$}} &
\textbf{Avance} &\textbf{Retroceso} &
\textbf{\begin{tabular}[c]{@{}c@{}}Giro\\ Antihorario\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}Giro\\ Horario\end{tabular}} \\

\hhline{-------}

\cellcolor[HTML]{FFF1F1} 0 & \cellcolor[HTML]{FFF1F1}\textbf{0} & \cellcolor[HTML]{FFF1F1}\textbf{0} &
\textit{0} & \textit{0} & \textit{0} & \textit{0} \\

\hhline{|>{\arrayrulecolor{MistyRose!50}}->{\arb}|------}

\cellcolor[HTML]{FFF1F1} & \cellcolor[HTML]{FFF1F1}\textbf{1} & \cellcolor[HTML]{FFF1F1}\textbf{1} &
\textit{0} & \textit{0} & \textit{0} & \textit{0} \\

\hhline{-------}
\end{tabular}
\end{table}

\end{document}