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).
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
dvipsnames
that adds a set of 68 colors defined under the cmyk color model and which follow thedvips
driversvgnames
that adds a set of 151 colors (with a few duplicate) defined under the rgb color model and originate from the SVG 1.1 specificationx11names
that adds a set of 317 colors defined under the rgb color model
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
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.