I am trying to get the entire header area (the two rows between \toprule and the long \midrule) of the table area to get the same background color (without any whitespace), but it doesn't seem to work. Any ideas on how this may be solved? Any way to set the ruler color as well?
I tried adding the \rowcolor{lightgray}
twice, but that doesn't seem to have any effect.
The code I have so far (MWE):
\documentclass{article}
\usepackage[table]{xcolor}
\newcolumntype{s}{>{\columncolor[HTML]{AAACED}} p{3cm}}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{threeparttable}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}
\begin{table}[ht]
\centering
\begin{threeparttable}
\caption{dsfsdfsdfsdfdsfdfsdsf}
\label{tab:strnedbhendbidrmestnedb74000117}
\begin{tabular}{@{}p{0,40\textwidth}*{4}{L{\dimexpr0,18\textwidth-2\tabcolsep\relax}}@{}}
\toprule
& \rowcolor{lightgray} \multicolumn{2}{c}{\textbf \Longstack{dsfdfsdf}} &
\rowcolor{lightgray} \multicolumn{2}{c}{\textbf \Longstack{sdfsdf}} \\
\cmidrule(l){2-3} \cmidrule(l){4-5}
$fsdfsdf$ & $ss_{d}$ &$ $ $bf_{tot}$ & $rr_{dg}$ & $ $ $gg_{tot} $ \\
\midrule
$Q_{rr} $ & 6,7 & 24 & 6,7 & 3 \\
jj & 6,7 & 14 & 2,2 & 3 \\
$ r_{g} $ & 6,7 & 26 & -3,0 & -4 \\
$ y_{tw}$ & 433,4 & 37 & 433,1 & 98 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
This how it appears so far:
UPDATE
As per the comment of mhtsort I tried the following:
\toprule
\rowcolor{lightgray} & \multicolumn{2}{c}{\textbf \Longstack{dsfdfsdf}} \rowcolor{lightgray} &
\multicolumn{2}{c}{\textbf \Longstack{sdfsdf}} \\
\cmidrule(l){2-3} \cmidrule(l){4-5}
But it results in this, which doesn't solve the issue:
UPDATE 2:
Adjusted as per the answer of Zarko. Also I added another \rowcolor{lightgray}
to try and fill up all the area between two rows between \toprule
and the long \midrule
.
\begin{tabularx}{\linewidth}{X*{2}{S[table-format=3.1]S[table-format=2]} }% %
\toprule
\rowcolor{lightgray}
& \multicolumn{2}{c}{\textbf{dsfdfsdf}}
& \multicolumn{2}{c}{\textbf{sdfsdf}} \\
\cmidrule(l){2-3}
\cmidrule(l){4-5}
\rowcolor{lightgray}
$fsdfsdf$ & {$ss_{d}$} & {$bf_{tot}$} & {$rr_{dg}$} & {$gg_{tot}$} \\ \midrule
However there is the some whitespace near the \cmidrule
, \toprule
and the \midrule
as can be seen from the results here (whitespace here refers to the white area between the grey colored background and the \cmidrule
, \toprule
and the \midrule
):
UPDATE 3: As per the last update Zarko this looks much better now. For the white artifacts there might be no solution.
L
column type?