9

I'm using the xcolor package to colour the top row in a table. This is displayed properly using PDF viewers such as Preview or Skim (Mac). But using Adobe Reader 10.1.3 (either Windows or Mac) doesn't display the table line properly.

But removing the colouring for the table fixes it. Here is the example that works as expected:

\begin{table}
\caption{Table showing Feature 5's Functional Tests}
\hspace*{-0.5in}
\begin{tabular}[h!]{|p{0.6cm}|p{4cm}|p{5cm}|p{4cm}|p{1.5cm}|}
\hline
{\bf Test ID } & {\bf Task } & {\bf Expected} & {\bf Actual} & {\bf Outcome} \\
\hline
   5.1 & Something &  Something & Something &  Success \\
\hline
   5.2 & Something &  Something & Something &  Success \\
\hline
   5.3 & Something &  Something & Something &  Success \\
\hline
   5.4 & Something &  Something & Something &  Success \\
\hline
\end{tabular} 
\end{table}

And here is the example with a coloured row:

\begin{table}
\caption{Table showing Feature 5's Functional Tests}
\hspace*{-0.5in}
\begin{tabular}[h!]{|p{0.6cm}|p{4cm}|p{5cm}|p{4cm}|p{1.5cm}|}
\hline
\rowcolor{gray!25}
{\bf Test ID } & {\bf Task } & {\bf Expected} & {\bf Actual} & {\bf Outcome} \\
\hline
   5.1 & Something &  Something & Something &  Success \\
\hline
   5.2 & Something &  Something & Something &  Success \\
\hline
   5.3 & Something &  Something & Something &  Success \\
\hline
   5.4 & Something &  Something & Something &  Success \\
\hline
\end{tabular} 
\end{table}

Removing the \rowcolor{} command replacing it with \cellcolor{} creates the same view. Any idea how to fix this?

I've tried printing it out of Adobe and the lines print fine, but as this will be read on as a soft copy it's pretty important. Here is a gallery to show the out of of the LaTeX code.

Any idea how to fix this?

Rich Race
  • 93
  • 1
  • 3

2 Answers2

8

PDF viewers try to "snap" rules to pixel boundaries and this can mean that the coloured panels get pulled over adjacent rules. Try increasing the rule width with

\setlength\arrayrulewidth{0.6pt}

or whatever value works on your screen.

David Carlisle
  • 757,742
  • By contrast, I've been having problems with the lines not showing up correctly when printed, even though they're at least visible, if slightly fainter, in the PDF viewer (Preview or Reader). Would the same thing be causing that? – Erika Oct 22 '14 at 09:14
  • @Erika probably. Try adjusting the with of \arrayrulewidth by a fraction just to get it to round the pixel boundaries differently. – David Carlisle Oct 22 '14 at 09:16
  • I'm not actually getting a difference, even on screen, playing around with \arrayrulewidth. It looks like the colored boxes are actually making the lines paler (and so the printer won't print them) because when I zoom in enough that the pixel overlap isn't so much an issue, they're still very faded out. Confusing! – Erika Oct 31 '14 at 16:25
1

The package colortbl (loaded by the key table of xcolor) constructs the array row by row, alterning colored rectangles, rules and contents of the cells. The resulting PDF, although perfectly correct and conform to the PDF syntax, is difficult to interpret by some PDF viewers (even modern ones) and may lead to artefacts on the screen (not on paper).

  • Some rules seem to disappear. This is because many PDF viewers give priority to graphical elements drawn posteriorly (which is in the spirit of the "painting model" of PostScript and PDF). This problem is particularly acute in Adobe Reader (although Adobe was the creator of the PDF format).

  • A thin white line may appear between two cells of the same color (in fact, this line has a width of 0 pt, which means, in PostScript and PDF, a width of 1 pixel). This phenomenon occurs when each cell is colored with its own instruction fill (the PostScript operator fill coded f in the PDF streams). This is the case with colortbl: each cell is colored on its own, even when columncolor or \rowcolor is used. These thin white lines appear in particular with the PDF engine MuPDF of Artifex Software (used, for instance, in Sumatra PDF) or with PDF.js used by Firefox. They don't appear in Adobe Reader.

The package nicematrix tries to solve that problems. That extension provides an environment {NiceTabular} similar to {tabular} (of the package array). With that environment, the colored panels are drawn before the rules (to avoid the first problem) and color by color (to avoid the second problem).

However, there is a drawback: nicematrix uses PGF/Tikz nodes and informations stored in the aux file and that's why one needs several compilations.

F. Pantigny
  • 40,250