How to Change the Font in LaTeX (Family, Size and Custom Fonts)

Updated Tested on TeX Live 2025 (pdfLaTeX, XeLaTeX, LuaLaTeX), Oct 2026 6 min read

Quick answer

To change the font of a whole LaTeX document, load a font package in the preamble, for example \usepackage{newtxtext,newtxmath} for a Times-style font with pdfLaTeX. With XeLaTeX or LuaLaTeX, load fontspec and pick any installed font with \setmainfont. Change the base size with a class option such as 12pt, or locally with commands like \large.

LaTeX’s default font is Computer Modern. Which way you change it depends on your compiler: font packages for pdfLaTeX, or any installed font through fontspec with XeLaTeX or LuaLaTeX.

What you’ll learn

Change the font size

Use this when you want bigger or smaller text for the whole document or one passage.

Set the base size with a class option. The standard classes (article, report, book) accept 10pt (default), 11pt and 12pt:

\documentclass[12pt]{article}

Change the size locally with a size command inside braces:

\documentclass[12pt]{article}
\begin{document}
This is the default text size.
{\large This is large text.}
{\small This is small text.}
{\footnotesize This is footnote-sized text.}
\end{document}

Compiled LaTeX page with four lines: default 12pt text, then large, small and footnote-sized text

Size commands are declarations: they affect everything after them until the closing brace. Their actual size depends on the base size:

CommandSize with 10pt baseCommandSize with 10pt base
\tiny5pt\large12pt
\scriptsize7pt\Large14.4pt
\footnotesize8pt\LARGE17.28pt
\small9pt\huge20.74pt
\normalsize10pt\Huge24.88pt

For an exact size, use \fontsize{size}{baselineskip}\selectfont, for example {\fontsize{14}{17}\selectfont Text}. For a 14pt body, use \documentclass[14pt]{extarticle} from the extsizes package.

Change the font family

Use this when the whole document, or a passage, should be serif, sans-serif or monospace.

LaTeX has three families: roman (serif, the default), sans-serif and typewriter (monospace). To change the default family for the whole document, redefine \familydefault in the preamble:

% Whole document in sans-serif
\renewcommand{\familydefault}{\sfdefault}
% Whole document in monospace
\renewcommand{\familydefault}{\ttdefault}

Warning: \documentclass[sans]{article} is not a valid option. LaTeX ignores it and logs Unused global option(s): [sans], so the document stays serif.

For a few words, use the text commands:

  • Serif: \textrm{...}
  • Sans-serif: \textsf{...}
  • Monospace: \texttt{...}
\documentclass{article}
\usepackage{courier} % changes only the monospace (\texttt) font
\begin{document}
This is the default serif text.
\textsf{This is sans-serif text.}
\texttt{This is monospace text.}
This is regular text, but here is some code: \texttt{int x = 0;}
\end{document}

Compiled LaTeX lines in Computer Modern serif, a sans-serif line, and monospace lines set in Courier

Result: body text stays serif, \textsf gives sans-serif, and \texttt uses Courier. The courier package changes only the monospace family. For code listings, see monospace fonts for code listings.

Change the font with a package (pdfLaTeX)

Use this when you compile with pdfLaTeX, the default on Overleaf, and want a different typeface for the whole document.

Load the package in the preamble, together with \usepackage[T1]{fontenc} for proper accented characters and hyphenation:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath} % Times-style text and maths
\begin{document}
Times-style text and maths: $\int_0^1 x^2\,dx = \frac{1}{3}$.
\end{document}
PackageLookEngineMaths font
lmodernLatin Modern, a scalable Computer ModernpdfLaTeXYes, Computer Modern
newtxtext,newtxmath (newtx)Times-style serifpdfLaTeXYes, matching
mathptmxTimes-style serifpdfLaTeXYes, no bold maths
tgtermes / tgherosTeX Gyre Times and Helvetica clonespdfLaTeXNo, text only
helvet (load as [scaled=0.92]{helvet})Helvetica-style sans for \textsfpdfLaTeXNo, text only
courierCourier for \textttpdfLaTeXNo, text only
libertinusLibertinus serif and sanspdfLaTeX, XeLaTeX, LuaLaTeXWith XeLaTeX or LuaLaTeX; add libertinust1math for pdfLaTeX
fontspecAny OpenType or TrueType fontXeLaTeX, LuaLaTeXAdd unicode-math

The old times package is obsolete: it changes the text but leaves the maths in Computer Modern. Use newtx or mathptmx instead.

To combine a Times-style body with Helvetica and Courier:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{mathptmx} % Times-style text and maths
\usepackage[scaled=0.92]{helvet} % Helvetica-style sans, scaled to match
\usepackage{courier} % Courier-style monospace
\begin{document}
This is in Times New Roman, which is the default font for this document.
This part remains in Times, but \textsf{this part is in Helvetica}.
Here is some code in Courier: \texttt{int main() \{ return 0; \}}.
\end{document}

Compiled lines in a Times-style serif, with one phrase in Helvetica-style sans and a code snippet in Courier; this screenshot was made without scaled=0.92, so the Helvetica looks slightly large

