In the following MWE,

\usepackage[usenames,dvipsnames]{xcolor} % in order to use color names


\title{\grn Title}% Force line breaks with \\

\section{\grn Section} % compilation error in this line!
Some Text.


I get the compilation error "Package xcolor Error: Undefined color 'NGREEN' ", but it seems to me that I have correctly defined the color ngreen. What's the problem? Note that if you comment the line, I got the correct compilation for the title.

PS I get the same error compiling with latex and pdflatex.

PPS probably some of the packages are redundant.

  • 3
    I suppose the problem comes with section capitalization: add \colorlet{NGREEN}{ngreen} for a workaround. – Claudio Fiandrino Dec 4 '13 at 9:32
  • With article it works just fine. This must be related to revtex4. I've never used it, so I've no clue... – nickie Dec 4 '13 at 9:34
  • You are right @ClaudioFiandrino, adding \colorlet{NGREEN}{ngreen} it works. So the capitalization of the section title reflects to the commands? – Nicola Dec 4 '13 at 9:46
  • @nickie The guy who has sent me the .tex file used \grn to highlight his changing to the text. Probably it works fine on his laptop. I wonder why it doesn't on mine without \colorlet{NGREEN}{ngreen} – Nicola Dec 4 '13 at 9:46

You need to use \protect\grn or else \grn is expanded to \color{NGREEN} when the section heading is converted to upper case.

\section{\protect\grn This is a section}

This is not specific to revtex except in that revtex capitalises section headings. To cause the same problem in any document class you can use

\MakeUppercase{\grn abc}

and the solution (\protect) is the same.

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.