Fonts in LaTeX

From Exterior Memory
Jump to: navigation, search

Font Variants


Like in other text-editing programs, you can choose the font you like. E.g. Times New Roman, Palatino, Verdana, Utopia, Computer Modern (cm), Latin Modern (lm), etc. All these examples are in fact called font families in the typesetting world.

In most typesetting programs you stick with one font family, although you may temporarily switch for specific blocks of text (e.g. switch to a monospaced font family for code listings).

The LaTeX notion of font families is slightly different. It remembers at least three font families at any given time, one for each generic family names (serif, sans-serif, monospaced). If you want to use a different font family, first you have to assign a specific font to one the the generic families of LaTeX, and then switch to that family. The idea is that you only assign fonts to these three generic font families once (at the start of your document) and only change between the font families later on in your document.

The University of Florida has a good overview of LaTeX font variants.

Latex knows about the following style variants:

Font families
LaTeX knows about at least three generic font families: roman / serif (rm), sans-serif (sf), and typewriter / monospaced (tt). In addition, there are lesser know families such as those for mathematical formulas, Sans Quotation, Typewriter proportional, Fibonacci and Dunhill. Only the Computer Modern and Latin Modern fonts provide these latter families. Cursive, as defined in CSS, is not a special font family type in LaTeX.
LaTeX knows about the following series: medium, bold. There are other series for weight (such as semi-bold and bold extended) and width (such as condensed), but those are very uncommon.
LaTeX knows the following shapes: normal, italic, slanted (oblique) and Small Capitals. Emphasis (emph) is not a shape; it is simply rendered as (Italic in regular or small capital text, but regular in italic or slanted text). Upright Italic and Outline are two other, but uncommon, shape variants.
Font size
LaTeX default font size is 10 points. It can be decreased or increased, ranging from tiny (5pt), scriptsize (7pt), footnotesize (8pt), small (9pt), normalsize (10pt), large (12pt), Large (14pt), LARGE (18pt), huge (20pt) to Huge (24pt)

It is possible to combine families, series, shapes and sizes (e.g. serif, bold, italic, small). However, it is not possible to combine within a group (e.g. monospaced sans-serif or small italic capitals are not possible).

There is no easy command to choose semi-bold face, like there is for bold (textbf). However, you can set semi-bold as the default boldface using



Font typesetting is non-trivial. As the University of Cambridge's LaTeX and fonts documentation puts it:

Typesetting's an old, arcane, aesthetics-ridden subject of which fonts are a small but surprisingly complex part. Even apparently simple operations are non-trivial - for example, when a character is enlarged, the lines are proportionally thinner than when the character is reduced. Rules for controlling these changes (and anti-aliasing, kerning etc) are contained in hints that form part of the font definition.

LaTeX is a relative old typesetting system, so when it was designed, no standards in font specification existed. The method designed by LaTeX involves glyphs stored in the metafont (MF) files and hints stored in TFM (TeX Font Metric) files.

There were multiple standards to map between computer codes and glyphs. Where the inputenc package allows you to specify the text encoding of your .tex file (e.g. ASCII, Latin-1, UTF-8), the fontenc packagage allows you to specify the font encoding, such as ot1, t1 or 8r. LaTeX's default is to use OT1, but you really want to use T1 (Type 1 fonts) as the default, or switch to OpenType. Type 1 can be set using the fontenc package:


Furthermore, the glyphs in each font can be encoded in different ways, Adobe's Postscript type 1, TrueType and OpenType. OpenType is an integrated superset of Postscript Type 1 and TrueType. The introduction chapter of The XeTeX Companion by Michel Goossens et al. describes the historic formats in detail.

Werner Lemberg explained the difference between input encoding, font encoding, characters and glyphs in Unicode Support in the CJK Package

LaTeX Fonts versus System Fonts

LaTeX by default uses a very complex infrastructure for fonts. Frankly, I never mastered it, and do not intend to ever understand, because I consider it arcane and archaic.

While the above system is still in widespread use, you no longer need to use it. XeTeX (and XeLaTeX) is a variant of PdfTeX (and PdfLaTeX) that supports OpenType or TrueType fonts definitions. All modern LaTeX distributions, such as TeXLive, contain xelatex support.

So this is your choice:

Use LaTeX (TFM-based) fonts
Advantage: still in wide-spread use.
Use System (OpenType/TrueType) based fonts
Advantage: no need to cope with the old an arcane, can use all modern fonts. Disadvantage: deviate from the default.

The header lines in a TeX file for using TFM files typically looks like this:

%!TEX TS-program = pdflatex
\usepackage{lmodern} % Use Latin Modern instead of Computer Modern

The header lines in a TeX file for using TrueType/OpenType files typically looks like this:

%!TEX TS-program = xelatex
\defaultfontfeatures{Mapping=tex-text}  % For archaic input (e.g. convert -- to en-dash)
\setmainfont{CMU Serif}                 % Computer Modern Unicode font
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}

Furthermore, instead of typesetting your LaTeX file with pdflatex:

pdflatex mydoc.tex

You need to typeset with xelatex:

xelatex mydoc.tex

Specifying Fonts to Use

Using LaTeX Fonts

Use this if you use old-fashioned TFM fonts

To specify a given font family:

\renewcommand{\ttdefault}{pcr}  % change serif family to Courier (pcr)

The above requires you to know the name of each font, like pcr for Courier. Because no-one can seem to remember this, packages have been created with only this line. So now you can simply write \usepackage{courier} instead of the above.

