# table cell shading overlaps to nearby cells

I have a latex table as follows

\documentclass[12pt]{report}

\usepackage{colortbl}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|@{\,}c@{\,}|@{\,}c@{\,}|@{\,}c@{\,}|@{\,}c@{\,}|}
\hline
Column1 & Column2 & Column3 & Column4 \\
\hline
A & \cellcolor[gray]{0.5} & D & E \\
\hline
&  &  & F \\
\hline
&  &  & \\
\hline
\end{tabular}
\end{table}

\end{document}


The cell color is overlaping to the nearby columns. It may be because of @{\,} I used with tabular to remove text padding in columns(It is required since my actual table has more width). Anyone know how prevent the cell shading from overlapping to other cells in this case?

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Sep 14 '14 at 10:13
• Hi, I have added a working example and refined my code a bit. – Josin Sep 14 '14 at 10:36

colortbl adds a padding \tabcolsep wide; instead of using @{\,} you should reduce \tabcolsep:

\documentclass[12pt]{report}

\usepackage{colortbl}

\begin{document}

\begin{table}
\centering
\setlength{\tabcolsep}{0.3em}
\begin{tabular}{|c|c|c|c|}
\hline
Column1 & Column2 & Column3 & Column4 \\
\hline
A & \cellcolor[gray]{0.5} & D & E \\
\hline
&  &  & F \\
\hline
&  &  & \\
\hline
\end{tabular}
\end{table}

\end{document}