LaTeX font example - controlling font colors in Latex documents

LaTeX FAQ: "How do I use font colors in LaTeX?"

Defining and using font colors in LaTeX documents turns out to be pretty easy, and it's a great LaTeX feature. Although my choice of colors may leave something to be desired, this example requirements specification was written with LaTeX, and converted to HTML using the latex2html conversion program.

(A really cool thing is that I also generated a LaTeX PDF version of that same requirements specification from the same LaTeX source files. Being able to create a LaTeX HTML document and a LaTeX PDF document from the same LaTeX source is really a terrific feature for technical specifications like this. (Not to mention that you can also keep all your LaTeX source files in a version control system, like CVS or SVN.))

How to define and use LaTeX font colors

In the preamble of your LaTeX document use this tag to include the color package:

\usepackage{color}

Then, when you need to use a different color in your LaTeX document, use a tag like this:

Here's a cool site you should check out:
{\color{blue}{http://www.devdaily.com/}}

A small, complete LaTeX font example document

Oops, I skipped an important part ... earlier in your LaTeX document you need to define what you mean by the color named "blue". A full (but brief) document might look like this:

\documentclass[letterpaper,11pt]{report}
\usepackage{color}
\definecolor{Blue}{rgb}{0.3,0.3,0.9}
\begin{document}

Here's a cool site you should check out:
{\color{Blue}{http://www.devdaily.com/}}

\end{document}

In this LaTeX example I've defined my own color "Blue" with the RGB values shown. Piece of cake ... well, once you know how to do it. ;)

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.