Font Size
Font Size
org/wiki/LaTeX/Fonts
LaTeX/Fonts
Font families
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.
The bodies of LaTeX documents are set in Roman (serif) type by default, but this can be
changed by setting the family default:
\renewcommand{\familydefault}{<family>}
\rmdefault
\sfdefault
\ttdefault
Emphasizing text
In order to add some emphasis to a word or a phrase, use the \emph{text} command, which
usually italicizes the text. Italics may be specified explicitly with \textit{text}.
Note that the \emph command is dynamic: if you emphasize a word which is already in an
emphasized sentence, it will be reverted to the upright font.
Text may be emphasized more heavily through the use of boldface, particularly for keywords the
reader may be trying to find when reading the text. As bold text is generally read before any
1 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
other text in a paragraph or even on a page, it should be used sparingly. It may also be used in
place of italics when using sans-serif typefaces to provide a greater contrast with unemphasized
text. Bold text can be generated with the \textbf{text} command.
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.
Note: Paragraph breaks are not allowed inside the command forms.
{\rmfamily
\textrm{...}
...}
roman font family
\textsf{...}
{\sffamily sans serif font
...} family
{\ttfamily teletypefont This is a fixed-width or monospace
\texttt{...}
...} family font.
{\upshape
\textup{...}
...}
upright shape The same as the normal typeface.
{\itshape
\textit{...}
...}
italic shape
{\scshape
\textsc{...}
...}
S C
{\bfseries
\textbf{...}
...}
bold
{\mdseries
\textmd{...}
...}
medium weight The normal font weight.
2 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
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.[2]
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. Instead, use the \ul{...} command from the
soul package or \uline{...} command from the ulem (underline emphasis) package. By
default, the latter package also overrides \emph to underline instead of italicize the text. In the
likely case that this is not your intent, use the normalem option, i.e.
\usepackage[normalem]{ulem}. Both packages also provide strikethrough text with
\st{...} or \sout{...}, respectively.
Sizing text
Built-in sizes
To scale text relative to the default body text size, use the following commands:
Command Output
\tiny sample text
{\Large\tableofcontents}
These commands cannot be used in math mode. However, part of a formula may be set in a
different size by using an \mbox command containing the size command. The new size takes
3 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
effect immediately after the size command; if an entire paragraph or unit is set in a certain size,
the size command should include the blank line or the \end{...} which delimits the unit.
\scriptsize 7 8 8 7 8 9 16.59
\footnotesize 8 9 10 8 9 10 16.59
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 (see: point (typography)).
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
4 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
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 (http://ww
w.gust.org.pl/projects/e-foundry/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.
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Georgia}
\setsansfont[Ligatures=TeX]{Arial}
\begin{document}
Lorem ipsum...
\end{document}
The [Ligatures=TeX] option allows you to use the standard TeX ligatures mentioned in the
Text Formatting chapter instead of Unicode characters that are unlikely to be on your keyboard.
For example, --- can be used to create em dashes (—), quotes can be typed ``like this''
instead of “like this”, and so on.
The fontspec package is extremely configurable. See the manual[3] for details, but some
basics are covered below.
5 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
We might want to hand-pick weights to achieve a certain look or better match the weights of
other fonts in our document. Continuing to use Futura as an example, say we want to use the
"book" weight for our default weight, "demi" for bold, and the font files are named:
\usepackage{fontspec}
\setmainfont[
Ligatures=TeX,
UprightFont = *-Boo,
ItalicFont = *-BooObl,
SmallCapsFont = *SC-Boo,
BoldFont = *-Dem,
BoldItalicFont = *-DemObl
]{Futura}
Note that instead of typing out Futura-Boo, Futura-BooObl, and so on, we can use * to
insert the base name.
\setmainfont[
Ligatures=TeX,
Numbers={OldStyle, Proportional}
]{Linux Libertine}
Features can be turned on and off using \addfontfeatures{...}. Say you wanted to set a
table in lining, tabular figures:
6 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
{\addfontfeatures{Numbers={Lining, Tabular}}
\begin{tabular}{l r}
Widgets: & 25 \\
Gadgets: & 6 \\
Whatsits & 24 \\
\end{tabular}
} % Return to previous figure style
Font encoding
Digitising human language is a complicated topic that has evolved significantly since TeX's
inception.
Unicode
Today, text is usually represented in computer systems using Unicode. Briefly,
A Unicode text file is made of a series of code points, each of which can represent a
character to be drawn, an accent or other diacritical mark to combine with an adjacent
character, or some non-printing character, such as instruction to print subsequent text right-
to-left.
One or more of these code points combines to represent a grapheme cluster or glyph, the
shapes within a font that we informally call "characters".
Modern font formats such as TrueType and OpenType contain encoding tables which map
code points to the glyphs the font file contains.
LuaLaTeX and XeLaTeX use these tools to render Unicode-encoded input files (LuaLaTeX
accepts UTF-8 files, while XeLaTeX is a bit more flexible and also accepts UTF-16 and UTF-32)
into PDF documents.
TeX encodings
The original TeX and LaTeX, designed long before the advent of Unicode, use a very different
scheme. When using latex or pdflatex, you must choose an input encoding, which the
engine uses to interpret your file, and an output encoding, which the engine uses to map your
7 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
inputs to glyphs. The default font encoding is OT1, the encoding of the original Computer
Modern fonts. It contains only 128 characters, many from ASCII, but leaving out some others
and including a number that are not in ASCII. When accented characters are required, TeX
creates them by combining a normal character with an accent. While the resulting output looks
correct, this approach has some caveats compared to Unicode-based approaches:
All this is not possible with OT1; that's why you may want to change the font encoding of your
document.
Note that different fonts support different output encodings. The default Computer Modern
font does not support T1, for example. You will need Computer Modern Super (cm-super) or
Latin Modern (lmodern), which are Computer Modern-like fonts with T1 support. If you have
none of these, it is quite frequent (depends on your TeX installation) that tex chooses a Type3
font such as the Type3 EC, which is a bitmap font. Bitmap fonts look rather ugly when zoomed
or printed.
The fontenc package tells LaTeX what font encoding to use. Font encoding is set with:
\usepackage['encoding']{fontenc}
where encoding is the font encoding. It is possible to load several encodings simultaneously.
There is nothing to change in your document to use CM Super fonts (assuming they are
installed), they will get loaded automatically if you use T1 encoding. For lmodern, you will need
to load the package after the T1 encoding has been set:
\usepackage[T1]{fontenc}
\usepackage{lmodern}
8 di 9 28/01/2020, 13:01
LaTeX/Fonts - Wikibooks, open books for an open world https://en.wikibooks.org/wiki/LaTeX/Fonts
The package ae (almost European) is obsolete. It provided some workarounds for hyphenation
of words with special characters. These are not necessary any more with fonts like lmodern.
Using the ae package leads to text encoding problems in PDF files generated via pdflatex (e.g.
text extraction and searching), besides typographic issues.
Many PDF viewers have a Properties feature to list embedded fonts and document metadata.
Many Unix systems make use of the poppler tool set which features pdfinfo to list PDF
metadata, and pdffonts to list embedded fonts.
References
1. Matthew Butterick. "Bold or italic". Practical Typography. https://practicaltypography.com
/bold-or-italic.html.
2. Matthew Butterick. "Underlining". Practical Typography. https://practicaltypography.com
/underlining.html.
3. http://mirrors.ctan.org/macros/latex/contrib/fontspec/fontspec.pdf
4. Matthew Butterick. "Alternate figures". Practical Typography. https://practicaltypography.com
/alternate-figures.html.
Text is available under the Creative Commons Attribution-ShareAlike License.; additional terms may apply. By
using this site, you agree to the Terms of Use and Privacy Policy.
9 di 9 28/01/2020, 13:01