I used cellcolor to change the color of a cell in the table. But, for some strange reason, it doesnot color it completely. Why would that happen? Below is MWE:

\usepackage{graphicx}           % include graphs/ figures  in the file
\usepackage{setspace}           % to set the line spacing in the document
\usepackage{lscape}             % to write pages in landscape environment
\usepackage{array,threeparttable}       % to add footnotes to the tables
\usepackage{caption}    % to create some space between table caption and table, otherwise there was no space
\usepackage[normalem]{ulem}     % to underline the text
\usepackage{grffile}            % to avoid printing the figure name (or otherwise, give figure names without spaces)
\usepackage{float}              % figures as 6 (a), 6 (b) etc.


  \caption{Free  (mg/100g ter) and aride compos (gy maer) in pokuls}
    \textbf{\cellcolor{blue!25}Frtion (matter)} & \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{0}}} & \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{15}}} & \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{60}}} & \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{120}}}\tabularnewline  
    \textit{Esseo acids} &       &       &       &  \tabularnewline     \addlinespace
    Valine & \multicolumn{1}{c}{75} & \multicolumn{1}{c}{40} & \multicolumn{1}{c}{26} & \multicolumn{1}{c}{10} \tabularnewline      \addlinespace
        \textit{\textbf{Total }} & \multicolumn{1}{c}{\textbf{11.84}} & \multicolumn{1}{c}{\textbf{10.24}} & \multicolumn{1}{c}{\textbf{9.2}} & \multicolumn{1}{c}{\textbf{10.18}} \tabularnewline      

  • Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – LaRiFaRi Mar 24 '15 at 22:45
  • @Werner If I try it by taking it out from \textbf{}, it still gives the same solution. – abhishek Mar 24 '15 at 22:50

\cellcolor should be the first thing that appears in the cell, except when using \multicolumn. Below I've also provided an updated \toprulec and \midrulec which inserts a coloured separation using \specialrules to make the heading more uniform:

enter image description here


\newcommand{\toprulec}{% Coloured \toprule
\newcommand{\midrulec}{% Coloured \midrule

  \cellcolor{blue!25}\textbf{Frtion (matter)} & 
    \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{0}}} & 
    \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{15}}} & 
    \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{60}}} & 
    \multicolumn{1}{c}{\cellcolor{blue!25}\textbf{M\textsubscript{120}}} \\
  \textit{Esseo acids} &       &       &       &  \\
  Valine & \multicolumn{1}{c}{75} & \multicolumn{1}{c}{40} & \multicolumn{1}{c}{26} & \multicolumn{1}{c}{10} \\
  \textit{\textbf{Total }} & 
    \multicolumn{1}{c}{\textbf{11.84}} & 
    \multicolumn{1}{c}{\textbf{10.24}} & 
    \multicolumn{1}{c}{\textbf{9.2}} & 
    \multicolumn{1}{c}{\textbf{10.18}} \\     


Similarly, \rowcolor should be the first thing that appears in the row.

  • I get the same solution, but what I mean is that the cell that is now colored blue, is not completely blue. I see 1mm on the top and 1mm on the bottom that is uncolored. Can this be fixed? – abhishek Mar 24 '15 at 22:51
  • @abhishek: See the updated answer. – Werner Mar 24 '15 at 23:00
  • Seems it like works. but if I have this table in a chapter in a thesis, where should I place this rule? in the main preamble? or close to the table - locally in a chapter? – abhishek Mar 24 '15 at 23:05
  • 1
    Place the \specialrule definitions in your preamble and then you can use them anywhere in your document. – Werner Mar 24 '15 at 23:07
  • Works very well!!! Thanks a lot.. Have to submit my thesis this week! – abhishek Mar 24 '15 at 23:11

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.