3

I'm trying to color the rows of a longtable with rowcolor as follow (in the MWE I have onyl included few rows of the very long table):

\documentclass[a4paper]{article}
\usepackage[fontsize=8pt]{scrextend}
\usepackage[table]{xcolor}
\usepackage[
bottom=22mm,
top=22mm,
left=15mm,
right=15mm
]{geometry}

\usepackage{caption} \usepackage{booktabs} \usepackage{longtable}

\definecolor{colorA}{rgb}{29,140,118} \definecolor{colorB}{rgb}{251,174,62}

\usepackage{makecell} \renewcommand\theadalign{bc} \renewcommand\theadfont{\bfseries} \renewcommand\theadgape{\Gape[4pt]} \renewcommand\cellgape{\Gape[4pt]}

\begin{document} {\scriptsize\tabcolsep=2pt \centering \begin{longtable}[c]{@{}cccccccccccc@{}} \caption*{\textbf{Supplementary table 2}. DEGs summary} \ \midrule \thead{xxxxx} & \thead{yyyyy} & \thead{xxxxx\yyyyy} & \thead{xxxxx\yyyyy} & \thead{yyyyy} & \thead{xxxxx\yyyyy} & \thead{xxxxx\yyyyy} & \thead{xxxxx} & \thead{xxxxx\yyyyy} & \thead{xxxxx\yyyyy} & \thead{xxxxx\yyyyy} & \thead{xxxxx\yyyyy} \ \midrule \rowcolor{colorA} 0dk2 & 651,3505 & -1,1010 & 0,1016 & -10,8339 & 0,0000 & 0,0000 & 0,0156 & 0,0003 & 0 & 0 & 0 \ \rowcolor{colorA}
AABR07001896.1 & 29,4550 & -1,0138 & 0,2150 & -4,7147 & 0,0000 & 0,0001 & 0,0391 & 0,0003 & 0 & 0 & 0 \ \rowcolor{colorB} AABR07001905.1 & 23,0908 & -1,2473 & 0,3169 & -3,9357 & 0,0001 & 0,0011 & 0,1166 & 0,0020 & 0 & 0 & 0 \ \rowcolor{colorB} AABR07001910.1 & 30,9100 & -1,7463 & 0,3645 & -4,7906 & 0,0000 & 0,0000 & 0,1770 & 0,0003 & 0 & 0 & 0 \ \rowcolor{colorA} AABR07001923.1 & 21,8214 & -1,5873 & 0,2611 & -6,0797 & 0,0000 & 0,0000 & 0,0528 & 0,0003 & 0 & 0 & 0 \ \end{longtable}} \end{document}

However the rows do not get colored: output example

I suspect that the problems comes from the fact that I use the makecell command. I cannot get rid of it because I need to force line breaks in the headings of the table as described here.

I've looked at the other issues with rowcolor and longtable here but they do not seem to be related with mine.

TVL
  • 99
MNP_88
  • 63
  • 1
    Hey, with e.g. red as colour it works (if you want to colour the whole line), I think the error lies within the defined colour, although I can't point exactly where. Edit: Is it possible, that the rgb values should be fractions of 1, e.g. \definecolor{colorA}{rgb}{0.5,0.5,0.5} (although this is not the colour you want) – TVL Jan 12 '21 at 17:12
  • yes that was the answer. Thanks! So silly from me. If you post it as an aswer I will flag it as correct – MNP_88 Jan 12 '21 at 17:30
  • 2
    If you want to keep your color definitions with their current values, just replace rgb with RGB. – leandriis Jan 12 '21 at 17:54
  • thanks @leandriis, thats good to know. – TVL Jan 12 '21 at 18:04

1 Answers1

1

As pointed out below the problem lies with the fact that rgb values should be fractions of 1. Or alternatively, to use these color definition rgb must be replaced with RGB

MNP_88
  • 63