# Problem with hline on alternating row colour table

I've created a table where the rows alternate in colour however /hline is acting unusually.

The first and second /hline work normally however after this alternating /hlines only show as a small dash next to the vertical column line

\usepackage[table]{xcolor}

\begin{table}[ht]
\rowcolors{2}{gray!25}{white}
\begin{tabular}{l | l|}
\hline
\rowcolor{gray!25}
text part 1 & test part 2  \\
Priority & High \\ \hline
text part 1 & test part 2  \\
Priority & High \\ \hline %this hline doesnt show
text part 1 & test part 2  \\
Priority & High \\ \hline
text part 1 & test part 2  \\
Priority & High \\ \hline %this hline doesnt show
text part 1 & test part 2  \\
Priority & High \\ \hline
text part 1 & test part 2  \\
Priority & High \\ \hline
\end{tabular}
\end{table}


Does anybody know what I'm doing wrong? Thanks.

• What about if you zoom in on the resulting output? This may just be an artifact created by the viewer resolution. – Werner Mar 10 '14 at 19:28
• Could this be related: tex.stackexchange.com/questions/162814/…, where the line is being overwritten? – Steven B. Segletes Mar 10 '14 at 19:42
• Looks like it was indeed to do with the line being overwritten you were right. The answer bellow worked perfectly. – user2086359 Mar 10 '14 at 20:12
• – Peter Grill Mar 10 '14 at 21:32

This is a documented issue affecting the display of \hline lines in PDFs, and affects some PDF viewers (Adobe's Acrobat may not display the line while Apple's Preview might display it fine). In most cases, the problem should not affect the printed output you see on paper.

If it still bothers you, however, you can swap out your \hline with the \midrule of the booktabs package to fix this:

\documentclass[]{article}

\usepackage[table]{xcolor}
\usepackage{booktabs}
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}

\begin{document}

\begin{table}[ht]
\rowcolors{2}{gray!25}{white}
\begin{tabular}{l | l|}
\toprule
\rowcolor{gray!25}
text part 1 & test part 2  \\
Priority & High \\ \midrule
text part 1 & test part 2  \\
Priority & High \\ \midrule
text part 1 & test part 2  \\
Priority & High \\ \midrule
text part 1 & test part 2  \\
Priority & High \\ \midrule
text part 1 & test part 2  \\
Priority & High \\ \midrule
text part 1 & test part 2  \\
Priority & High \\ \bottomrule
\end{tabular}
\end{table}

\end{document}


See also: \cline doesn't work -- a different underlying problem, but a similar fix.

• Worked like a charm, thanks for the help! edit: I would upvote your answer but sadly not enough reputation yet. – user2086359 Mar 10 '14 at 20:09
• as documented in the colortbl package, cline doesn't work, but the OP's MWE doesn't use cline? hline works but depending on viewer and zoom facto it may vanish in the view. – David Carlisle Mar 10 '14 at 21:29
• That is true. After my research, I put cline into the OP's mouth, but it was in fact hline. I have edited my answer to reflect the source of the problem, and to indicate that it should not affect printed output. – cslstr Mar 10 '14 at 21:37
• No. Delete "similar" :-) The situation with cline and hline are completely different. cline takes up no vertical space it includes negative spacing so that cline{1}\cline{2} line up, this means that coloured panels overprint the line by exactly half its thickness. Conversely, coloured panels do not overprint hline at all, they are adjacent but may appear to overprint (or have a white gap) depending which way the viewer rounds exact coordinates to pixel boundaries. – David Carlisle Mar 10 '14 at 23:33