# Define and use new colors for \rowcolor (Colortbl)

How can I use the maroon that I have defined, instead of the gray? Or (better) how can I use directly the maroon from:

\usepackage[dvipsnames]{xcolor}


\documentclass{scrbook}

\usepackage{colortbl}

\definecolor{maroon}{cmyk}{0,0.87,0.68,0.32}

\newcommand{\gray}{\rowcolor[gray]{.90}}

\begin{document}

\begin{tabular}{|l|c|}
\rowcolor[gray]{.9}
one&two\\
\rowcolor[gray]{.5}
three&four
\end{tabular}

\end{document}

-
\rowcolor{maroon} – David Carlisle May 5 '13 at 21:14
@DavidCarlisle \rowcolor[maroon]{.90} does not work – FormlessCloud May 5 '13 at 21:22
That's why I said \rowcolor{maroon}. The optional argument of \color (or \rowcolor) is a color model and if used then the mandatory argumnet takes a color syntax in that model so the [gray] model takes a single number. If you don't use the optional argument then it's a color name as defined by \definecolor – David Carlisle May 5 '13 at 21:26

For an existing color or one previously defined using \definecolor or \colorlet, you can use \rowcolor{maroon}; if you need shades of the color, you can use the !<value> syntax provided by xcolor (the table option for xcolor internally loads colortbl):

\documentclass{scrbook}
\usepackage[table]{xcolor}

\definecolor{maroon}{cmyk}{0,0.87,0.68,0.32}

\begin{document}

\noindent\begin{tabular}{|l|c|}
\rowcolor{maroon}
one & two \\
\rowcolor{maroon!50}
three & four \\
\rowcolor{maroon!10}
five & six
\end{tabular}

\end{document}


Similarly for the Maroon color already provided by the dvipsnames option:

\documentclass{scrbook}
\usepackage[table,dvipsnames]{xcolor}

\begin{document}

\noindent\begin{tabular}{|l|c|}
\rowcolor{Maroon}
one & two \\
\rowcolor{Maroon!50}
three & four \\
\rowcolor{Maroon!10}
five & six
\end{tabular}

\end{document}


The first optional argument for \rowcolor (or \columncolor, or \cellcolor) behaves like the optional argument for \color:

\color[<model>]{<color specification>}


If the optional argument is used, then the mandatory argument expects a <colour specification> instead of a <name>.

For a list of available color models (using xcolor), see Section 2.2 of the xcolor documentation.

-