Cell color with horizontal rule in tabular environment

I am trying to draw the following figure in latex:

However, some of my horizontal lines appear to be blurred by the cellcolor and some vertical lines don't show up at all. Anyone knows a way to get round this problem?

\documentclass{article}
\usepackage{colortbl}
\usepackage{hhline}
\begin{document}
\begin{tabular}{|llll|}
\hhline{*{4}{>{\arrayrulecolor{black}}-|}}
1 & 2 & 3 & 4 \\\hhline{*{4}{>{\arrayrulecolor{black}}-|}}

\cellcolor{blue} & 2 & 3 & 4 \\\hhline{*{4}{>{\arrayrulecolor{black}}-|}}

\cellcolor{blue} & \cellcolor{blue} & 3 & 4 \\\hhline{*{4}{>{\arrayrulecolor{black}}-|}}

\cellcolor{blue} & \cellcolor{blue} & \cellcolor{blue} & 4 \\\hhline{*{4}{>{\arrayrulecolor{black}}-|}}
\end{tabular}
\end{document}


Don't use hhline to insert the rules. Instead, use array which does a better job at connecting corners in a tabular:

\documentclass{article}

\usepackage{colortbl,array}

\begin{document}

\begin{tabular}{| *{4}{l|} }
\hline
1 & 2 & 3 & 4 \\
\hline
\cellcolor{blue} & 2 & 3 & 4 \\
\hline
\cellcolor{blue} & \cellcolor{blue} & 3 & 4 \\
\hline
\cellcolor{blue} & \cellcolor{blue} & \cellcolor{blue} & 4 \\
\hline
\end{tabular}

\end{document}

• Thanks. I've ran the code and noticed the horizontal line immediately under 1 and the one after doesn't show. I do see a thin horizontal line though when I zoom in to about 400%! – picasso Mar 7 '16 at 21:05
• @iab : This is dependant on your reader/viewer and not related to LaTeX. I use SumatraPDF. – Werner Mar 7 '16 at 21:08
• I use Adobe Acrobat Reader. Since I can't make any assumptions about what reader/viewer users of the document will use (I'm only knowing of Sumatra now), it appears I'll have to find some other way of highlighting the cells. Thanks for your help. – picasso Mar 8 '16 at 6:51
• @iab: You can make all the rules thicker by adjusting \arrayrulewidth. The default is .4pt (say \setlength{\arrayrulewidth}{1.5pt}), which is lost as many zoom levels under Adobe (Acrobat) Reader. Different viewers have different rendering techniques, which you can't control for (but it is worth noting). – Werner Mar 8 '16 at 7:02