In a larger project, we have trouble producing tables that look "just right" because use of colorcell leaves little vertical lines between colored cell areas. I've made a minimal table that demonstrates, as seen from this screenshot:
We've read a lot of posts about this, do not have any definitive answers. I think I'm getting closer to a comprehensive understanding of the vertical lines issue. I'm posting LaTeX example code that demonstrates several variants. In some PDF viewers, it appears the gray area is smooth, while others still show a faint ghost of white.
In the end, I'm not able to eliminate the little white line without setting tabcolsep to 0, this seems unfortunate/heroic/incorrect.
We also have the problem that the horizontal lines sometimes also show in other tables using colortbl, but I gather that is actually a separate problem (if I'm reading this correctly: \url{Very thin white line in colortbl}). If I do get a satisfactory before/after comparison, I'll start another thread here.
Here's my best result, using the proposal at the end of this code:
This is a snapshot from the viewer Evince in Ubuntu Linux, to my eye there is still a faint bit of white. It looks a little different on various monitors. I've looked at this on various monitors in various OS, it appears to be a touchy PDF problem.
This is the best I can do so far, if there is a better, less tedious way to do it, I wish you'd tell me. I don't totally hate setting tabcolsep to 0, but then I do hate manually inserting indentation space just on the left side of the table. I don't care if the right side goes right up to the edge.
Please don't let your answer be "redesign your table to fit our opinion of what looks nice". This is the one the professors want to use.
In my code, I leave all of the packages we use because a smaller MWE won't necessarily reproduce the same problem the same way. The very important effect of the array package is my evidence for still loading those other things.
\documentclass[letterpaper,landscape,11pt,english]{article}
\usepackage{lmodern}
\usepackage[scaled=0.9]{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[landscape]{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\setlength{\parskip}{10bp}
\setlength{\parindent}{0pt}
\usepackage{array}
\usepackage{calc}
\usepackage{rotating}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{hhline}
\makeatletter
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{moresize}
\usepackage{verbatim}
\usepackage{color}
\usepackage{colortbl}
\usepackage{adjustbox}
\usepackage{url}
\definecolor{gr}{RGB}{240,240,240}
\makeatother
\usepackage{babel}
\begin{document}
%\normalsize{}
Paul Johnson
March 26, 2016
We have fought a battle with coloring in LaTeX tables. The problem is
that when one colors a cell, one either obliterates the lines of the
border or one is unable to get the line colors correctly. The
ordinary line drawing functions like \\hline and \\cline are not
comfortable with colored cells, one is urged to change to hhline to
draw the lines. With hhlines, the colors of the cell backgrounds do not
destroy the border lines. But there's a new problem, the accidental
white line border.
The trouble case for this is illustrated in the first table, where you
should see tiny white vertical lines between the cells of the colored row.
% Am using guide in "colortbl.pdf" to use hhline to adjust color of
% column separator. However, it appears tabular* just ignores this
\setlength\tabcolsep{0pt}
\begin{tabular*}{11cm}{@{\extracolsep{\fill}}>{\centering}p{2.1cm}|> {\centering}m{2.9cm}|>{\centering}m{3cm}|>{\centering}m{2.9cm}|}
\multicolumn{4}{c}{\textbf{A Frustrating Table with white lines}}\tabularnewline
\hhline{~---}
& \multicolumn{1}{>{\centering}m{2.9cm}}{{\cellcolor{gr}}Here's a box\\
Score}& \multicolumn{1}{>{\centering}m{3cm}}{{\cellcolor{gr}}Another
Box with two\\
Rows} &{\cellcolor{gr}}Student's\\
Proficiency Level\tabularnewline
\hhline{----}
\multicolumn{1}{|>{\centering}p{2.1cm}|}{Science} & 28 & 26 or above & Proficient\tabularnewline
\hline
\end{tabular*}
Those are not actually white lines. They are more correctly described as the absence of gray lines.
Study this:
\url{https://tex.stackexchange.com/questions/65604/hhline-adds-white- line-where-no-line-is-intended}
The white line is the absence of a line caused by my use
of hhline, but I don't see how to change the color of that one little
line.
Here I try to set the row color as gray, but place the
first cell as white.
But the white lines show unless we tune up the rowcolor overlap,
which puts some gray outside the table on the right
\setlength\tabcolsep{0pt}
\begin{tabular*}{11cm}{@{\extracolsep{\fill}}
>{\centering}p{2.1cm}|
>{\centering}m{2.9cm}|
>{\centering}m{3cm}|
>{\centering}m{2.9cm}|}
\multicolumn{4}{c}{\textbf{A Frustrating Table with white
lines}}\tabularnewline
\hhline{~---}
\rowcolor{gr}[0mm][1mm]
\multicolumn{1}{>{\centering}m{2.1pt}|}{\cellcolor{white}}
& \multicolumn{1}{>{\centering}m{2.9cm}}{Here's a box\\
Score}& \multicolumn{1}{>{\centering}m{3cm}}{{\cellcolor{gr}}Another
Box with two\\
Rows} &{\cellcolor{gr}}Student's\\
Proficiency Level\tabularnewline
\hhline{----}
\multicolumn{1}{|>{\centering}p{2.1cm}|}{Science} & 28 & 26 or above & Proficient\tabularnewline
\hline
\end{tabular*}
The colortbl.pdf file has lots of suggestions, none I
understand very well. On p. 5 suggests it suggests:
Replace "|" with vline or vrule, like this:
\begin{verbatim}
!{\color{gr}\vrule width 5pt}
\end{verbatim}
or maybe
\begin{verbatim}
!{\color{gr}\vline}
\end{verbatim}
However, that causes the whole table to break because
bottom right corner lines don't connect anymore. Look here:
\setlength\tabcolsep{0pt}
\begin{tabular*}{11cm}{@{\extracolsep{\fill}}>{\centering}p{2.1cm}|
>{\centering}m{2.9cm}|
>{\centering}m{3cm}|
>{\centering}m{2.9cm}|}
\multicolumn{4}{c}{\textbf{A Frustrating Table with
white lines}}\tabularnewline
\hhline{~---}
& \multicolumn{1}{>{\centering}m{2.9cm}%
!{\color{gr}\vrule width 1pt}%% where a vert bar would have been
}{{\cellcolor{gr}}Here's a box\\
Score}&
\multicolumn{1}{>{\centering}m{3cm}!{\color{gr}\vrule width 5pt}}
{{\cellcolor{gr}}Another
Box with two\\
Rows} &{\cellcolor{gr}}Student's\\
Proficiency Level\tabularnewline
\hhline{----}
\multicolumn{1}{|>{\centering}p{2.1cm}|}{Science} & 28 & 26
or above & Proficient\tabularnewline
\hline
\end{tabular*}
I believe this problem relates to the use of the array package and
some assumptions it makes about the sum of columns inside a table. This
fine answer on SE explains it.
\url{https://tex.stackexchange.com/questions/116917/why-is-my-tabular-wider-than-the-sum-of-its-columns-widths}
The total width of a table is the sum of the columns, plus the
2 x tabcolsep, plus arrayrulewidth. But the tabular* is
specified with the total width, and that's confusing
So now, instead of specifying a
column width in cm, we have to do some ridiculous dance.
Replace a column width like "2.1cm" with
\begin{verbatim}
{\dimexpr 2.1cm-2\tabcolsep-1.5\arrayrulewidth}
\end{verbatim}
Same calculation has to be applied to multicols as well.
\setlength\tabcolsep{0pt}
\begin{tabular*}{11cm}{@{\extracolsep{\fill}}
>{\centering}p{\dimexpr 2.1cm-2\tabcolsep-1.5\arrayrulewidth}|
>{\centering}m{\dimexpr 2.9cm-2\tabcolsep-1.5\arrayrulewidth}|
>{\centering}m{\dimexpr 3cm-2\tabcolsep-1.5\arrayrulewidth}|
>{\centering}m{\dimexpr 2.8cm-2\tabcolsep-1.5\arrayrulewidth}|}
\multicolumn{4}{c}{\textbf{A Frustrating Table with
white lines}}\tabularnewline
\hhline{~---}
& \multicolumn{1}{
>{\centering}m{\dimexpr 2.9cm-2\tabcolsep-1.5\arrayrulewidth}%
!{\color{gr}\vrule width 1pt}%% where a vert bar would have been
}{{\cellcolor{gr}}Here's a box\\
Score}&
\multicolumn{1}{>{\centering}m
{\dimexpr 3cm-2\tabcolsep-1.5\arrayrulewidth}
!{\color{gr}\vrule width 5pt}}
{{\cellcolor{gr}}Another
Box with two\\
Rows} &{\cellcolor{gr}}Student's\\
Proficiency Level\tabularnewline
\hhline{----}
\multicolumn{1}{|>{\centering}p{2.1cm}|}{Science}
& 28
& 26 or above
& Proficient\tabularnewline
\hline
\end{tabular*}
\end{document}
tabular*
makes that tricky as you are adding gaps of unspecified width between the columns. It's easier withtabular
to avoid these gaps.