Overleaf’s guide to font sizes, families and styles covers more packages.

Use any font with fontspec (XeLaTeX and LuaLaTeX)

Use this when you need a specific font, such as a university’s required typeface or a system font.

fontspec loads OpenType and TrueType fonts by name. It only works with XeLaTeX or LuaLaTeX; on Overleaf, switch the compiler through the gear icon or the File menu, then Compiler.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes} % Times-like serif
\setsansfont{TeX Gyre Heros} % Helvetica-like sans
\setmonofont{TeX Gyre Cursor} % Courier-like monospace
\begin{document}
Main text in TeX Gyre Termes, \textsf{sans text in TeX Gyre Heros}
and \texttt{code in TeX Gyre Cursor}.
\end{document}

Result: a document set in fonts that ship with TeX Live. It compiles on Overleaf, and locally with LuaLaTeX; see the common errors below if XeLaTeX can’t find them.

On your own computer, you can name any installed font. This example uses fonts that come with macOS:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial}
\setsansfont{Helvetica}
\setmonofont{Courier New}
\begin{document}
This is in Arial, which is the default font for this document.
This text is in Arial, but \textsf{this part is in Helvetica}.
Here is some code in Courier: \texttt{int main() \{ return 0; \}}.
\end{document}

Compiled document in Arial with a phrase in Helvetica and a code snippet in Courier New, produced with XeLaTeX on a Mac

  • Helvetica isn’t installed on Windows or available on Overleaf; use TeX Gyre Heros or Arial there.
  • Overleaf has a long list of fonts you can name directly, including Arial, Times New Roman and Courier New. See which fonts Overleaf supports with fontspec.
  • Font features go in the preamble: \setmainfont{TeX Gyre Pagella}[Numbers=OldStyle] gives old-style figures.

Change the font of headings

Use this when headings should look different from the body text.

The titlesec package controls section heading fonts:

\usepackage{titlesec}
\titleformat{\section}{\Large\bfseries\sffamily}{\thesection}{1em}{}
  • \section is the heading level to change; repeat for \subsection and others.
  • \Large\bfseries\sffamily sets size, weight and family.
  • \thesection prints the number, and 1em is the gap before the title.

Bold, italic, small caps and other styles

Use these commands for individual words:

CommandEffect
\textbf{...}Bold
\textit{...}Italic
\textsl{...}Slanted
\textsc{...}Small caps (if the font has them)
\emph{...}Emphasis, italic by default
\underline{...}Underline
\MakeUppercase{...} / \MakeLowercase{...}Change case
\sout{...} (ulem package)Strikethrough

Load ulem as \usepackage[normalem]{ulem}. Without [normalem], it redefines \emph to underline instead of italicise:

Compiled text where the phrase emphasized text is underlined rather than italic because ulem was loaded without normalem, alongside italic, bold, underlined and struck-through examples

Which method should you use?

MethodBest forWorks with
Class option or size commandsText sizeAll engines
\renewcommand{\familydefault}Whole document in sans or monoAll engines
Font packageA standard typeface with matching mathspdfLaTeX (some also XeLaTeX/LuaLaTeX)
fontspecAny installed or required fontXeLaTeX, LuaLaTeX

Common errors

  • Fatal Package fontspec Error: The fontspec package requires either XeTeX or LuaTeX: you’re compiling with pdfLaTeX. Switch to XeLaTeX or LuaLaTeX, or use a font package.
  • The font "…" cannot be found: the font isn’t installed on that system. On a local XeLaTeX install, fonts that come with TeX Live may not be found by name; compile with LuaLaTeX or install the font in your system.
  • Unused global option(s): [sans]: sans isn’t a class option. Use \renewcommand{\familydefault}{\sfdefault}.
  • \emph text is underlined: load ulem with [normalem].
  • Class option 14pt ignored: use extarticle or another class that supports it.

If you’re moving the document to Word afterwards, see fonts after converting LaTeX to Word, where a reference document sets the Word fonts. For long formulas in your new font, see line breaks in LaTeX equations. More formatting guides are in the LaTeX guides.

Frequently asked questions

How do I use Times New Roman in LaTeX?

With pdfLaTeX, load \usepackage{newtxtext,newtxmath} for a Times-style font with matching maths. With XeLaTeX or LuaLaTeX, load fontspec and use \setmainfont{Times New Roman} if the font is installed.

How do I make the whole LaTeX document sans-serif?

Add \renewcommand{\familydefault}{\sfdefault} to the preamble. The [sans] class option does not exist and is ignored with an Unused global option warning.

Can I use Arial in Overleaf?

Yes. Overleaf lists Arial among the fonts available to fontspec. Set the compiler to XeLaTeX or LuaLaTeX, then use \setmainfont{Arial}.

Why does fontspec give an error?

fontspec works only with XeLaTeX or LuaLaTeX. With pdfLaTeX it stops with a fatal error, so switch the compiler or use a pdfLaTeX font package instead.

Can I use 14pt in the article class?

Not as a class option; article accepts only 10pt, 11pt and 12pt. Use \documentclass[14pt]{extarticle} from the extsizes package, or \fontsize{14}{17}\selectfont for a block of text.