# cellcolor affects horizontal alignment in table

I have a table and I want to highlight some cells with color with \cellcolor.

However the horizontal alignment is distorted, as you can see in the image.

Can this be corrected with the current approach?

I didn't find any relevant information and a radically new approach would be preferably avoided.

I found only the workaround of adding a(n extra) ~ in the beginning of the non-highlighted cells of the same column. It works, but this is a workaround.

\documentclass{article}

\usepackage{array}
\usepackage{hhline}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

\begin{document}
\begin{table}[h]
\footnotesize
\begin{center}
\caption{blah}
\label{fig:QResults}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|l|c|c|}                                                       \hhline{-|~|-}
\multicolumn{1}{|c|}{~~Features~~} & \multicolumn{1}{ c|}{} & ~~error~~ \\ \hhline{-|~|-}
\noalign{\smallskip}                                                       \hhline{-|~|-}
\cellcolor[gray]{0.8} {~~feat1~~} & {} & \cellcolor[gray]{0.8} {$1.49$} \\ \hhline{-|~|-}
{~~feat2~~} & {} &                       {$4.86$} \\ \hhline{-|~|-}
{~~feat3~~} & {} &                       {$4.67$} \\ \hhline{-|~|-}
\end{tabular}
\end{center}
\end{table}
\end{document}


• I'm not sure why you are using ~~ to force spaces around the cell content. Have you tried without? Oct 9, 2014 at 0:34
• Yes I tried, these are there just to add some space between the text and the vertical lines, to allow the text to "breathe". Please note that the effect is the same for the last column, where there are no ~~. I updated the 1st post with the same numbers on all rows, so that the effect it more visible. Oct 9, 2014 at 0:36
• I just edited your post so that the example is reproducible (so that we can copy/paste it and compile it directly) -- this should appear shortly. Oct 9, 2014 at 0:42

\cellcolor[gray]{0.8}~~feat1~~ & {} & \cellcolor[gray]{0.8}{$1.49$} \\ \hhline{-|~|-}