# Creating new colors in xcolor for use in listings

I'm trying to include some code using \usepackage{listings}. However the default look is not very pretty, so I want to customize it a bit. I've read some of the other posts about changing the layout of the code so I tried this:

    \usepackage{listings}
\usepackage[rgb]{xcolor}
\lstset{%
language=C++,%
backgroundcolor=\color{yellow!20},% sets backgroundcolor
basicstyle=%
\scriptsize \color{black},% basic font setting
\color{OliveGreen}
}


But OliveGreen is undefined. Green is not good looking at all, so I would like to know how I can mix/create my own colors? Or maybe use another package with more standard colors in it.

-

The OliveGreen color is defined in dvipsnam.def, so you get it with

\usepackage[rgb,dvipsnames]{xcolor}


Alternatively, you can define it by stating

\definecolor{OliveGreen}{rgb}{0,0.6,0}


in your document preamble. In both cases, you can use the color by name where you wish.

With the dvipsnames option the OliveGreen color is defined in the CMYK model with what would be

\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}


but the same xcolor package will convert it to the rgb specification above.

This is what I get from the following test document:

\documentclass{article}
\usepackage[rgb,dvipsnames]{xcolor}

\definecolor{OliveGreenCMYK}{cmyk}{0.64,0,0.95,0.40}
\definecolor{OliveGreenRGB}{rgb}{0,0.6,0}

\begin{document}