tex_logos_04.gif (2422 bytes)
Color text in LaTeX

The color package which is distributed with LaTeX 2e makes it very easy to use colored text in LaTeX 2e. Here is a simple demo file that shows you how to do it.


Download the .tex file to play with or the .pdf file to see the typeset output from the .tex file.

The color package also provides the commands \pagecolor, \colorbox and \fcolorbox. These commands are not discussed in this demo.

Here is the content of color-package-demo.tex. It is largely self-documenting.

%% color-package-demo.tex
%% Bent Petersen Oct 2000


\author{Bent Petersen}
\date{Oct 24, 2000}

\setlength{\parskip}{2.0ex plus 0.6ex minus 0.4ex}

The easiest way to use color text in \LaTeXe{} is to use the color
package. You load the color package in your preamble as usual
Here the option [usenames] causes the definitions for the 68 colors
known to dvips (see next page) to be preloaded. Those colors can then
be specified by name. For example \verb={\color{BrickRed} BrickRed}=
produces {\color{BrickRed} BrickRed}. Alternately one can use the
\textcolor{BrickRed}{this is BrickRed}
which produces \textcolor{BrickRed}{this is BrickRed}.
If the 68 predefined colors do not suffice, or if you do not want
to load the definitions of all of them, you may define your own
custom colors.
Here is a dark blue defined in terms of the RGB (red, green, blue) color model.
{\color{MyDarkBlue}This color is MyDarkBlue}
{\color{MyDarkBlue}This color is MyDarkBlue}
Once we have defined the new color we can use it anywhere in
the current document. For example,
\verb=\textcolor{MyDarkBlue}{a nice blue}= produces
\textcolor{MyDarkBlue}{a nice blue}.
Custom colors may also be defined in terms of the CMYK
(cyan, magenta, yellow, black)
color model. Here is a light magenta.
{\color{MyLightMagenta}This color is MyLightMagenta}
{\color{MyLightMagenta}This color is MyLightMagenta}

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


Last updated 
Thursday, April 10, 2003
Bent E. Petersen

Back to the TeX index page