A three line table is used for my report. I want to fill lightgray
background color to the whole table, but there is white space between rows, how to eliminate this issue?
Without
\addlinespace
: there is still white space around rulesWith
\addlinespace
: this is ideal spacing between rows, but how to fill colour as well for these white spaces?
\usepackage{colortbl}
\definecolor{Lightgray}{RGB}{235,235,235}
Code:
\begin{table} [htpb]
\centering
\begin{minipage}[b]{0.9 \textwidth}
\centering
\begin{threeparttable}[b]
\caption{Size and shape distribution for a sampled rock riprap}
\label{tab:size_shape}
\begin{tabular} { p{0.15 \textwidth} p{0.10 \textwidth} p{0.10 \textwidth} p{0.10 \textwidth} p{0.15 \textwidth} }
\toprule
\rowcolor{Lightgray}& Small & Medium & Large & Shape fraction \\ \cmidrule{1-5} \addlinespace
\rowcolor{Lightgray}Compact & 10\% & 44\% & 7\% & 61\% \\ \addlinespace
\rowcolor{Lightgray}Flat & 4\% & 10\% & 4\% & 18\% \\ \addlinespace
\rowcolor{Lightgray}Elongated & 5\% & 12\% & 4\% & 21\% \\ \addlinespace
\midrule
\rowcolor{Lightgray}Size fraction & 19\% & 66\% & 15\% & 100\% \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{minipage}
\end{table}
Edit 1: Using \renewcommand{\arraystretch}{1.3}
gets proper spacing between rows without \addlinespace
. The remaining issue is: how to get ride of the whihte space for rules?
Edit 2: The solution of Professional-looking tables with alternating row colors still could not eliminate white space after midline
or cmidrule
. Hence white
colour is used for the row after midline
to hide
the white space. If wrong please correct me.
See the table created by the new commands of that solution:
\begin{table} [htpb]
\centering
\begin{minipage}[b]{0.9 \textwidth}
\centering
\begin{threeparttable}[b]
\caption{Size and shape distribution for a sampled rock riprap}
\label{tab:size_shape}
\begin{tabular} { p{0.15 \textwidth} p{0.10 \textwidth} p{0.10 \textwidth} p{0.10 \textwidth} p{0.15 \textwidth} }
\topline
\headcol & Small & Medium & Large & Shape fraction \\% \cmidrule{1-5}
\midline
\rowcol Compact & 10\% & 44\% & 7\% & 61\% \\
\rowcol Flat & 4\% & 10\% & 4\% & 18\% \\ % \cellcolor{lightgray}
\rowcol Elongated & 5\% & 12\% & 4\% & 21\% \\
\midline
\rowcol Size fraction & 19\% & 66\% & 15\% & 100\% \\
\bottomlinec %\bottomrule
\end{tabular}
\end{threeparttable}
\end{minipage}
\end{table}
Besides, if you enlarge the table and look carefully, you will see few thin white lines in the heading row! Is that normal?
See below:
tex.stackexchange.com/q/33758
seems not working.