3

\rowcolor seems to alter the thickness of cell borders. Example:

\documentclass{scrbook}
\usepackage[table]{xcolor}

\definecolor{maroon}{cmyk}{0.20,0.00,0.00,0.00}

\begin{document}

\noindent\begin{tabular}{|l|c|}
\hline
one & two \\
\rowcolor{maroon}three & four \\

five & six \\
\hline
\end{tabular}

\end{document}

outputs (I have added the red rectangles to show the alterations), rendered by Adobe Acrobate Pro XI:

enter image description here

The output depends on the PDF viewer as well as the zoom. In some cases, borders are even invisible:

enter image description here

How to prevent \rowcolor from altering the thickness of cell borders?

  • If it depends on the viewer, it is a viewer issue and nothing to do with TeX. Does the table print correctly? – cfr Apr 23 '16 at 02:21
  • @cfr Thanks. If some PDF viewers have issues, can't part of the issue come from the way the PDF was generated? I'll try printing, but the reviewers of the document won't print it and are likely to use the same PDF viewer. – Franck Dernoncourt Apr 23 '16 at 02:30
  • All I can say is: this is in general a known problem: the rendering depends on the viewer. Lines disappear at certain magnifications in certain viewers on certain hardware, the user's settings for the viewer, OS etc. and so on. The colour going over the edge - if that's what's happening - can be addressed. But the way the viewer renders lines, not really. Printing is the definitive test, though even that is driver dependent. (I've seen 90% of lower case serif ts disappear on printing. Go figure.) – cfr Apr 23 '16 at 03:05
  • I guess the best advice would be to go for simple, classic formatting. Go for the high quality tabular formats produced by things like booktabs. The line widths won't necessarily render correctly, but that probably doesn't really matter. I'd avoid colour. Aside from anything else, if you don't know who the reviewers are, have you checked what the table will look like to people with different varieties of colour blindness? – cfr Apr 23 '16 at 03:07
  • @cfr I checked that the contrast between the text and the background respects the Web Content Accessibility Guidelines 2.0 (Stack Exchange should do the same by the way). Thanks, I'll look at booktabs. It's too bad there is no good option to color lines :-/ Sumatra is the only one I could find that does a good job rendering the PDF, so at least the problem is solved for 0.1% of the reviewers. – Franck Dernoncourt Apr 23 '16 at 03:16
  • I normally redraw the lines later with the help of tikz. See http://tex.stackexchange.com/a/303859/2388 – Ulrike Fischer Apr 23 '16 at 11:08
  • 3
    I'm voting to close this question as off-topic because it's a viewer issue – Moriambar Jun 12 '17 at 19:04
  • @Moriambar why not writing that as an answer? – Franck Dernoncourt Jun 12 '17 at 19:28
  • @FranckDernoncourt what, the fact that it's a viewer issue? As you wish – Moriambar Jun 12 '17 at 19:30
  • 1
    @FranckDernoncourt is what I wrote what you were thinking of as an answer? – Moriambar Jun 12 '17 at 19:41
  • 1
    @Moriambar I am voting to keep it open, because it is not entirely a viewer issue. The table can be fixed by drawing it two times, first background, then the lines, for example. – Heiko Oberdiek Jun 13 '17 at 00:02

2 Answers2

3

As OP asked, I'm expanding on comments, especially @cfr's.

The issue is due to the fact that the viewers render the images and pdf differently at different magnifications (or when the part of the page seen is different). So one has to rely more on print that on screen, although also the print differs from driver to driver. So it's best to check the output at different maginifications, and possibly print it.


Nevertheless I think that your vertical separators, and your "boxy" table style could need a bit of restyling. Also I think it's best to use different shades of grey for enhancing any rows/cells that need such enhancement (as a plus is colourblind friendly!).

So here is an example of what I mean

\documentclass{scrbook}
\usepackage[table]{xcolor}
\usepackage{booktabs}

\begin{document}

\noindent\begin{tabular}{lc}
\toprule
header&header\\
\midrule
one & two \\
\rowcolor{gray!30}three & four \\

five & six \\
\bottomrule\end{tabular}

\end{document}

enter image description here

Moriambar
  • 11,466
1

With {NiceTabular} of nicematrix, you have a solution. The color panels are drawn before the rules. However, you need several compilations.

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

\begin{document}

\begin{NiceTabular}{|l|c|}[color-inside] \hline one & two \ \rowcolor{red!15} three & four \ five & six \ \hline \end{NiceTabular}

\end{document}

Output of the above code

F. Pantigny
  • 40,250
  • In this answer, since version 5.0 of nicematrix one must write |l|c| instead of |L|C| in the preamble of {NiceTabular} (but there is an option for backward compatibility). – F. Pantigny Jul 18 '20 at 20:41