[Tex/LaTex] Color cell in table

backgroundscolortablestabularx

I'm trying to fill out cells in several rows of my table, however, the color is not filling the entire cell. I can't explain myself why. Additionally, I want my table to be textwidth but it's not executed somehow. Maybe someone could help me understand what I'm doing wrong.

All help highly appreciated!

Here is the code:

\begin{table}[]
\centering
\caption{}
\label{Tab1}
\begin{tabularx}{\textwidth}{@{}lccccc@{}}   
\toprule
\textbf{Author(s)} & \multicolumn{1}{l}{\textbf{RP}}        & \multicolumn{1}{l}{\textbf{PP}}          & \multicolumn{1}{l}{\textbf{ST}}  & \multicolumn{1}{l}{\textbf{HD}}                 & \multicolumn{1}{l}{\textbf{RT}}           \\ \midrule
AK         & Yes                                               & Yes                                               & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes                                               & Yes                                               \\ \midrule
SK         & Yes                                               & Yes                                               & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes                                               & Yes                                               \\ \midrule
MN         & \cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} No} & {\color[HTML]{333333} Yes}                        & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & \cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} No} & \cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} No} \\ \midrule
MS         & Yes                                               & \cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} No} & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes                                               & \cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} No} \\ \midrule
JB         & Yes                                               & Yes                                               & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes                                               & Yes                                               \\ \midrule
HL         & Yes                                               & Yes                                               & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes                                               & Yes                                               \\ \bottomrule
\end{tabularx}
\end{table}

This is what I get

Example

Best Answer

You're mixing and (mis)matching two visual metaphors in one table: (a) color, to highlight various cells (and even an entire column) and (b) the well-spaced horizontal lines of the booktabs package. Use one or the other metaphor, but not both. In the following screenshot, I show what may be achieved by using just color (or, should I say, scales of gray?).

I can't discern a compelling reason for using a tabularx environment here; in the code below, I use a tabular environment. If you believe the columns ought to be a bit wider, try adding the instruction \setlength{\tabcolsep}{12pt}. (The default is 6pt.)

enter image description here

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array} % for "\extrarowheight" macro
\usepackage[skip=0.333\baselineskip]{caption}
\begin{document}
\begin{table}
\setlength\extrarowheight{2pt}
\centering
\caption{My splendid table}\label{Tab1}
\begin{tabular}{@{}llllll}   
\hline
\textbf{Author(s)} & \textbf{RP} & \textbf{PP} 
    & \textbf{ST} & \textbf{HD} & \textbf{RT} \\[0.75ex] 
AK & Yes & Yes 
   & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes & Yes \\ 
SK & Yes & Yes 
   & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes & Yes \\ 
MN & \cellcolor[HTML]{656565}\color[HTML]{FFFFFF}No 
   & \color[HTML]{333333}Yes
   & \cellcolor[HTML]{C0C0C0}\textbf{Yes} 
   & \cellcolor[HTML]{656565}\color[HTML]{FFFFFF}No 
   & \cellcolor[HTML]{656565}\color[HTML]{FFFFFF}No \\ 
MS & Yes 
   & \cellcolor[HTML]{656565}\color[HTML]{FFFFFF}No 
   & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes 
   & \cellcolor[HTML]{656565}\color[HTML]{FFFFFF}No \\ 
JB & Yes & Yes 
   & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes & Yes \\ 
HL & Yes & Yes 
   & \cellcolor[HTML]{C0C0C0}\textbf{Yes} & Yes & Yes \\ 
\hline
\end{tabular}
\end{table}
\end{document}
Related Question