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:

\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

This is what I get



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

\usepackage{array} % for "\extrarowheight" macro
\caption{My splendid table}\label{Tab1}
\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 \\ 
  • 1
    nice answer, but after column headers i would add \hline :) – Zarko Feb 21 '18 at 18:57
  • @Zarko - Thanks. I actually think that whitespace is a more powerful visual separator here. Note that there are only two \hline directives, and their sole function is to provide a visual marker as to where the tabular material starts an stops. However, reasonable people (and even more so artists!) may disagree. – Mico Feb 21 '18 at 18:58
  • @Zarka and @Mico: Independently of the artistic preferences, I am in agreement with @Zarko when it comes to the additional \hline in the table – Jo-Achna Feb 22 '18 at 11:40
  • @Mico - Thank you for the elaborate and detailed answer. So me mismatching was the main problem. Good to know. The choice of using tabularx was dictated by personal habit. I am still wondering, why \textwidth is not doing its job. In my other tables, it works perfectly. Hmmm – Jo-Achna Feb 22 '18 at 11:43
  • 1
    @user3832272 - The tabularx environment failed to achieve the width of \textwidth because none of the columns were of type X (or, at least, derived from the X column type). – Mico Feb 22 '18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.