Fonts in LaTeX, Part One: XeLaTeX
Now and then I get asked about how to use some TrueType or OpenType font with LaTeX, so I figured I would take the time to write up some simple tutorials on how to do so. The first part will focus on the easiest route to making use of TrueType and OpenType fonts in LaTeX: XeTeX and XeLaTeX.
XeLaTeX also has the advantage of not only giving easy access to modern fonts, but also accepting Unicode input files.
The first thing you need to do is find out if you have XeLaTeX installed, and if it is a sufficiently up to date version. This is easiest to do from the command-line:
% xelatex
This is XeTeXk, Version 3.141592-2.2-0.996 (Web2C 7.5.6)
%&-line parsing enabled.
**^C
This is the version that I am using for the tutorial, and is what comes with TeX Live 2007. I highly recommend just installing and using the entire TeX Live CD/DVD, even if you're using a Linux system that offers TeX Live packages, because, in particular for Debian/Ubuntu, I've found that the default installation often doesn't install some important packages, and it can be a pain sort through all the available packages using Synaptics or whatnot to find what it didn't install.
I am also assuming that you are using a (modern) Unix or MacOS X system. I assume that most of this material should also apply when using Windows, but if someone can comment, let me know.
Now, as an example, say you want to use the Pagella font from the TeX Gyre project. First download them and install the fonts (the otf files) as you normally would on your computer. Under MacOS X, this means using Font Book. If you double-click on an otf file it will load Font Book for you and there will be dialog with a button to install the font. If you load Font Book yourself, you can use the "Add Fonts..." menu item under the File menu to select the files. Under a modern Unix, I would recommend just placing the otf files in your ~/.fonts folder, though I think file managers like Nautilus also understand how to install fonts.
And that was all the installation work necessary; as I said, XeLaTeX is the easiest solution unless you have specialized needs. Now just create a small LaTeX document:
documentclass{article}
\usepackage{fontspec}
\setromanfont{TeX Gyre Pagella}
\begin{document}
Testing XeLaTeX!
Greek: τεχ.
\end{document}
The fontspec package isn't necessary, but it makes dealing with fonts in XeLaTeX much easier, for example it defines the convenient \setromanfont command. You can learn more about all of its great features from its beautifully formatted manual.
The other thing you might need to know is what XeLaTeX thinks your font is called. If you're using TeX Live, like I suggest, you will have the program otfinfo at your disposal that can do that for you:
% otfinfo --family texgyrepagella-regular.otf
TeX Gyre Pagella
Note that despite its name, otfinfo will also work on ttf files, assuming that they include OpenType data in them. The other option is to use Font Book on MacOS X or fc-list from the command-line in Unix.
Now you just run xelatex:
% xelatex test.tex
This is XeTeXk, Version 3.141592-2.2-0.996 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(./test.tex
...
...
Output written on test.pdf (1 page).
Transcript written on test.log.
And you have your document:
I think that is about everything you need to know, but if you try this tutorial out and find that something doesn't work, let me know. If you have more specialized or demanding typographical needs, you may want to use pdfTeX and pdfLaTeX, and part two of the tutorial will explain how to do the necessary configuration to use TrueType and OpenType fonts with them.

Alan Schmitt said,
July 12, 2008 @ 1:33 pm
Maybe you could expand on the font installation bit, saying that only the otf files are necessary.
Thanks a lot for this great tutorial, it worked out of the box here (I’m using TeX Live 2007).
Patrick Hall said,
July 12, 2008 @ 11:04 pm
I would *love* to figure out how to get utf-8 input files working with LaTeX under Ubuntu; I’ve been trying to do so for some time, with no success. I have a bunch of links to various things I’ve tried at http://del.icio.us/tag/latex+unicode .
Do you know what exactly does it takes to install the whole Texlive CD under Ubuntu? I’ve installed so many TeX packages with apt-get by now that I’m afraid I’ve lost track; I do have xelatex installed, though.
When I run your example document, I get:
$ xelatex gyre.tex
This is XeTeXk, Version 3.141592-2.2-0.996-patch1 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(./gyre.tex
LaTeX2e
Babel and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, pinyin, loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo))
(/usr/share/texmf-texlive/tex/xelatex/fontspec/fontspec.sty
(/usr/share/texmf-texlive/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texmf-texlive/tex/latex/tools/calc.sty)
(/usr/share/texmf-texlive/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texmf-texlive/tex/latex/xkeyval/xkeyval.tex
(/usr/share/texmf-texlive/tex/latex/xkeyval/keyval.tex)))
! LaTeX Error: File `lmodern.sty’ not found.
Greg said,
July 13, 2008 @ 9:58 am
@ Patrick: sudo apt-get install lmodern
Thanks for the tips! I didn’t know about XeTaTeX, and it’s awesome.
washburn said,
July 13, 2008 @ 5:33 pm
@Alan: Thanks! I just revised it a little to hopefully be clearer about installing the fonts.
washburn said,
July 13, 2008 @ 5:35 pm
@Patrick: No, offhand I do not know what set of packages you would need to install to be sure you have installed the entirety of TeX Live. This is why I just recommend installing it yourself than using the package manager. As Greg pointed out, you probably need to at least install the lmodern package.
washburn said,
July 13, 2008 @ 5:36 pm
@Greg: Thanks! I’m glad that so many people seem to be benefiting from this information.
Patrick Hall said,
July 13, 2008 @ 9:16 pm
Hi guys,
Thanks Greg and washburn, I seem to be making some progress here!
http://ruphus.com/code/unicodelatex/
So my goal is to get the extremely multilingual file
http://ruphus.com/code/unicodelatex/ohboy.tex
Into a pdf; I have had partial success:
http://ruphus.com/code/unicodelatex/ohboy.pdf
Next I’ll trying install the whole cd with the package manager as you recommend.
Thanks again
washburn said,
July 13, 2008 @ 9:22 pm
@Patrick: It looks like the problem is that you are not using a font that includes all of the necessary glyphs. It is pretty rare for a single font to include glyphs for all of those languages. So to typeset that document you are going to need to switch between multiple fonts.
Dario said,
July 18, 2008 @ 12:26 am
I thought you might enjoy a short article I wrote on expert font features using XeTeX:
http://nitens.org/taraborelli/latex