If you colourise a row in a table, @{} does not remove the colour from the side bearings, as demonstrated in below figure.
To remove the colour, you may direct a kern into the table column using >{\kern-\tabcolsep}, as demonstrated in below figure:
However, this does not work if the column you want to kern is a p-column. Instead, the cell content no longer lines up with the next cell, as demonstrated below:
Why? Is it possible to use \kern in some way (I know setting \tabcolsep to zero may have the same effect, but doing that has some side effects)?
MWE:
\documentclass[table]{article}
\usepackage{lmodern, microtype, xcolor}
\begin{document}
\begin{tabular}{@{}lcr@{}}
\rowcolor{lightgray}test&test&test\\\hline
test&test&test\\
\rowcolor{lightgray}test&test&test\\
\end{tabular}
\vspace{1cm}
\begin{tabular}{>{\kern-\tabcolsep}lcr<{\kern-\tabcolsep}}
\rowcolor{lightgray}test&test&test\\\hline
test&test&test\\
\rowcolor{lightgray}test&test&test\\
\end{tabular}
\vspace{1cm}
\begin{tabular}{>{\kern-\tabcolsep}p{1cm}cr<{\kern-\tabcolsep}}
\rowcolor{lightgray}test&test&test\\\hline
test&test&test\\
\rowcolor{lightgray}test&test&test\\
\end{tabular}
\end{document}




tabcolsepto zero and use narrow, empty columns to set space between the columns. However, I wonder if it is possible to use the\kerntrick in some way. – Sveinung Aug 18 '19 at 09:05\hspace"– David Carlisle Aug 18 '19 at 13:37>{\columncolor{white}[0pt][\tabcolsep]}before the first and>{\columncolor{white}[\tabcolsep][0pt]}before the last column and later on colored the row with the usual\rowcolorcommand. – leandriis Aug 18 '19 at 15:28