In LaTeX the default font typeface is the Computer Modern family. You can change this font typeface for another that better suits your style.
To change the fond typeface of the entire document, a simple line must be added to the preamble:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tgbonum}
\begin{document}
This document is a sample document to test font
families and font typefaces.
This text uses a different font typeface
\end{document}
The line \usepackage{tgbonum}
establishes the font family TeX Gyre Bonum, whose font package name is tgbonum
, as the default font for this document.
The font can also be changed for a specific element in the document.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{textwidth=7cm}
\usepackage{tgbonum}
\begin{document}
This document is a sample document to
test font families and font typefaces.
{\fontfamily{qcr}\selectfont
This text uses a different font typeface
}
\end{document}
The command \fontfamily{qcr}\selectfont
will set the TeX gyre cursor font typeface, whose fontcode is qcr
, for the text inside the braces. A lot more LaTeX font typefaces are available, see the reference guide.
The popular LaTeX font typefaces are originated from four families:
Roman, Sans Serif and Typewriter typefaces
Font | "fontpackagename" | "fontcode" | Example |
---|---|---|---|
Computer Modern Roman | cmr
|
![]() | |
Latin Modern Roman | lmodern |
lmr |
![]() |
Latin Modern Dunhill | lmodern |
lmdh |
![]() |
TeX Gyre Termes | tgtermes |
qtm |
![]() |
TeX Gyre Pagella | tgpagella |
qpl |
![]() |
TeX Gyre Bonum | tgbonum |
qbk |
![]() |
TeX Gyre Schola | tgschola |
qcs |
![]() |
Times | mathptmx |
ptm |
![]() |
Utopia / Fourier | utopia / fourier |
put |
![]() |
Palatino | palatino |
ppl |
![]() |
Bookman | bookman |
pbk |
![]() |
Charter | charter |
bch |
![]() |
Computer Modern Sans Serif | cmss
|
![]() | |
Latin Modern Sans Serif | lmodern |
lmss |
![]() |
TeX Gyre Adventor | tgadventor |
qag |
![]() |
TeX Gyre Heros | tgheros |
qhv |
![]() |
Helvetica | helvet |
phv |
![]() |
Computer Modern Typewriter | cmtt
|
![]() | |
Latin Modern Sans Typewriter | lmodern |
lmtt |
![]() |
TeX Gyre Cursor | tgcursor |
qcr |
![]() |
Courier | courier |
pcr |
![]() |
See also The LaTeX Font Catalogue, though not that not all fonts listed in the catalogue is distributed with a license that allows it to be distributed as part of TeX Live, and therefore not all those fonts are available on Overleaf.
For more information see: