0

I have a table where cells have borders and background colors. On some PDF readers the background colors sometimes get painted over the borders: illustration of the problem

I haven't been able to solve this and now I'm pondering other ways to represent the same data.

Many places recommend avoiding horizontal lines as much as possible, so I was wondering if I should modify this table by removing all horizontal lines (and the non-thick vertical lines) and instead of painting entire cells, I would paint a small square or circle in the center of cells. Is that possible?

2
  • 2
    I usually do not close questions. However, the fact that your previous, very similar question may make you worried that this question gets closed, too. Generally it is not appreciated if there is no starting point provided. You will get way more positive feedback if you post the code that produces the output you show, and explain what you have tried. (You may not like this comment but I am really only trying to help you get a valuable answer.)
    – user194703
    Commented Sep 23, 2019 at 2:30
  • 1
    you can use \hfill inside a cell to make the colour panel short but simpler is not to use colortbl at all and just put a coloured rectangle from eg \textcolor{red}{\strut\hspace{1em}} in the cells. Commented Sep 23, 2019 at 7:00

1 Answer 1

4

My recommendation is : (a) Use the booktabs package (b) instead of vertical rules, use some horizontal space between cells (c) instead of horizontal rules, use some like \addlinespace[.2em] to allow a similar space between rows. Example:

mwe

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{booktabs,array}
\newcolumntype{K}{!{\color{white}\ }c}
\begin{document}
\begin{tabular}{cKKKKKK}\toprule
\multicolumn{2}{c}{Malware} & \multicolumn{3}{c}{Shareware} & \multicolumn{2}{c}{Etc...}\\\cmidrule(r){1-2}\cmidrule(rl){3-5}\cmidrule(l){6-7}
P1 & P2 & P3 & P4 & P5 & P6 & P7 \\\midrule
\rowcolor{yellow}
 &\cellcolor{red} & &  &  &  & \\\addlinespace[.25em]
\rowcolor{cyan}
& & &  &\cellcolor{olive}  &  & \\\addlinespace[.25em]
&  &  & \cellcolor{magenta}  &  &  & \\\addlinespace[.25em]
\rowcolor{gray!20}
&  &  & \cellcolor{magenta!20}  &  &  & \\\addlinespace[.25em]
& & & & & \cellcolor{magenta} & \cellcolor{magenta} \\\bottomrule
\end{tabular}
\end{document}
1
  • @AtteJuvonen Look good :)
    – Fran
    Commented Sep 23, 2019 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .