Colors in Tikz

This page is a summary of how colors work in Tikz, and provide list of available colors. TikZ uses the xcolor package under the hood. This package implements a lot of color models, and allows to tweak multiple parameters. I refer to its extensive documentation for an exhaustive overview of functionalities.

Going further than LaTeX considerations, I also want to point-out that if you ever need a simple reference covering color spaces, conversion between those spaces, standard operations on colors (blending, etc) from a computational point of view, this package's documentation can also come quite handy.

Table of contents

TikZ Color List

In the general LaTeX tips page, I provide a simple colors.tex file that overides some of the default colors and provide a few new ones. This file is not intended to provide a large spectrum of colors and I encourage everyone to tweak it and define their own colorscheme, based on their needs. In what follows, I will give a few details on which are the colors and colors operations provided by TikZ (through the xcolor package).

Default List

TikZ takes care of loading xcolor during its import, and uses xcolor's default settings. This provides the user with a list of basic colors (defined in xcolor.sty) available at all time and which can be used by refering to their name:

black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow

This list can found in the xcolor documentation (section 4. Colors by Name).

Default available colors in TikZ.
Source code for the above image.
\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc} % to compute rectangle coords on the fly
\usetikzlibrary{positioning} % for below of=
\usepackage{kpfonts}

\begin{document}

\begin{tikzpicture}
    \def \columnWidth {6};
    \def \baseWidth {0.5cm};
    \def \baseHeight {0.25cm};

    \foreach \color [count=\i from 0] in {black, blue, brown, cyan, darkgray, gray,
                                         green, lightgray, lime, magenta, olive,
                                         orange, pink, purple, red, teal, violet,
                                         yellow} {

        \coordinate (center_\color)
                        at ({2*mod(\i, \columnWidth)}, {1.5*div(\i, \columnWidth)});
        \coordinate (rectangle_bottom_\color)
                        at ($(center_\color) - (\baseWidth, \baseHeight)$);
        \coordinate (rectangle_top_\color)
                        at ($(center_\color) + (\baseWidth, \baseHeight)$);

        \draw[fill=\color, black] (rectangle_bottom_\color) rectangle (rectangle_top_\color);
        \node[below=0.5cm of center_\color] {\color};
    }
\end{tikzpicture}

\end{document}

More Color Options

As you might discover when going through xcolor's manual, more color are available assuming you manually load the package with the correct option. Among those options are

For instance, when manually importing the xcolor package before TikZ using the dvipsnames option

\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

The user can now access the following colors (note the capitalized first letter):

Apricot, Aquamarine, Bittersweet, Black, Blue, BlueGreen, BlueViolet, BrickRed, Brown, BurntOrange, CadetBlue, CarnationPink, Cerulean, CornflowerBlue, Cyan, Dandelion, DarkOrchid, Emerald, ForestGreen, Fuchsia, Goldenrod, Gray, Green, GreenYellow, JungleGreen, Lavender, LimeGreen, Magenta, Mahogany, Maroon, Melon, MidnightBlue, Mulberry, NavyBlue, OliveGreen, Orange, OrangeRed, Orchid, Peach, Periwinkle, PineGreen, Plum, ProcessBlue, Purple, RawSienna, Red, RedOrange, RedViolet, Rhodamine, RoyalBlue, RoyalPurple, RubineRed, Salmon, SeaGreen, Sepia, SkyBlue, SpringGreen, Tan, TealBlue, Thistle, Turquoise, Violet, VioletRed, White, WildStrawberry, Yellow, YellowGreen, YellowOrange

Default available colors in TikZ.
Source code for the above image.
\documentclass{standalone}

\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

\usetikzlibrary{calc} % to compute rectangle coords on the fly
\usetikzlibrary{positioning} % for below of=
\usepackage{kpfonts}


\begin{document}

\begin{tikzpicture}
    \def \columnWidth {7};
    \def \baseWidth {0.5cm};
    \def \baseHeight {0.25cm};

    \foreach \color [count=\i from 0] in {
        Apricot, Aquamarine, Bittersweet, Black, Blue, BlueGreen, BlueViolet, BrickRed,
        Brown, BurntOrange, CadetBlue, CarnationPink, Cerulean, CornflowerBlue, Cyan,
        Dandelion, DarkOrchid, Emerald, ForestGreen, Fuchsia, Goldenrod, Gray, Green,
        GreenYellow, JungleGreen, Lavender, LimeGreen, Magenta, Mahogany, Maroon, Melon,
        MidnightBlue, Mulberry, NavyBlue, OliveGreen, Orange, OrangeRed, Orchid, Peach,
        Periwinkle, PineGreen, Plum, ProcessBlue, Purple, RawSienna, Red, RedOrange,
        RedViolet, Rhodamine, RoyalBlue, RoyalPurple, RubineRed, Salmon, SeaGreen,
        Sepia, SkyBlue, SpringGreen, Tan, TealBlue, Thistle, Turquoise, Violet,
        VioletRed, White, WildStrawberry, Yellow, YellowGreen, YellowOrange} {

        \coordinate (center_\color)
                        at ({2.5*mod(\i, \columnWidth)}, {1.5*div(\i, \columnWidth)});
        \coordinate (rectangle_bottom_\color)
                        at ($(center_\color) - (\baseWidth, \baseHeight)$);
        \coordinate (rectangle_top_\color)
                        at ($(center_\color) + (\baseWidth, \baseHeight)$);

        \draw[fill=\color, black] (rectangle_bottom_\color) rectangle (rectangle_top_\color);
        \node[below=0.5cm of center_\color] {\color};
    }
\end{tikzpicture}

\end{document}

I refer the reader to section 4 of xcolor's manual for an exhaustive listing under all options. I also refer to the documentation (2.15.1) to handle name clashing if using more than one color option at once.

Color Manipulation

The xcolor package defines general and powerful expressions dedicated to working with colors, whose “grammar” is explicited in section 2 of the manual. Precise details are provided in the documentation, but for easy-reference here are some of the features enabled by those expressions.

Alpha Transparency

It is easy to control the transparency of colors. The syntax is as follow

color!alpha

With color refering to an already defined color and alpha being an integer between 0 and 100. For example:

red!20  % red with 20% opacity

Which can be directly used inside of any TikZ drawing command.

Color Blending

There is a simple syntax that allows to define color blends on the fly.

colorA!alpha!colorB

Where colorA and colorB refer to colors that will be blended, using alpha% of colorA and (100-alpha)% of colorB.

blue!45!red  % a blend of 45% of blue and 55% of red

Once again, I refer to the documentation for details on the “blending operation” meaning in color spaces.