\usepackage{lmodern}
pdfLaTeX font packages
With pdfLaTeX, fonts are selected by loading a font package. Always include \usepackage[T1]{fontenc} first for correct output encoding. The example below shows the recommended setup with commented alternatives.
Latin Modern
The default LaTeX font — an extended Computer Modern with full T1 encoding support. Recommended starting point.
TeX Gyre Pagella
A polished Palatino clone. Slightly wider with elegant serifs — popular in academic and book typesetting.
TeX Gyre Heros
A Helvetica clone. Pairs well with Pagella or Latin Modern for headers and captions.
Inconsolata
A programmer-friendly monospaced font with better readability than the default Courier.
\documentclass{article}
% Encoding — required for proper output with pdfLaTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
% --- Serif fonts (pick one) ---
% \usepackage{lmodern} % Latin Modern (default, recommended)
% \usepackage{palatino} % Palatino — elegant, slightly wider
% \usepackage{tgpagella} % TeX Gyre Pagella — polished Palatino clone
% \usepackage{times} % Times New Roman look-alike
% --- Sans-serif fonts (pick one) ---
% \usepackage{helvet} \renewcommand{\familydefault}{\sfdefault}
% \usepackage{tgheros} \renewcommand{\familydefault}{\sfdefault}
% --- Monospaced fonts (pick one) ---
% \usepackage{courier} % Courier monospaced
% \usepackage{inconsolata} % Inconsolata — more readable
\usepackage{lmodern}
\begin{document}
This paragraph is set in Latin Modern, the default LaTeX font.
{\sffamily This text uses the sans-serif font family.}
{\ttfamily This text uses the monospaced (typewriter) font.}
\end{document}\setmainfont{TeX Gyre Pagella}
fontspec for XeLaTeX and LuaLaTeX
fontspec gives you direct access to any OpenType or TrueType font installed on the system. Use \setmainfont, \setsansfont, and \setmonofont to define the three font families globally.
BoldFont
BoldFont = {Source Sans Bold}
Override which font file is used for \textbf{}.
ItalicFont
ItalicFont = {Source Sans Italic}
Override the italic variant for \textit{}.
Scale
Scale = 0.9
Scale the font relative to the main font size — useful for monospaced fonts.
Numbers
Numbers = OldStyle
Enable OpenType old-style (lowercase) numerals for more readable body text.
Ligatures
Ligatures = TeX
Enable TeX-style ligatures such as -- for en-dash and --- for em-dash.
Kerning
Kerning = On
Enable optical kerning adjustments between character pairs.
\documentclass{article}
% fontspec requires XeLaTeX or LuaLaTeX
\usepackage{fontspec}
% Set the main (serif) font — use any font installed on the system
\setmainfont{TeX Gyre Pagella}
% Set the sans-serif font
\setsansfont{TeX Gyre Heros}
% Set the monospaced font
\setmonofont[Scale=0.9]{Inconsolata}
% Load a font with specific features
\newfontfamily\titlefont{TeX Gyre Termes}[
BoldFont = {TeX Gyre Termes Bold},
ItalicFont = {TeX Gyre Termes Italic},
]
\begin{document}
Regular text is set in TeX Gyre Pagella.
{\sffamily Sans-serif text uses TeX Gyre Heros.}
{\titlefont This paragraph uses the custom \textbackslash titlefont family.}
\texttt{Monospaced code uses Inconsolata at 90\% scale.}
\end{document}\section{Font sizes}
Font size commands and line spacing
LaTeX provides ten relative size commands. The actual point size depends on the document class base size (10 pt, 11 pt, or 12 pt). The setspace package handles line spacing cleanly without affecting font size.
\tiny
5 pt
\scriptsize
7 pt
\footnotesize
8 pt
\small
9 pt
\normalsize
10 pt
\large
12 pt
\Large
14 pt
\LARGE
17 pt
\huge
20 pt
\Huge
25 pt
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{setspace} % line spacing
\begin{document}
% ---- Font size commands ----
{\tiny tiny (5pt)} \\
{\scriptsize scriptsize (7pt)} \\
{\footnotesize footnotesize (8pt)} \\
{\small small (9pt)} \\
{\normalsize normalsize (10pt)} \\
{\large large (12pt)} \\
{\Large Large (14pt)} \\
{\LARGE LARGE (17pt)} \\
{\huge huge (20pt)} \\
{\Huge Huge (25pt)} \\
\vspace{1em}
% ---- Line spacing ----
\begin{singlespace}
Single-spaced paragraph using the setspace package.
\end{singlespace}
\begin{doublespace}
Double-spaced paragraph — common for draft submission.
\end{doublespace}
% Compact half-line increase
\setstretch{1.25}
Paragraph at 1.25$\times$ line spacing.
\end{document}\section{Google Fonts}
Using Google Fonts in LaTeX
Google Fonts are distributed as TrueType or OpenType files. With XeLaTeX or LuaLaTeX + fontspec you can use them by name once installed. Here is the recommended workflow:
Download the font
Visit fonts.google.com, select the font, and download the .ttf or .otf files.
Install on the system
On Linux: copy to ~/.fonts/ or /usr/share/fonts/ and run fc-cache -fv. On macOS: open in Font Book. On Windows: right-click the file and select Install.
Use with fontspec
\setmainfont{Inter}[Ligatures=TeX] — use the exact font family name. Confirm availability with fc-list | grep "Inter" on Linux/macOS.
Engine requirement
Google Fonts require XeLaTeX or LuaLaTeX with fontspec. pdfLaTeX only supports fonts compiled into the TeX distribution. FormaTeX supports all three engines — compare engines.
\section{Common pitfalls}
Avoid these font mistakes
fontspec requires XeLaTeX or LuaLaTeX
fontspec cannot be used with pdfLaTeX. If you want system fonts or OpenType features, switch engines. FormaTeX supports all three — see the engine comparison guide.
Missing T1 encoding with pdfLaTeX
Without \usepackage[T1]{fontenc} the output uses OT1 encoding, which lacks proper hyphenation for accented characters and makes copy-paste from the PDF unreliable.
Scaling math fonts separately
Body font changes do not automatically scale the math font. Use packages like newtxmath, newpxmath, or mathasaccents that match your chosen text font.
Loading font packages in the wrong order
Load fontenc and inputenc before any font package. With fontspec, load it first and then any additional OpenType feature packages.
\section{FAQ}
Frequently asked questions
\section{Related guides}
Keep learning LaTeX
Explore more guides and try every example live in the FormaTeX playground.
Try custom fonts in the playground
Compile with pdfLaTeX, XeLaTeX, or LuaLaTeX — all in the browser. Free tier, no credit card required.

