-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtextformatting.tex
179 lines (169 loc) · 7.67 KB
/
textformatting.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
\chapter{Formatting Text}
\label{formatting}
\section{Emphasis}
Sometimes you need some extra punch to get your point across.
The simplest way to emphasize text in \LaTeX{} is with the \verb|\emph| command,
which \emph{italicizes} its argument:
\begin{leftfigure}
\begin{lstlisting}
\emph{Oh my!}
\end{lstlisting}
\end{leftfigure}
gives us
\begin{leftfigure}
\lm \emph{Oh my!}
\end{leftfigure}
We have other tools at our disposal:
\begin{leftfigure}
\begin{lstlisting}
We can also use \textbf{boldface} or \textsc{small caps}.
\end{lstlisting}
\end{leftfigure}
producing
\begin{leftfigure}
\lm%
We can also use \textbf{boldface} or \textsc{small caps}.
\end{leftfigure}
Be judicious when you use emphasis, especially boldface,
which excels at drawing the reader's attention away from everything around it.
\textbf{Too much is distracting.}
\section{Meeting the whole (type) family}
Boldface and italics are just a few of the many styles you can use.
A (mostly) complete list follows:
\begin{flushleftfigure}
\lm%
\begin{tabularx}{0.9\textwidth}{l|l|l}
{\normalfont Command} & {\normalfont Alternative} & {\normalfont Style} \\
\hline
\texttt{\textbackslash textnormal\{...\}} & \texttt{\{\textbackslash normalfont ...\}} & the default \\
\texttt{\textbackslash emph\{...\}} & \texttt{\{\textbackslash em ...\}} & \emph{emphasis, typically italics} \\
\texttt{\textbackslash textrm\{...\}} & \texttt{\{\textbackslash rmfamily ...\}} & roman (serif) type \\
\texttt{\textbackslash textsf\{...\}} & \texttt{\{\textbackslash sffamily ...\}} & {\fontspec{Latin Modern Sans}sans serif type} \\
\texttt{\textbackslash texttt\{...\}} & \texttt{\{\textbackslash ttfamily ...\}} & {\fontspec{Latin Modern Mono}teletype (monospaced)} \\
\texttt{\textbackslash textit\{...\}} & \texttt{\{\textbackslash itshape ...\}} & \textit{italics} \\
% WTF: LuaTeX font loading doesn't seem to know what to do with Latin Modern Roman Slant
\texttt{\textbackslash textsl\{...\}} & \texttt{\{\textbackslash slshape ...\}} & {\fontspec{lmromanslant10-regular}slanted, or oblique type} \\
\texttt{\textbackslash textsc\{...\}} & \texttt{\{\textbackslash scshape ...\}} & \textsc{Small Capitals} \\
\texttt{\textbackslash textbf\{...\}} & \texttt{\{\textbackslash bfseries ...\}} & \textbf{boldface} \\
\end{tabularx}
\end{flushleftfigure}
Prefer the first form, which takes the text to format as an argument,
over the second, which affects the group it is issued in.
The former automatically improves spacing around
the formatted text. For example,
\textit{italic type} amidst upright type should be followed
by a slight amount of additional space, called an ``italic correction''\quotekern.
The latter is your only option
when formatting multiple paragraphs
or defining the style of other commands.\punckern\footnote{%
For instance, this book's section headers are styled with
\texttt{\textbackslash Large\allowbreak\textbackslash itshape}.}
\section{Sizes}
The font size of \introduce{body text}---that is, your main content---is
usually ten points,\punckern\footnote{The standard digital publishing point,
sometimes called the PostScript point, is \otffrac{1}{72} of an inch.
\LaTeX{}, for historical reasons, defines its point (\texttt{pt})
as \otffrac{100}{7227} of an inch
and the former as ``big points''\quotekern, or \texttt{bp}.
Use whichever you would like.}
but can be adjusted by passing arguments to
\verb|\documentclass|.\punckern\footnote{Stock \LaTeX{} classes accept
\texttt{10pt}, \texttt{11pt}, or \texttt{12pt} as optional arguments.
KOMA~Script classes accept arbitrary sizes with
\monobox{fontsize=<size>}.}
To scale text relative to this default size, use the following commands:
\begin{flushleftfigure}
\lm%
\renewcommand{\arraystretch}{1.1}%
\begin{tabular}{l l}
\texttt{\textbackslash tiny} & \tiny Example Text \\
\texttt{\textbackslash scriptsize} & \scriptsize Example Text \\
\texttt{\textbackslash footnotesize} & \footnotesize Example Text \\
\texttt{\textbackslash small} & \small Example Text \\
\texttt{\textbackslash normalsize} & \normalsize Example Text \\
\texttt{\textbackslash large} & \large Example Text \\
\end{tabular}
\end{flushleftfigure}
\clearpage
\begin{flushleftfigure}
\lm%
\begin{tabular}{l l}
\texttt{\textbackslash Large} & \Large Example Text \\
\texttt{\textbackslash LARGE} & \LARGE Example Text \\
\texttt{\textbackslash huge} & \huge Example Text \\
\texttt{\textbackslash Huge} & \Huge Example Text \\
\end{tabular}
\end{flushleftfigure}
If you look carefully, you will find some subtleties at play here.
\LaTeX's default type family, Latin Modern,
comes in several \introduce{optical sizes}.
Smaller fonts aren't just shrunken versions of their big siblings---they
have thicker strokes, exaggerated features,
and more generous spacing to improve legibility at their size.
\begin{leftfigure}
\fontspec{lmroman5-regular} If I make 5 point type
\lm the same height as 11 point type,
you can easily spot the differences.
\end{leftfigure}
Back when fonts were made out of metal, multiple optical sizes were standard.
But many digital fonts only have one,
since each optical size requires a great deal of careful
design.\punckern\footnote{If you have typefaces with multiple optical sizes,
\LuaLaTeX{} and \XeLaTeX{} can make good use of them!
See \chapref{fonts} for more on font selection.}
Points and optical sizes don't tell the whole story.
Each typeface has different proportions which affect its perceived size.
(Compare Garamond, {\fontspec{Latin Modern Roman} Latin Modern},
{\fontspec{Futura-Boo}Futura},
and {\fontspec{NHaasGroteskDSPro-45Lt}\addfontfeature{LetterSpace=3}Helvetica}, all at 11 points.)
Shown below are some common terms:
\begin{centerfigure}
\includegraphics[keepaspectratio,width=0.7\textwidth]{heights.png}
\captionof{figure}{Type sits on the \introduce{baseline},
rises to its \introduce{ascender height},
and drops to its \introduce{descender height}.
The \introduce{cap height} refers to the size of uppercase letters,
and the \introduce{x-height} refers to the size of lowercase letters.}
% For size reference:
%{\sffamily\fontsize{8pt}{8pt}\selectfont This is 8-point text.}
\end{centerfigure}
If the previous commands don't give you a size you need,
you can create custom ones with \verb|\fontsize|,
which takes both a text size and a
distance between baselines.
This must be followed with \verb|\selectfont| to take effect.
For example, \texttt{\textbackslash fontsize\{30pt\}\allowbreak\{30pt\}%
\allowbreak\textbackslash selectfont}
produces
\begin{leftfigure}
\lm
\fontsize{30pt}{30pt}\selectfont
large type with no \\
additional space \\
between lines
\end{leftfigure}
{\fontsize{11pt}{11pt}\selectfont
Note how without some extra space,
or \introduce{leading},\punckern\footnote{This term comes from the days of
metal type, when strips of lead or brass were inserted
between lines to space them out.\punckern\endnote{Jan Middendorp, \textit{Shaping Text}
(Amsterdam, 2014), 71}}
descenders from one line almost collide with ascenders and capitals on
the next.
Leading is important---without it, blocks of text become uncomfortable to
read, especially at normal body sizes.\par}
Let your type breathe!\footnote{For a discussion of how much leading
to use, see \textit{Practical Typography},
as mentioned in Appendix~\ref{resources}.}
\exercises{}
\begin{itemize}
\item Learn how to underline text with the \texttt{ulem}
package.\punckern\footnote{Other typographical tools---like italics,
boldface, and small caps---are generally preferable to underlining,
but it has its uses.}
\item Use KOMA~Script to change the size and style of your section headings.
\item Learn the difference between italic and oblique type.
\item Change the default text style
(used by \verb|\textnormal| and \verb|\normalfont|) by redefining
\verb|\familydefault|.
\end{itemize}