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, https://www.overleaf.com/learn/latex/Articles/Unicode%2C_UTF-8_and_multilingual_text%3A_An_introduction.
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
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.
to change fonts used w/ different families use the following commands:
-
\setmainfont{<font-family>}
-
\setromanfont{<font-family>}
, https://tex.stackexchange.com/questions/211394/fontspec-sans-serif-as-main-font -
\setsansfont{<font-family>}
-
\setmonofont{<font-family>}