Spring til indhold

LaTeX normally chooses the appropriate font and font size based on the logical structure of the document (e.g. sections). In some cases, you may want to set fonts and sizes by hand.


Introduction

The syntax to set a font size or font style is easy:

This is a simple example, {\tiny this will show different font sizes} and also \textsc{different font styles}.

FontSizesEx1.png


This example shows how to use the smallest available font (tiny) in LaTeX and the small caps style.

  Open an example in ShareLaTeX

Font sizes

Font sizes are identified by special names, the actual size is not absolute but relative to the font size declared in the \documentclass statement (see Creating a document in LaTeX).

In this example the {\huge huge font size} is set and 
the {\footnotesize Foot note size also}. There's a fairly 
large set of font sizes.

FontSizesEx2.png


In the example, {\huge huge font size} declares that the text inside the braces must be formatted in a huge font size. For a complete list of available font sizes see the reference guide.

  Open an example in ShareLaTeX

Font families

By default, in standard LaTeX classes the serif typeface (a.k.a. roman) font is used. The other font typefaces (sans serif and typewriter, a.k.a. monospace) can be used by entering some specific commands

In this example command and switches are used. 
\texttt{A command is used to change the style 
of a sentence}

\sffamily
A switch changes the style from this point to 
the end of the document unless other switch is used

FontSizesEx3.png


You can set up the use of sans font as a default in LaTeX document by using the command:

 \renewcommand{\familydefault}{\sfdefault}


Similarly, for using roman font as a default:

 \renewcommand{\familydefault}{\rmdefault}


  Open an example in ShareLaTeX

Font styles

The most common font styles in LaTeX are bold, italics and underlined, but there are a few more.

Part of this text is written \textsl{in different 
font style} to highlight it.

FontSizesEx4.png


In the example at the introduction the small caps style was used. In this case the \textsl command sets the slanted style which makes the text look a bit like italics but not quite. See the reference guide for a complete list of font styles.

If you want to go back to "normal" font style (default for the LaTeX class you are using), this can be done by using the \textnormal{...} command or the \normalfont switch command.

  Open an example in ShareLaTeX

Reference guide

Font sizes

Command Output
\tiny F-tiny.png
\scriptsize F-scriptsize.png
\footnotesize F-footnotesize.png
\small F-small.png
\normalsize F-normalsize.png
\large F-large.png
\Large F-large2.png
\LARGE F-large3.png
\huge F-huge.png
\Huge F-huge2.png

Default font families

typeface = family command switch command output
serif (roman) \textrm{Sample Text 0123} \rmfamily F-textrm.png
sans serif \textsf{Sample Text 0123} \sffamily F-textsf.png
typewriter (monospace) \texttt{Sample Text 0123} \ttfamily F-texttt.png

Font styles

style command switch command output
medium \textmd{Sample Text 0123} \mdseries F-textmd.png
bold \textbf{Sample Text 0123} \bfseries F-textbf.png
upright \textup{Sample Text 0123} \upshape F-textrm.png
italic \textit{Sample Text 0123} \itshape F-textit2.png
slanted \textsl{Sample Text 0123} \slshape F-textsl.png
small caps \textsc{Sample Text 0123} \scshape F-textsc.png

  Open an example in ShareLaTeX

Further reading

For more information see:

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX