Very thin white line in colortbl

Whenever I use the colortbl package to format tables, a thin white space between the cells sometimes shows up on screen (not in print for as far as I can tell). For example in this table:

Is there an easy way to enlarge each rectangle by a tiny amount so that the white space is not visible anymore?

(My guess is that the white space appears due to rounding in my pdf viewer, evince. I don't know if other pdf viewers have the same issue. Regardless, I would like to have my pdf file look good in common pdf readers)

2 Answers

Yes this is due to the coloured panels being snapped to pixel boundaries.

You can go \\\noalign{\vskip-0.1pt} for a suitably small amount between each row, then the panels will overlap and you are less likely to get a gap. You can add set \extrarowheight to something large to compensate (which is probably a good idea anyway, to keep the capital letters away from the top of the panels)

That is for horizontal lines. For vertical lines \rowcolor has optional arguments to specify optional left and right overhang.

• Awesome, works like a charm! Maybe this could be default behavior of colortbl?
– yori
Apr 27 '12 at 14:51
• Can't really make it the default, it's inherent in the way TeX handles color really, a "small" overlap between tow large panels isn't noticeable but if you have a 0.4pt \hline between them overlapping by 0.1pt is probably too much. You can get the same behaviour without colortbl just use something like \fcolorbox Tex will specify that the coloured panel and the border are adjacent but some viewers my snap them apart by a pixel. Apr 27 '12 at 15:43
• I see. Perhaps a length parameter could be added to the colortbl package, which can be set by the user to enlarge each background by a small overlap?
– yori
Apr 27 '12 at 16:32
• yes that's a possibility, I'll think about it... Apr 27 '12 at 18:33

The package nicematrix provides tools specially designed to solve that problem. The output is perfect in all the PDF viewers, at all levels of zoom.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{xcolor}
\usepackage{amssymb}

\begin{document}
\begin{NiceTabular}{cccwl{8cm}}
\CodeBefore
\columncolor{gray}{1}
\rowcolor{gray}{1}
\rectanglecolor{lightgray}{2-2}{2-4}
\rectanglecolor{lightgray}{2-2}{6-2}
\rectanglecolor{gray}{3-3}{3-4}
\rectanglecolor{gray}{3-3}{7-3}
\cellcolor{black}{7-2,8-2,8-3}
\Body
& \Block[l]{1-3}{\color{white}Property 1} \\
& & \Block[l]{1-2}{Property 2} \\
$\blacktriangledown$ & & & \color{white}Property 3 \\
& $\blacktriangledown$ \\
& & $\blacktriangledown$ & \bfseries Part 1 \\
$\bullet$ & $\bullet$ & $\bullet$ & 1. Step one \\
\hline
$\bullet$ & \color{white} $\bullet$ & $\bullet$ & 2. Step two \\
\hline
$\bullet$ & \color{white} $\bullet$ & \color{white} $\bullet$ & 3. Step three \\
\hline
\end{NiceTabular}

\end{document}