Many users don't just want to use black text on a white background with LaTeX, but also want to be able to change the color of the font or other elements. One package that is suitable for this is the xcolor package, which makes it quite easy to change the color of the font, for example. This is done with \usepackage{xcolor} as usual. However, it should be noted that a large number of colors are only available to the user when the corresponding option is set when xcolor is included.
The option plays an essential role in the package. They not only activate most of the available colors, but also certain commands are only available when the corresponding option is set.
The first group of options refers to the color models. Per default, natural is set here, which means that the colors remain in their model, with the exception of RGB, HSB and Gray which are transferred to rgb, hsb and gray. If another option is set here, the colors will be transferred to the corresponding model.
Options that are transferred directly are rgb, cmy, cmyk, hsb and gray. The options RGB and HTML are transferred to rgb, HSB to hsb and Gray to gray.
The second group of options refers to the predefined colors and their use. The options dvipsnames, svgnames and x11names each load a set of predefined colors. The option table ensures that the colortbl usepackage is loaded, so that tables (rows, columns and cells) can also be colored. The hyperref option adapts the hyperref usepackage to the xcolor usepackage.
Options | Description |
rgb, cmy, cmyk, hsb and gray (RGB, HTML, HSB and Gray) | transfer all colors to the specified color model. |
dvipsnames, svgnames and x11names | Load a set of predefined colors each. |
table | Includes the colortbl usepackage and allows the use of colors within tables. |
hyperref | Adapt the hyperref usepackage to the usexcolor package. |
\usepackage{xcolor}
black | darkgray | gray | lightgray | white | |||||
yellow | orange | red | purple | pink | |||||
magenta | violet | blue | cyan | teal | |||||
green | lime | olive | brown |
To be able to use these colors, the option dvipsnames must be set:
For example:\documentclass[xcolor=dvipsnames]{article}
Apricot | Cyan | Mahogany | |||
ProcessBlue | SpringGreen | Aquamarine | |||
Dandelion | Maroon | Purple | |||
Tan | BitterSweet | DarkOrchid | |||
Melon | RawSienna | TealBlue | |||
Black | Emerald | MidnightBlue | |||
Red | Thistle | Blue | |||
ForestGreen | Mulberry | RedOrange | |||
Turquoise | BlueGreen | Fuchsia | |||
NavyBlue | RedViolet | Violet | |||
BlueViolet | Goldenrod | OliveGreen | |||
Rhodamine | VioletRed | Brickred | |||
Gray | Orange | RoyalBlue | |||
White | Brown | Green | |||
OrangeRed | RoyalPurple | WildStrawberry | |||
BurntOrange | GreenYellow | Orchid | |||
RubineRed | Yellow | CadetBlue | |||
JungleGreen | Peach | Salmon | |||
YellowGreen | CarnationPink | Lavender | |||
Periwinkle | SeaGreen | YellowOrange | |||
Cerulean | LimeGreen | PineGreen | |||
Sepia | CornflowerBlue | Magenta | |||
Plum | SkyBlue |
With xcolor you can now set pages, backgrounds, fonts, text, frames and fields in the available colors.
With the command \definecolor{color name}{color set}{value} you can define your own colors.
Example: \definecolor{MyBlue}{rgb}{0.9,0.9,1}The \color{Color} command changes the default color from black to the selected color. With \color{green} everything turns green, not only the font, but also elements like tables etc...
The \pagecolor{Color} command changes the page color. For example \pagecolor{red} then the page becomes red instead of white.
Text |
red text on yellow background |
Within tables, individual cells, columns, and rows can be colored. To be able to use the commands, the option table must be set.
\begin{tabular}{r>{\columncolor{red}}cl} A & B & C \\ 1 & 2 & 3 \\ A & B & C \\ \end{tabular}
a2 + b2 = c2 |
\fcolorbox{red}{white}{ \parbox{0.3\textwidth}{ \begin{itemize} \item listing \item key point 1 \item key point 2 \end{itemize}} } \fcolorbox{blue}{white}{ \parbox{0.3\textwidth}{ \begin{enumerate} \item enumeration \item key point \item key point \end{enumerate}} }
|
|