in the name of god, the most beneficent, the most merciful


latex: manage fonts

i will show which tex commands i use for selecting different fonts when creating tex document. all the info below is just a summary of the following articles.

compiling

for compiling tex document i recommend that you use xelatex instead of pdflatex engine because of its native support of utf-8.[1]

fonts

make sure otf or ttf fonts are installed on your machine.

fontspec package

for you to be able to configure fonts make sure you use the fontspec package in the preamble of your tex document.

\usepackage{fontspec}

set default font family

The bodies of LaTeX documents are set in Roman (serif) type by default, but this can be changed by setting the family default:

\renewcommand{\familydefault}{<family>}

where <family> is any of the following:

  • \rmdefault

  • \sfdefault

  • \ttdefault

 — from wikibooks[2]

selecting font

By default, LaTeX uses Computer Modern, a family of typefaces designed by Donald Knuth for use with TeX. It contains serif, sans serif, and monospaced fonts, each available in several weights and optical sizes [2].

to change fonts used w/ different families use the following commands:

  • \setmainfont{<font-family>}

  • \setromanfont{<font-family>}[3]

  • \setsansfont{<font-family>}

  • \setmonofont{<font-family>}