Coloring
This article explains how to use colour in your LaTeX document via the color or xcolor packages.
There are 2 packages that supports the process of coloring your document in : color
and xcolor
. While both packages provide a common set of commands for colour manipulation, but xcolor
is more flexible and supports a larger number of colour models, so is the recommended approach.
The xcolor
package
xcolor
packageLet's look at xcolor
in action:
This example produces the following output:
\color{magenta}
- set themagenta
color for the following block of text - in this case isitemize
\textcolor{red}{easily}
: Changes the colour of inline text. This command takes two parameters, the colour to use and the text whose colour is changed.\colorbox{orange}{orange background}
: Changes the background colour of the text passed in as the second argument.
Supported colors
If loaded with not special options, the default color pallete of xcolor
is:
However, you can get access to more named colors via the following options:
dvipsnames
: loads 68 named colours (CMYK)svgnames
: loads 151 named colours (RGB)x11names
: loads 317 named colours (RGB)
For example, if you import the xcolor
package with: \usepackage[dvipsnames]{xcolor}
, you will get the following colors:
For reference:
Last updated