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}

Typewriter: \texttt{YOUR TEXT}

Roman: \textrm{YOUR TEXT}

Font Series

medium: \textmd{YOUR TEXT}

boldface: \textbf{YOUR TEXT}

Font Shape

italic: \textit{YOUR TEXT}

slanted: \textsl{YOUR TEXT}

upright: \textup{YOUR TEXT}

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.

FontFont Package NameFont Code
Computer Modern Romancmr
Latin Modern Romanlmodernlmr
Latin Modern Dunhilllmodernlmdh
Latin Modern Sans Seriflmodernlmss
Timesmathptmxptm
Utopia/Fourierutopia/fourierput
Palatinopalatinoppl
Bookmanbookmanpbk
Chartercharterbch

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.

Further Reading

LaTex Tutorial

  1. 27 Pros and Cons of Using LaTex for Scientific Writing
  2. 6 easy steps to create your first Latex document examples
  3. How to add circuit diagrams in Latex
  4. How to create a Latex table of contents
  5. How to create footnotes in LaTeX and how to refer to them, using the builtin commands
  6. How to create Glossaries in LaTeX
  7. How to create plots in Latex – codes and examples
  8. How to create symbols in LaTeX – commands for Latex greek alphabet
  9. How to create tables in LaTeX – rows, columns, pages and landscape tables
  10. How to drawing graphs in Latex – vector graphics with tikz
  11. How to highlight source code in LaTeX
  12. How to insert an image in LaTeX – Managing Latex figure and picture
  13. How to Itemize and Number List – Adding Latex Bullet Points
  14. How to make hyperlink in latex – Clickable links
  15. How to reference in Latex – 5 steps to bibliography with Bibtex
  16. How to use Latex Packages with examples
  17. How to use LaTeX paragraphs and sections
  18. LaTeX Installation Guide – Easy to follow steps to install LaTex
  19. Learn to typeset and align Latex equations and math

Photo of author
Author
SJ Tsai
Chief Editor. Writer wrangler. Research guru. Three years at scijournal. Hails from a family with five PhDs. When not shaping content, creates art. Peek at the collection on Etsy. For thoughts and updates, hit up Twitter.

Leave a Comment