...type using color?

Emphasizing text using color is a common feature with a typical word processor. You can type with color in $latex \LaTeX$, too, through the use of a package. Packages extend the capabilities of your document or make it easier to do what you want. There are many packages that come with your distribution of $latex \LaTeX$ and there are many others that don't. The best place to go to learn about the various packages is at CTAN, which is an acronym for "Comprehensive $latex \TeX$ Archive Network". Popular packages include amsmath typesetting mathematics, geometry for setting margins, tikz or pstricks for creating graphics, and various packages for changing the fonts more easily. The standard choice for color is xcolor;he "x" in xcolor signifies it is an extension of the earlier color package.

To use a package, declare it in the preamble. For the xcolor package it would be:


The xcolor package lets you reference by name the base colors black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow in your document. Colored text is then created using the textcolor command by specifying the color of the text followed by the text: \textcolor{red}{here} typeset "here" in red. You can soften these colors using the ! symbol followed by the percentage of that color you want: \textcolor{orange!40}{softened color} produces the text "softened color" which is 40 percent of the orange color.

Multiple colors can be mixed by using a ! to separate the colors: \textcolor{blue!60!green}{some blue some green} produces "some blue some green" in a color which is 60 percent blue and 40 percent green. Note the second color has a ! before it and the percentage is determined by how much color is left over (100 - 60 = 40). Mixing more colors is done in a similar fashion: \textcolor{red!30!purple!40!yellow}{multiple colors}.
produces "multiple colors" in text that is 30 percent red, 40 percent purple, and 100-40-30=30 percent yellow. Aside from the base colors you can access many other color names by choosing an option when you declare the xcolor package. For example, \textcolor[x11names]{xcolor} uses the x11names option which gives you the most additional color names to choose from. Using x11names, a color LightSkyBlue1 is defined so \textcolor{another defined color name}{LightSkyBlue1 color} will not not give an error.

See the xcolor documentation at CTAN for the various options and respective color names. The following tex file and its output illustrates the xcolor package ColorText (.tex) and ColorText (PDF)

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code