6

I have a table where I am filling some of the cells with a gray color. It works fine. The problems is however, that the horizontal lines of the table becomes gray too. How can I solve this so that the lines stays as Black lines and the cell color is gray?

Image of my problem: enter image description here

A complete code example can be found online here or in this code:

\documentclass{article}
\usepackage{slashbox,pict2e}
\usepackage{color, colortbl}
\usepackage{amssymb}

\definecolor{Gray}{gray}{0.9}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|l|c|c|c|}
    \hline\backslashbox{Enhed}{Interface} & ED    & DDG   & \textit{Server} \\
    \hline  ED      & \checkmark        & \checkmark        & {\cellcolor{Gray}} \\
    \hline DDG     & \checkmark        & {\cellcolor{Gray}}  & \checkmark \\
    \hline \textit{Server}  & {\cellcolor{Gray}}  & \checkmark        & {\cellcolor{Gray}}\\\hline
\end{tabular}
\caption{Oversigt over interfaces mellem enhederne.}
\label{tab:interfacesMellemEnheder}
\end{table}
\end{document}
  • 5
    It's only a problem with the pdf viewer. Check with a large zoom. Normally there should be no problem with the printer. – Bernard Oct 20 '14 at 8:19
  • also there should be no {} around \cellcolor (although it makes no difference here) – David Carlisle Oct 20 '14 at 8:21
  • slashbox is a very old package, you might try diagbox instead. – Andrew Swann Oct 20 '14 at 8:23
  • 1
    Beside the technical "fake" problem, the true problem is the obsession to put as many rules as possible. My suggestion is use booktabs, not diagbox, one \toprule, one \cmidrule{2-4} for "Interface" in a multicolumn, a \midrule, a \bottomrule and ... and nothing else. – Fran Oct 20 '14 at 8:59
4

As you can read in the comments there never was a problem with the tex code. The only problem was the pdf viewer. When zooming in the lines gets visible again. This will not be a problem when printing the page.

  • I currently have this exact issue and both Google Chrome and Adobe Acrobat display my PDF incorrectly. You can say "not a problem with tex code, only problem with pdf viewers", but if practically all viewers of my PDF are going to see it incorrectly, it does become my problem. – Atte Juvonen Sep 22 at 21:28
1

Sorry, this is too long for a comment. As requested by FireFly3000, an example with booktabs with only a few rules:

MWE

In this type of table diagbox have no utility, so you can put "Interface" in a multicolumn in a previous row, and left only "Enhed" in the cell, or if you prefer this label vertically centered, use the multirow package:

\documentclass{article}
\usepackage{colortbl, booktabs}
\usepackage{multirow}
\usepackage{amssymb}
\definecolor{Gray}{gray}{0.9}
\begin{document}
\begin{table}
\centering
\begin{tabular}{lccc}
\toprule
\multirow{2}{*}{Enhed} & \multicolumn{3}{c}{Interface} \\
\cmidrule{2-4}
            & ED                &  DDG             & \textit{Server} \\
\midrule
ED               & \checkmark        & \checkmark       & \cellcolor{Gray} \\
DDG              & \checkmark        & \cellcolor{Gray} & \checkmark       \\
\textit{Server}  & \cellcolor{Gray}  & \checkmark       & \cellcolor{Gray} \\
\bottomrule
\end{tabular}

\caption{Oversigt over interfaces mellem enhederne.}
\label{tab:interfacesMellemEnheder}
\end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.