103 lines
5.2 KiB
TeX
103 lines
5.2 KiB
TeX
\chapter{Text markup}
|
||
|
||
\section*{Text highlighting}
|
||
|
||
Text markup can be done in two ways: semantically or visually.
|
||
We recommend that you use semantic markup whenever possible.
|
||
In contrast to visual markup, it only states \emph{why} something is special and entrusts to \LaTeX{} \emph{how} it is going to look.
|
||
The simplest semantic markup, that was also used in the previous sentence, is an emphasis: \code{latex}{\textbackslash emph\{…\}}.
|
||
By default, this command sets text in italics.
|
||
When it is nested, the second level of emphasis is set straight again.
|
||
This kind of formatting is only perceived when reading the text and does not attract attention beforehand, as colored or bold text does (which is more appropriate for higher-level structuring purposes).
|
||
|
||
Some types of visual markup are listed in \cref{tbl:visual-markup}, but you should use them very carefully.
|
||
In principle, they can also be nested, however, for some combinations, the corresponding fonts will be missing.
|
||
Many other programs try to distort existing fonts to imitate the missing one.
|
||
As this does not look particularly good, \LaTeX{} will not do it.
|
||
So do not be surprised when your carefully nested selection of four different markups is just ignored and does not do anything at all.
|
||
|
||
\begin{table}[H]
|
||
\center
|
||
\begin{tabular}{lll}
|
||
\toprule
|
||
Markup & Command & Rendering \\
|
||
\midrule
|
||
bold & \code{latex}{\textbackslash textbf\{bold face\}} & \textbf{bold face} \\
|
||
italics & \code{latex}{\textbackslash textit\{italics\}} & \textit{italics} \\
|
||
small caps & \code{latex}{\textbackslash textsc\{small caps\}} & \textsc{small caps} \\
|
||
monospaced & \code{latex}{\textbackslash texttt\{typewriter text\}} & \texttt{typewriter text} \\
|
||
slanted & \code{latex}{\textbackslash textsl\{slanted\}} & \textsl{slanted} (please, don’t!) \\
|
||
underlined & \code{latex}{\textbackslash underline\{underlined\}} & \underline{underlined} \\
|
||
subscript & \code{latex}{\textbackslash textsubscript\{subscript\}} & x\textsubscript{subscript} \\
|
||
superscript & \code{latex}{\textbackslash textsubscript\{superscript\}} & x\textsuperscript{superscript} \\
|
||
\bottomrule
|
||
\end{tabular}
|
||
\caption{Visual markup commands}
|
||
\label{tbl:visual-markup}
|
||
\end{table}
|
||
|
||
Usually, you should not need these commands too often, as they appear by themselves when you are using semantic markup.
|
||
For instance, the \pkg{hyperref} package provides the \code{latex}{\textbackslash url\{…\}} command.
|
||
This command does not only use a mono-spaced font for \acro{URL}s, it also makes them clickable and, if necessary, wraps them without adding hyphens.
|
||
|
||
The same applies for different font sizes.
|
||
You can specify the body text font size with an option at the document class:
|
||
\codeblock{latex}{listings/text-markup/font-size.tex}
|
||
Building upon this, \LaTeX{} generates different font sizes that can be called via the commands in \cref{tbl:type-sizes}.
|
||
It is, however, best to restrict those to title pages and similar things.
|
||
For the rest, you can trust the default settings and avoid the visual clutter.
|
||
|
||
\begin{table}[H]
|
||
\center
|
||
\begin{tabular}{ll}
|
||
\toprule
|
||
Command & Rendering \\
|
||
\midrule
|
||
\code{latex}{\{\textbackslash tiny tiny\}} & {\tiny tiny} \\
|
||
\code{latex}{\{\textbackslash footnotesize footnote size\}} & {\footnotesize footnote size} \\
|
||
\code{latex}{\{\textbackslash small small\}} & {\small small} \\
|
||
\code{latex}{\{\textbackslash normalsize normal\}} & {\normalsize normal} \\
|
||
\code{latex}{\{\textbackslash large large\}} & {\large large} \\
|
||
\code{latex}{\{\textbackslash Large larger\}} & {\Large larger} \\
|
||
\code{latex}{\{\textbackslash LARGE largest\}} & {\LARGE largest} \\
|
||
\code{latex}{\{\textbackslash huge largest of all\}} & {\huge largest of all} \\
|
||
\code{latex}{\{\textbackslash Huge megalomania\}} & {\Huge megalomania} \\
|
||
\bottomrule
|
||
\end{tabular}
|
||
\caption{Font size commands}
|
||
\label{tbl:type-sizes}
|
||
\end{table}
|
||
|
||
\newpage
|
||
|
||
\section*{Paragraph alignment}
|
||
\label{sec:ragged-alignment}
|
||
By default, \LaTeX{} sets continuous text in full justification.
|
||
However, we can also switch to ragged alignment by using the commands
|
||
\code{latex}{\textbackslash raggedright}, \code{latex}{\textbackslash raggedleft}, and
|
||
\code{latex}{\textbackslash centering}.
|
||
These commands influence the environment that they are used in, e.\,g., the
|
||
\mono{document} environment. Correspondingly, the text within the whole
|
||
document is affected.
|
||
Alternatively, we can use dedicated environments in order to influence the
|
||
formatting
|
||
of certain paragraphs (\cref{lst:ragged-alignment}).
|
||
|
||
\example{lst:ragged-alignment}{formatting-paragraphs/ragged-alignment}{Ragged
|
||
alignment}
|
||
|
||
\section*{Indentation and spacing}
|
||
\label{sec:indents-and-parskips}
|
||
Usually, we illustrate a new paragraph by indenting the first line of it
|
||
(\code{latex}{\textbackslash parindent}).
|
||
Alternatively, paragraph spacing, i.\,e., vertical space between paragraphs,
|
||
can be used (\code{latex}{\textbackslash parskip}).
|
||
For both variants, there are adjustable parameters:
|
||
\codeblock{latex}{listings/formatting-paragraphs/indentation.tex}
|
||
|
||
\noindent We can use \code{latex}{\textbackslash noindent} to turn off the indentation for only one
|
||
paragraph.
|
||
For the first paragraph after a heading, there is usually no indentation.
|
||
|
||
|