Try   HackMD

LaTeX/Fonts & Font families

Original text includes more information and commands which unsupported in most TeX renderers developed for math notions, so I removed them from this text.

There are hundreds - if not thousands - of typefaces, or font families. Common examples include Times, Courier, and Helvetica. These families can generally be grouped into three main categories: serif, sans serif, and monospaced. LaTeX commands generally refer to these with the shorthand rm, sf, and tt respectively.

By default, LaTeX uses Computer Modern, a family of typefaces designed by Donald Knuth for use with TeX. It contains serif, sans serif, and monospaced fonts, each available in several weights and optical sizes.

Font styles

Typefaces usually come in various styles and weights, such as italic and bold. The following table lists the commands you will need to access typical font shapes.

LaTeX command Equivalent switch Output style Remarks
\textnormal{...} {\normalfont ...}
document font family
This is the default or normal font.
\textrm{...} {\rmfamily ...}
roman font family
\textsf{...} {\sffamily ...}
sans serif font family
\texttt{...} {\ttfamily ...}
teletypefont family
This is a fixed-width or monospace font.
\textit{...} {\itshape ...}
italic shape
\textbf{...} {\bfseries ...}
bold

Generally, one should prefer the commands over their equivalent switches because the former automatically corrects spacing immediately following the end of the selected style.

You may have noticed the absence of underline - this is because underlining is a byproduct of the typewriter era, and is not recommended when bold and italic type is available instead. However, underlining can be useful in some cases, such as to draw attention to changes during editing. Although underlining is available via the \underline{...} command, text underlined in this way will not break properly.

Sizing text

Built-in sizes

To scale text relative to the default body text size, use the following commands:

Command Output
\tiny
sampletext
\scriptsize
sampletext
\small
sampletext
\normalsize
sampletext
\large
sampletext
\Large
sampletext
\LARGE
sampletext
\huge
sampletext
\Huge
sampletext

These commands change the size within a given scope. For instance \Large{some words} will change the size of only some words, and does not affect the font in the rest of the document. It will work for most parts of the text.

By default, \normalsize is 10 points. Note that not every document class has unique sizes for all of the above size commands.

Absolute Point Sizes
size standard classes (except slides), beamer AMS classes, memoir slides
[10pt] [11pt] [12pt] [10pt] [11pt] [12pt]
\tiny 5 6 6 6 7 8 13.82
\scriptsize 7 8 8 7 8 9 16.59
\small 9 10 10.95 9 10 10.95 16.59
\normalsize 10 10.95 12 10 10.95 12 19.907
\large 12 12 14.4 10.95 12 14.4 23.89
\Large 14.4 14.4 17.28 12 14.4 17.28 28.66
\LARGE 17.28 17.28 20.74 14.4 17.28 20.74 34.4
\huge 20.74 20.74 24.88 17.28 20.74 24.88 41.28
\Huge 24.88 24.88 24.88 20.74 24.88 24.88 41.28

Points in TeX follow the standard American point system in which 1 pt is approximately 0.35136 mm. The standard point size used in most modern computer programs (known as the desktop publishing point or PostScript point) has 1 pt equal to approximately 0.3527 mm while the standard European point size (known as the Didot point) had 1 pt equal to approximately 0.37597151 mm.

Arbitrary sizes

The \tiny\Huge commands are often enough for your needs, but you may occasionally want an arbitrary font size.This is done with \fontsize{<size>}{<line space>}\selectfont. For example:

\\fontsize{5cm}{5.5cm}\\selectfont

sets the current font size to 5cm with 5.5 centimeter leading.

If you are using the latex or pdflatex engines, you may get a warning similar to the following:

LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <142.26378> not available
(Font)              size <24.88> substituted on input line 103.

This is because these older engines only support a fixed set of sizes - between 5 and 17 point. When he designed Computer Modern, Knuth created individual font files for these sizes, each with stroke widths and spacing optimized for that particular size. To avoid distorting them, scaling these fonts is disabled by default.

This issue is avoided when using lualatex or xelatex, which use Latin Modern - a vectorized version of Computer Modern - as the default font family. This still provides individual files at each of the original optical sizes, but will automatically scale the closest one when asked for an arbitrary size.