[XeTeX] Changing the color of the fonts

Michiel Kamermans pomax at nihongoresources.com
Sun Nov 22 12:01:16 CET 2009


Lewis,

In order to set foreground/background coloring in LaTeX, you can use the 
the "color" package:

\documentclass{article}
\usepackage{color}
\begin{document}
This is plain text, {\color{yellow}this is yellow,} {\color{red}and this 
is red}.
\end{document}

Not quite sure what you mean by coloring the fonts (rather than coloring 
the text) but if you want to associate a color with a specific font, 
then you can create a macro that sticks in the color command whenever 
you issue your font command:

\documentclass{article}
\usepackage{fontspec}
\usepackage{color}
\newfontfamily{\yellowfont}{Courier}
\newfontfamily{\redfont}{Times New Roman}
\newcommand{\yf}{\yellowfont \color{yellow}}
\newcommand{\rf}{\redfont \color{red}}
\begin{document}
This is plain text, \yf this is yellow, \rf and this is red.
\end{document}

For all the details on how to use the color command, see 
http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=color - note 
that if you use the graphics or graphicx packages, color should already 
be loaded.

- Mike "Pomax" Kamermans
nihongoresources.com


More information about the XeTeX mailing list