How to Change Latex Font and Font Size

# How to Change Latex Font and Font Size

This post may contain affiliate links that allow us to earn a commission at no expense to you. Learn more

LaTeX has grown to become a popular document preparation software because it takes care of many duties automatically, and produces professional-looking documents. The software chooses an appropriate font style and size for each document based on its structure.

Moreover, it allows you to change the default LaTeX font and default font size. Let’s look at the different ways to do this.

## Setting LaTeX Font Size

LaTeX offers a range of font sizes for each document. These font sizes can be identified using specific names. However, their sizes aren’t actually absolute. Instead, they are relative to the size of the font declared in the document’s \documentclass preamble.

For example, the command {\huge a huge font size} tells LaTeX that the sentence “this is the huge font size” should be formatted with huge font size.

This is an example showing {\huge a huge font size} set.

When compiled, the output will resemble:

The different commands for font size are shown in the table below:

As you can see, the smallest font is set using the command {\tiny size} while the largest one is set using the command {\huge size}.

## Adding More Font Sizes

LaTeX offers a limited number of font sizes by default. You can add more sizing options using special packages. One of these is the Extsizes package. This package offers additional sizing options for the standard LaTeX document class packages.

This includes font sizes 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, and 20pt, which applies to the article, letter, book, report and proc classes for documents.

You can add these font options to your document class name using the code \documentclass[9pt]{extbook} to add a 9pt size font for example.

## Using Different Font Styles

You can set a variety of different font styles in LaTeX. These styles can be broken down into three broad categories: family, series, and shape.

Some common font styles and their corresponding commands are shown below:

### Font Styles

Sans serif: \textsf{YOUR TEXT}

### Font Shape

small cap: \textsc{YOUR TEXT cap]

An example of different styles in use is shown below:

\documentclass{article}

\begin{document}

\textit{\textbf{ this text is shown in bold and italics.}}

\textrm{\textsl{ this text is in Times New Roman}}

\end{document}

When compiled, the output resembles:

Each sentence in the above text can also be shown in separate lines using the command \newline.

\documentclass{article}

\begin{document}

\textit{\textbf{ this text is shown in bold and italics.}\newline}

\textrm{\textsl{ this text is in Times New Roman}}

\end{document}

This produces the following output:

LaTeX also allows you to change the in-text style to italic or from italic to upright using the command \emph. For example:

\documentclass[12pt]{article}

\begin{document}

\textit{ the text in this sentence is in italic, with the exception of this \emph{word} and this \emph{word}.}

\end{document}

When compiled, the output resembles:

We can perform a similar function with boldface in place of the italics used above.

\documentclass[12pt]{article}

\begin{document}

\textbf{ the text in this sentence is in bold with this \emph{word} and this \emph{word} in italics.}

\end{document}

## More Font Families

We discussed a few font families in the examples above. However, there are many more that LaTeX offers. These font families and their corresponding codes are shown below.

• cmm: Computer Modern Italic
• cmsy: Computer Modern Symbols
• cmex:  Computer Modern Extensions
• cmr: Computer Modern Roman
• cmss: Computer Modern Sans
• cmtt: Computer Modern Typewriter
• ptm: Adobe Times
• phv: Adobe Helvetica
• pcr: Adobe Courier

You can also adjust the weights and widths for different font series. These are listed below.

• b: Bold
• sb: Semi Bold
• eb: Extra Bold
• el: Extra Light
• l: Light
• m: Medium
• sl: Semi Light
• ub: Ultra Bold
• ul: Ultra Light

For different font widths, the following options and their percentages are shown below:

uc: Ultra Condensed, 50%

ec: Extra Condensed, 62.5%

c: Condensed, 75%

sc: Semi Condensed, 87.5%

x: Expanded, 125%

ex: Extra Expanded, 150%

ux:Ultra Expanded, 200%

m: Medium, 100%

sx: Semi Expanded, 112.5%

## Using Additional LaTeX Font Typefaces

LaTeX uses the Computer Modern  typeface family by default in its documents, but you can use additional packages for more font options. For example, you can use the code \usepackage{helvet} in the preamble for Helvetica  font.

\documentclass{article}

\usepackage[T1]{fontenc}

\usepackage{helvet}

\begin{document}

This document shows different document typefaces and fonts

\end{document}

When compiled, the output font will resemble:

Some of the additional typefaces you can use are shown below, along with their package name and code.

## Troubleshooting LaTeX Font Problems

In some cases, you may encounter an error when using certain fonts. If this occurs, LaTeX will show an error message at the bottom of the window after compiling your document.

The good news is that these error messages tend to be detailed. Therefore, you can locate the error within a particular line and remove it. You can then save your file and compile it again.

## Final Thoughts

As you can see, there are a variety of different LaTeX font options. It’s not uncommon to use at least a few different font styles in a single document. Whether that is bolded or italic portions or even sentences that are presented in different font sizes.

The above guide should help you navigate through the various font options available in LaTeX. So try experimenting with different font styles to make your next document look extra special.

## Frequently Asked Questions

Some frequently asked questions related to LaTeX fonts are shown below:

### Q1. How Can I Use Different Fonts in LaTeX?

You can use fonts different from the default Computer Modern one by using the relevant code. For example, you can write text in Times New Roman font using \textrm{ YOUR TEXT}.

### Q2. How Do I Change Font Size in LaTeX?

You can use different LaTeX font sizes by using the relevant font size command. To make your font huge, you would use the command {\huge YOUR TEXT}.

### Q3. Why Aren’t My LaTeX Font Commands Working Properly?

You may encounter an error when using certain fond commands if you do not have the relevant LaTeX font packages installed. You should ensure these are added and called out in your preamble before compiling your code.