# hhline and cell color problems revisited

So, I've read a lot of issues with cell coloring and cell border. I tried to fix them as follows:

I use hhline to print horizontal cell borders.

If I am in the middle of a multirow cell, I print hhline using the same color as the cell. This avoids having white lines in the middle.

However, I still get pale lines running through the middle of my multirow cell. They aren't white, but they are a paler color than the cell.

Here is a MWE.

\documentclass[]{article}

\usepackage{array}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{hhline}

\begin{document}

\begin{tabularx}{1\textwidth}{m{0.333\textwidth} m{0.333\textwidth} m{0.333\textwidth} }

\hhline{---}
\multicolumn{1}{|c|}{\cellcolor[RGB]{255, 255, 0} a cell} &
\multicolumn{1}{c|}{\cellcolor[RGB]{255, 192, 203} middle} &
\multicolumn{1}{c|}{right cell} \tabularnewline

\hhline{|-|-|-|}

\multicolumn{1}{|c|}{\cellcolor[RGB]{255, 255, 0} a cell} &
\multicolumn{2}{c|}{\cellcolor[RGB]{255, 165, 0} } \tabularnewline

\hhline{|-|>{\arrayrulecolor[RGB]{255, 165, 0}}-->{\arrayrulecolor{black}}|}

\multicolumn{1}{|c|}{\cellcolor[RGB]{255, 255, 0} a cell} &
\multicolumn{2}{c|}{\multirow{-2}{*}{\cellcolor[RGB]{255, 165, 0} multirow cell with pale line through the middle}} \tabularnewline

\hhline{|-|--|}

\end{tabularx}

\end{document}


Is this just a problem of my particular pdf viewer? Is there a simple fix?

You get this sort of lines when two colored surfaces touch exactly. And the only way to get rid of them is either to ensure that the surfaces overlap a bit, to paint over the gap, or to have only one surface:

\documentclass[]{article}
\usepackage[table]{xcolor}
\usepackage{tikz}

\begin{document}

{\color{red}\rule{1cm}{1cm}\rule{1cm}{1cm}}

{\color{red}\rule{1cm}{1cm}\hspace{-0.1pt}\rule{1cm}{1cm}}

{\color{red}\rule{1cm}{1cm}\rule{1cm}{1cm}\tikz[overlay]\draw(-1,0)--++(0,1);}

{\color{red}\rule{2cm}{1cm}}

\end{document}


Using \hhline imho doesn't help much as you then have the gaps between the lines and the colored cell. But you can e.g. move the second line a bit up:

\documentclass[]{article}
\usepackage{array}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{hhline,tikz}

\begin{document}

\begin{tabularx}{1\textwidth}{m{0.333\textwidth} m{0.333\textwidth} m{0.333\textwidth} }

\hhline{---}
\multicolumn{1}{|c|}{\cellcolor[RGB]{255, 255, 0} a cell} &
\multicolumn{1}{c|}{\cellcolor[RGB]{255, 192, 203} middle} &
\multicolumn{1}{c|}{right cell} \tabularnewline

\hhline{|-|-|-|}

\multicolumn{1}{|c|}{\cellcolor[RGB]{255, 255, 0} a cell} &
\multicolumn{2}{c|}{\cellcolor[RGB]{255, 165, 0} }
\tabularnewline[-0.5pt] % a a bit up.

\multicolumn{1}{|c|}{\cellcolor[RGB]{255, 255, 0} a cell} &
\multicolumn{2}{c|}{\multirow{-2}{*}{\cellcolor[RGB]{255, 165, 0}multirow cell with pale line through the middle}} \tabularnewline

\hhline{|-|--|}

\end{tabularx}

\end{document}


• I do not understand this part of table \tabularnewline \\[\dimexpr-\normalbaselineskip -0.5pt\relax] % a a bit up.. Is it sufficient just \tabularnewline? – Zarko Feb 27 '17 at 15:07
• @Zarko Sorry this was a remnant of tests with the \hhline in between. Without it one naturally need only one new line. – Ulrike Fischer Feb 27 '17 at 15:11