# Error with xcolor package

I would like to write the chapters' titles in my LaTeX document in an other color, so I imported the following package:

\usepackage[dvipsnames]{xcolor}


But when I try this:

\chapter{\color{Maroon} My Title}


I get the following error:

Package xcolor Error: undefined color MAROON.


Is there any other package that must be declared to make this works?

I use:

\documentclass{report}

and yes I use pdftex.

-
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Marco Daniel Jul 22 '12 at 17:51
Which document class are you using? book by any chance? Are you using pdftex? Best is to provide a minimal working compilable example. –  percusse Jul 22 '12 at 18:03
I cannot recreate your error with a MWE, I used a book document class, and simply added your \chapter command. It compiled and provided a maroon chapter title. –  J M Jul 22 '12 at 18:11
Please notice the error message you posted: Package xcolor Error: undefined color MAROON. The name of the color appears uppercased in the message, which means (if you copied the error verbatim) that you used \color{MAROON} somewhere instead of \color{Maroon}. Please check that in your document you are using Maroon and not MAROON. –  Gonzalo Medina Jul 22 '12 at 19:17
Your header uses \Makeuppercase and so the color name gets uppercased. Use the optional argument of \chapter to avoid this problem or check the documentation of fancyhdr for a \nouppercase command. –  Ulrike Fischer Jul 22 '12 at 19:40

I wouldn't apply those format changes directly in the argument of the sectional units since the formatting changes will also appear in the ToC and in the headers producing undesired results; the following minimal working example reproduces the problem mentioned:

\documentclass{report}
\usepackage[dvipsnames]{xcolor}
\usepackage{lipsum}

\begin{document}

\chapter{\color{Maroon}My Title}
\lipsum[1-30]

\end{document}


since \MakeUppercase is used to produce the headers, LaTeX sees the color name as "MAROON" (uppercased) and this triggers the error message

! Package xcolor Error: Undefined color MAROON'.


To prevent this kind of problems, I suggest using the sectsty or the titlesec packages to perform changes to the sectional unit formatting. An example with sectsty:

\documentclass{report}
\usepackage[dvipsnames]{xcolor}
\usepackage{sectsty}
\usepackage{lipsum}% just to generate text for the example

\chapterfont{\color{Maroon}}

\begin{document}

\chapter{My Title}
\lipsum[4]

\end{document}


Now that additional information has been given in the comments, it's clear that a different approach is needed since the fncychap package is beeing used to produce the chapter titles in the Conny style. The MWE reproducing the problem:

\documentclass{report}
\usepackage[dvipsnames]{xcolor}
\usepackage[Conny]{fncychap}
\usepackage{lipsum}

\begin{document}

\chapter{\color{Maroon}My Title}
\lipsum[1-30]

\end{document}


In this case, the modification to the title color can be done by using \ChTitleVar of only the title in the heading must receive color:

\documentclass{report}
\usepackage[dvipsnames]{xcolor}
\usepackage[Conny]{fncychap}
\usepackage{lipsum}

\ChTitleVar{\centering\Huge\color{Maroon}}

\begin{document}

\chapter{My Title}
\lipsum[1-30]

\end{document}


If the color change must affect all the heading, a possible solution can be obtained by redefining \DOCH:

\documentclass{report}
\usepackage[dvipsnames]{xcolor}
\usepackage[Conny]{fncychap}
\usepackage{lipsum}

\makeatletter
\renewcommand{\DOCH}{%
\color{Maroon}\mghrulefill{3\RW}\par\nobreak
\vskip -0.5\baselineskip
\mghrulefill{\RW}\par\nobreak
\CNV\FmN{\@chapapp}\space \CNoV\thechapter
\par\nobreak
\vskip -0.5\baselineskip
}
\makeatother

\begin{document}

\chapter{My Title}
\lipsum[1-30]

\end{document}


-
I tried this solution but it doesn't work. May be because I am using this package to change my chapters' titles appearance: \usepackage[Conny]{fncychap} –  user16841 Jul 22 '12 at 19:29
@user16841 crucial information that should have been mentioned in the question! That's why it is (almost always) advisable to add to your questions a minimal working example illustrating the problem. In some minutes I'll give you an answer with the fncychap package. –  Gonzalo Medina Jul 22 '12 at 19:35
@user16841 I've ipdated my answer with a solution with fncychap. Please let me know if this is what you want. –  Gonzalo Medina Jul 22 '12 at 19:43
yes, it works! Thanks –  user16841 Jul 22 '12 at 20:02

I wouldn't use fncychap for any reason whatsoever. But anybody is free to harm themselves as they like. :)

Add the following declaration after having loaded xcolor:

\colorlet{MAROON}{Maroon}


A simple way to avoid coloring the headings and the table of contents entry is to use the optional argument to \chapter:

\chapter[Title]{\color{Maroon}Title}


An "automated" way that preserves the possibility of specifying a different "short title" can be as follows:

\makeatletter
\let\latex@chapter\@chapter
\renewcommand\@chapter[2][]{%
\if\relax\detokenize{#1}\relax
\latex@chapter[#2]{\color{Maroon}#2}
\else
\latex@chapter[#1]{\color{Maroon}#1}
\fi}
\makeatother
`

Of course, changing the color of "Chapter 1" or other parts of the chapter title is another thing.

-