Other examples are:

\usepackage{chancery} % change serif to Zapf Chancery (a cursive font), leaving sans-serif and monospace intact.
\usepackage{times}    % changes serif to Times; sans-serif to Helvetica; monospaced to Courier
\usepackage{lmodern}  % use the Latin Modern font

The following table shows which font is set using which package. The table is taken from the PSNFSS manual, the PostScript New Font Selection Scheme, the LaTeX code that handles PostScript fonts.

Package Roman Font Sans-Serif Font Monospaced Font Math Font
default CM Roman CM Sans Serif CM Typewriter ≈ CM Roman
lmodern LM Roman LM Sans Serif LM Typewriter
mathpazo Palatino ≈ Palatino
mathptmx Times ≈ Times
times Times Helvetica Courier
palatino Palatino Helvetica Courier
bookman Bookman Avant Garde Courier
newcent New Century Schoolbook Avant Garde Courier
charter Charter
chancery Zapf Chancery
utopia Utopia
helvet Helvetica
avant Avant Garde
courier Courier

Further reading:

Using System Fonts

Use this if you use modern TrueType fonts

To specify fonts using TrueType:

\defaultfontfeatures{Mapping=tex-text}  % For archaic input (e.g. convert -- to en-dash)
\setmainfont{CMU Serif}                 % Computer Modern Unicode font
\setmonofont{CMU Typewriter Text}
\setsansfont{CMU Sans Serif}

Further reading:

Installing New Fonts

Using LaTeX Fonts

Installing new fonts in LaTeX is hard, and may require you to adjust font definitions, compile new font files, etc.

Others have better documented this:

Using System Fonts

You just install the fonts the same way as you install other fonts in your system.

Available Fonts

Recommended OpenType Fonts

The following three fonts are good font choices. They all have serif, sans-serif and monospaced variants, and Unicode character support for Latin and Cyrillic scripts.

Linux Libertine
Linux Libertine (serif) and the Linux Builinum (non-linear serif) are beautifully shaped fonts, with extensive Unicode support. It was quickly adopted by Wikipedia as their default font. Perfect choice for printed and on-screen usage. Not the best choice for listing of source code.
Computer Modern Unicode (CMU)
The standards LaTeX font is Computer Modern. Latin Modern and Computer Modern Unicode are newer alternative with much better Unicode support.
Deja Vu
Deja Vu and its predecesor Bitstream Vera are originally designed for good visibility of source code, they both also contain regular serif and sans serif variants.

If you want more variations, have a look at the TeX Gyre Fonts collection for modern OpenType fonts, which provides:

  • Adventor, a sans serif font based on ITC Avant Garde Gothic by Herb Lubalin and Tom Carnase (1970);
  • Bonum, a serif font based on Bookman Old Style by Alexander Phemister (1860);
  • Chorus, a cursive font based on Zapf Chancery by Hermann Zapf (1979);
  • Cursor, a monospaced serif font based on Courier by Bud Kettler (1955);
  • Heros, sans serif font based on Helvetica by Max Miedinger (1957);
  • Pagella, a serif font based on Palatino by Hermann Zapf (1940);
  • Schola, a serif font based on Century Schoolbook by Morris Fuller Benton (1919);
  • Termes, a serif font based on Times by Stanley Morison (1932).

Further sources:

Advanced Typesetting Options

XeTeX has very good support for glyph variants, while PdfTex does not. See:

On the other hand, PdfTex does support microtypographic features, while XeTeX does not (source: ∃xistential Type)

Available LaTeX Fonts

To choose a font of your liking, please visit Here are some common examples.

Below are some fonts which are installed by default.

Serif Fonts

Abbreviation Font Name
cmr Computer Modern Roman (default)
lmr Latin Modern Roman
pbk Bookman
bch Charter
pnc New Century Schoolbook
ppl Palatino
ptm Times

Sans Serif Fonts

Abbreviation Font Name
cmss Computer Modern Sans Serif (default)
lmss Latin Modern Sans Serif
pag Avant Garde
phv Helvetica

Typewriter Fonts

Abbreviation Font Name
cmtt Computer Modern Typewriter (default)
lmtt Latin Modern
pcr Courier

Furthermore, the Bera Mono (BitStream Vera Mono) and LuxiMono fonts were designed to look good when used in conjunction with the Computer Modern serif font.


Cursive Fonts

Since LaTeX has no generic family group for cursive fonts, these fonts are usually assigned to the roman family.

Abbreviation Font Name
pzc Zapf Chancery

Mathematical Formula Fonts

Abbreviation Font Name
cmm Computer Modern (math italic)
cmsy Computer Modern (math symbols)
zplm Palatino (math)

Character Set

Each font family may support UTF-8 which allows you to typeset non-latin glyphs (e.g. Greek, Cyrillic, Armenian, Hebrew, Arabic, Devanagari, Gurmukhi, Gujarati, Tamil, Thai, Tibetan, Georgian, Hangul, Cherokee, Mongolian, Braille, Han, Hiragana, Katakana, Bopomofo, Yi, Deseret, Shavian, and many other scripts).

Bold Typewriter is Not Bold

Error: \texttt{Typewriter \textbf{Bold}} gives normal (not bold) text.

The standard LaTeX typewriter (Computer Modern) font does not have a distinguishable bold variant. Neither does the replacement font Latin Modern.

See LaTeX Bold Typewriter Font how to solve this.