I would like to highlight the first two rows of my table with a custom shade of gray. For this, I thought of using the \rowcolor environment from the colortbl package.
However, its usage seems to leave unwanted gaps in the shading, i.e. the shading patch does not get applied to the full row.
Here is a MWE
\documentclass{article}
\usepackage{xcolor}
\definecolor{newgray}{RGB}{196,196,196}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{threeparttable}
\begin{document}
\begin{threeparttable}
\centering
\begin{tabular*}{\textwidth}{ l @{\extracolsep{\fill}} l c r}
\multicolumn{4}{c}{\textbf{Random Table}} \\
\toprule
\multicolumn{1}{l}{Item} & \multicolumn{1}{l}{Case 1} & \multicolumn{1}{c}{Case 2} & \multicolumn{1}{r}{Case 3}\\
\midrule
\rowcolor{newgray}first thing, & \tnote{a}245 & \tnote{b}25e-6 & \tnote{c}79e-6 \\
\rowcolor{newgray}[20pt][20pt]second thing & \tnote{a}450 & --- & \tnote{b}24e-6 \\
third thing & \tnote{d}2e-6 & \tnote{c}4123.5 & \tnote{b}2e-6 \\
fourth thing & --- & 1e6 & no data \\
\bottomrule
\end{tabular*}
\medskip
\begin{tablenotes}
\item[a] some explanation
\item[b] this is why \dots
\item[c] see reference awesome
\item[d] hello world
\item
\end{tablenotes}
\end{threeparttable}
\end{document}
which produces the following output
Here are the requirements. I would like to have the table typeset to the textwidth achieved here using \begin{tabular*}{\textwidth}{ l @{\extracolsep{\fill}} l c r}, and secondly I need to have explanatory notes achieved here using the tablenotes environment provided by the threeparttable package. For aesthetics, I am using the booktabs package.
Clearly, the shading achieved right now is not desirable. When used without any overhang specification, the \rowcolor command leaves gaps in the shading. While, using left and right overhang minimises these shading gaps in the middle columns, it extends the shading beyond the table's width, which is undesirable.
How can I achieve the expected behavior, i.e. shade the row uniformly, with no gaps and without exceeding table's width?



tabularxto make the table span the textwidth does not seem to have this drawback. Would this be an option for you? – leandriis May 28 '18 at 19:49X X Xfor all columns in tabularx. Maybe I am wrong. Anyway, I am curious to know your solution. – Dr Krishnakumar Gopalakrishnan May 28 '18 at 19:50@{\extracolsep{\fill}}. – Zarko May 28 '18 at 19:55Xtype columns. Here are also some related topics: color not applied properly in a row when \extraccolsep\fill is used in the tabular* environment and coloring entire row of tabular* – leandriis May 28 '18 at 19:59Xtype columns and still retain the desired alignment ofl l c r? – Dr Krishnakumar Gopalakrishnan May 28 '18 at 20:01Xtype as shown here Centering in tabularx and X columns for a centeredXlike column. For raggedright or raggedleft alignment, this works analogously. – leandriis May 28 '18 at 20:07