TransWikia.com

Very thin white line in colortbl

TeX - LaTeX Asked on August 6, 2021

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.

Correct answer by David Carlisle on August 6, 2021

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}

Output of the above code

Answered by F. Pantigny on August 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP