Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
2  
\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
add comment

1 Answer 1

up vote 5 down vote accepted

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}

enter image description here

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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