# Overhang parameter of rowcolor changes overhang of each cell, not just the row

I want to highlight a few rows in a table, and used \rowcolor as per the first table. Well, this results in the row coloring being wider than I desire, so I thought the simple fix would be to adjust the overhang of the row via the optional parameter

\rowcolor{cyan!20}[1pt]


But, this yields the result shown in the second table. The overhang was applied to each cell -- I just want to control the overhang of the entire row, not each cell. That is, I want a solid colored row, but with the overhang adjusted on the left and the right of the row.

## Code:

\documentclass{article}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{colortbl}

\begin{document}

\begin{tabular}{clc}
$n$ & Text & $f(n)$ \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\rowcolor{cyan!20}
1   & abc    & 2      \\
2   & abc    & 1      \\ \rowcolor{cyan!20}
7   & abc    & 3      \\
8   & abc    & 2      \\
9   & abc    & 1      \\
10  & abc    & 2      \\
11  & abc    & 2      \\
\bottomrule
\end{tabular}
\begin{tabular}{clc}
$n$ & Text & $f(n)$ \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\rowcolor{cyan!20}[1pt]%  <---- only change from above is the "[0pt]"
1   & abc    & 2      \\
2   & abc    & 1      \\ \rowcolor{cyan!20}
7   & abc    & 3      \\
8   & abc    & 2      \\
9   & abc    & 1      \\
10  & abc    & 2      \\
11  & abc    & 2      \\
\bottomrule
\end{tabular}
\end{document}

• That's a bit rubbish isn't it: who designed that interface? – David Carlisle Jun 25 '14 at 20:41

\rowcolor is implemented as "do this column colour in every cell of the row" which isn't what you want for the overhang, so:

\documentclass{article}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{colortbl}

\begin{document}

\begin{tabular}{clc}
$n$ & Text & $f(n)$ \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\rowcolor{cyan!20}
1   & abc    & 2      \\
2   & abc    & 1      \\ \rowcolor{cyan!20}
7   & abc    & 3      \\
8   & abc    & 2      \\
9   & abc    & 1      \\
10  & abc    & 2      \\
11  & abc    & 2      \\
\bottomrule
\end{tabular}
\begin{tabular}{clc}
$n$ & Text & $f(n)$ \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\rowcolor{cyan!20}
\multicolumn{1}{>{\columncolor{cyan!20}[1pt][\tabcolsep]}c}{1}
& abc    &
\multicolumn{1}{>{\columncolor{cyan!20}[\tabcolsep][1pt]}c}{2}
\\
2   & abc    & 1      \\ \rowcolor{cyan!20}
7   & abc    & 3      \\
8   & abc    & 2      \\
9   & abc    & 1      \\
10  & abc    & 2      \\
11  & abc    & 2      \\
\bottomrule
\end{tabular}
\end{document}

• Very interesting that the choice of color specified for \columncolor in the \multicolumn does not matter!! – Peter Grill Jun 25 '14 at 22:16