148 lines
9.6 KiB
TeX
148 lines
9.6 KiB
TeX
\chapter{Special characters}
|
||
|
||
\label{sec:special-characters}
|
||
|
||
\section{Spaces}
|
||
|
||
The special character used most frequently is a simple space between words.
|
||
\LaTeX{} creates it whenever the source code contains spaces or single newlines (by hitting the enter key once) between other characters.
|
||
The word space is not the only one, though\,---\,there are a few more types of spaces.
|
||
\Cref{lst:spaces} illustrates how they are used.
|
||
|
||
\example{lst:spaces}{special-characters/spaces}{Different spaces in \LaTeX}
|
||
|
||
\paragraph{English Spacing}
|
||
In documents written in English, \LaTeX{} uses traditional English Spacing by default. That is, double spaces after each sentence.
|
||
We can prevent this by using the command \code{tex}{\textbackslash frenchspacing} above the first paragraph.
|
||
With \code{latex}{\textbackslash nonfrenchspacing}, we can reset the behavior.
|
||
When using English Spacing, \LaTeX{} tries to recognize abbreviations and to use normal spaces after those.
|
||
We should still check this and\,---\,where necessary\,---\,enforce word spaces (\mono{.\textbackslash␣}) or sentence spaces (\mono{\textbackslash @.␣}).
|
||
|
||
\section{Hyphens and dashes}
|
||
There are different kinds of horizontal lines being used as punctuation,
|
||
most frequently the hyphen (-), the en dash (–) and the em dash (—).\footnote{They are named after the letters N and M,
|
||
that occupy roughly the same space.
|
||
The letter M is also about as wide as it is tall, and the amount is called a \emph{Geviert} in German, hence the German terms \emph{Halbgeviertstrich} and \emph{Geviertstrich} for the two dashes.}
|
||
These three characters are created in \LaTeX{} by different numbers of consecutive hyphens in the source code,
|
||
as shown in \cref{tbl:bars}.
|
||
|
||
\begin{longtable}{@{}llp{7.8cm}@{}}
|
||
\toprule
|
||
Code & Character & Usage \\
|
||
\midrule
|
||
\code{latex}{-} & Hyphen & a small-sized stroke \\
|
||
\code{latex}{-{}-} & En dash & a range mark (8\,--\,10\,am) or an interruptor at sentence level – the latter surrounded by spaces and used in most European languages (including British English) \\
|
||
\code{latex}{-{}-{}-} & Em dash & an interrupter at sentence level\,---\,mostly used in American English and without or with thin spaces \\
|
||
\bottomrule
|
||
\caption{Hyphens and dashes in \LaTeX}
|
||
\label{tbl:bars}
|
||
\end{longtable}
|
||
|
||
The hyphen is obviously also used for hyphenation, but for this purpose, we should not insert it explicitly in our source code.
|
||
In most places, \LaTeX{} does the hyphenation automatically if we are using the correct \texttt{babel} configuration.\footnote{c.\,f. \cref{sec:language}.}
|
||
In case something goes wrong, we can intervene using the codes from \cref{tbl:separators}:\footnote{Those also require the \texttt{babel} package.}
|
||
|
||
\setlength\LTleft{-2cm}
|
||
\begin{longtable}{@{}lp{8cm}p{3cm}p{3cm}@{}}
|
||
\toprule
|
||
Code & Explanation & English example & German example \\
|
||
\midrule
|
||
\endhead
|
||
\code{latex}{\textbackslash -} & Exclusive hyphenation: The word may only be hyphenated at this position (can also be used multiple times within one word\,---\,all of those positions are then allowed). & & $\qquad\qquad\qquad$~Vers\-endung, Ver\-sendung \\
|
||
\code{latex}{"-} & Additional hyphenation: The word may be hyphenated here, as well as at the default positions. & & $\qquad\quad$~Mecklen- burg-Vorpommern \\
|
||
\code{latex}{-} & Exclusive hyphen: Is only used for compound words and prevents the automatic hyphenation for the rest of the word (which is typographically desirable). & $\qquad\qquad\quad$~stand-by & Hals-Nasen-Ohren-Arzt \\
|
||
\code{latex}{"=} & Non-exclusive hyphen: Is used for long compound words when the text wrapping would not work without additional automatic hyphenation. & & $\qquad\qquad$~Sonnen-auf- und -untergang \\
|
||
\code{latex}{""} & Cut-off point without a hyphen: Allows something like a \acro{url} to wrap without inserting a potentially misleading hyphen. Also useful in combination with parentheses. & $\qquad\qquad$~(sub-) module & $\qquad\qquad$~(Teil-) Prüfung \\
|
||
\code{latex}{"\textasciitilde} & Non-wrapping hyphen: Keeps the hyphen together with the following word, very useful for suspended hyphens when parts of compound words are omitted. & high-quality and \mbox{-priced products} & von Satzanfang bis \mbox{-ende} \\ % cannot be reproduced without german babel
|
||
\bottomrule
|
||
\caption{Exceptions for hyphenation}
|
||
\label{tbl:separators}
|
||
\end{longtable}
|
||
|
||
\section{Quotation marks}
|
||
Quotation marks can generally be created using the codes from \cref{tbl:quotation-marks}.
|
||
The decisive factor is the appearance, not the semantics, which is why the French Guillemets are used the wrong way around in German
|
||
(the \emph{french left quotation mark} on the right and vice versa).
|
||
|
||
\begin{table}[H]
|
||
\center
|
||
\begin{tabular}{lcccc}
|
||
\toprule
|
||
Language & \multicolumn{2}{c}{First level} & \multicolumn{2}{c}{Second level} \\
|
||
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
|
||
& Code & Result & Code & Result \\
|
||
\midrule
|
||
English (\acro{A.\,E.}) & \code{latex}{``…''} & ``…'' & \code{latex}{`…'} & `…' \\
|
||
English (\acro{B.\,E.}) & \code{latex}{`…'} & `…' & \code{latex}{``…''} & ``…'' \\
|
||
German & \code{latex}{\glqq…\grqq} & \glqq…\grqq & \code{latex}{\glq…\grq} & \glq…\grq \\
|
||
German (alternatively) & \code{latex}{\frqq…\flqq} & \frqq…\flqq & \code{latex}{\frq…\flq} & \frq…\flq \\
|
||
\bottomrule
|
||
\end{tabular}
|
||
\caption{Quotation marks}
|
||
\label{tbl:quotation-marks}
|
||
\end{table}
|
||
|
||
We can get more flexibility using the \pkg{csquote} package, which provides the \code{latex}{\enquote{<quote>}} command.
|
||
It chooses the correct quotation marks depending on the language being used; also, nested \texttt{enquote}s automatically switch back and forth between first and second level.
|
||
When enabling the \code{latex}{autostyle=true} option on package import, \code{latex}{\textbackslash foreignquote\{<language>\}\{<quote>\}} selects varying quotation marks for each quotation.
|
||
|
||
\section{Diacritics}
|
||
If we are able to insert letters with diacritics via our keyboard\,---\,e.\,g., the German Umlauts or common accents\,---\,we can do this within our source code, as well:
|
||
The characters will remain intact in the output.
|
||
If not, we can also create the diacritics via escape codes.
|
||
\Cref{tbl:diacritics} shows just a few examples\,---\,the letters can of course be swapped out, but there is still a huge amount of different diacritics.
|
||
|
||
\begin{table}[H]
|
||
\center
|
||
\begin{tabular}{lccclccclcc}
|
||
\toprule
|
||
\code{latex}{\textbackslash `{o}} & -- & \`{o} & $\quad$ & \code{latex}{\textbackslash c{c}} & -- & \c{c} & $\quad$ & \code{latex}{\textbackslash d{u}} & -- & \d{u} \\
|
||
\code{latex}{\textbackslash '\{o\}} & -- & \'{o} & & \code{latex}{\textbackslash k\{a\}} & -- & \k{a} & & \code{latex}{\textbackslash r\{a\}} & -- & \r{a} \\
|
||
\code{latex}{\textbackslash \^\{o\}} & -- & \^{o} & & \code{latex}{\textbackslash l\{\}} & -- & \l{} & & \code{latex}{\textbackslash u\{o\}} & -- & \u{o} \\
|
||
\code{latex}{\textbackslash "\{o\}} & -- & \"{o} & & \code{latex}{\textbackslash =\{o\}} & -- & \={o} & & \code{latex}{\textbackslash v\{s\}} & -- & \v{s} \\
|
||
\code{latex}{\textbackslash H\{o\}} & -- & \H{o} & & \code{latex}{\textbackslash b\{o\}} & -- & \b{o} & & \code{latex}{\textbackslash t\{oo\}} & -- & \t{oo} \\
|
||
\code{latex}{\textbackslash ~\{o\}} & -- & \~{o} & & \code{latex}{\textbackslash .\{o\}} & -- & \.{o} & & \code{latex}{\textbackslash o} & -- & \o \\
|
||
\bottomrule
|
||
\end{tabular}
|
||
\caption{Diacritics}
|
||
\label{tbl:diacritics}
|
||
\end{table}
|
||
|
||
\section{More special characters}\label{sec:more-special-characters}
|
||
Some special characters, like the percent sign, are reserved as part of the \LaTeX{} syntax and cannot be used as normal characters.
|
||
These and many, many more can be created by their own commands.
|
||
Please note that some of them only work in maths environments (c.\,f. \cref{sec:maths}), others might require additional packages.
|
||
|
||
\begin{table}[H]
|
||
\center
|
||
\begin{tabular}{cll}
|
||
\toprule
|
||
Sign & Code & Remarks \\
|
||
\midrule
|
||
?`/!` & \verb|?`/!`| & \\
|
||
\textasciicircum & \code{latex}{\textbackslash textasciicircum} & \\
|
||
\textasciitilde & \code{latex}{\textbackslash textasciitilde} & \\
|
||
\textasteriskcentered & \code{latex}{\textbackslash textasteriskcentered} & \\
|
||
\textbackslash & \code{latex}{\textbackslash textbackslash} & \\
|
||
%\textbar & \code{latex}{\textbackslash textbar} & \\
|
||
%\textbullet & \code{latex}{\textbackslash textbullet} & \\
|
||
\textcopyright & \code{latex}{\textbackslash textcopyright} & \\
|
||
\textdagger & \code{latex}{\textbackslash textdagger} & \\
|
||
%\textdaggerdbl & \code{latex}{\textbackslash textdaggerdbl} & \\
|
||
\textellipsis & \code{latex}{\textbackslash textellipsis} & \\
|
||
\textless/\textgreater & \code{latex}{\textbackslash textless/\textbackslash textgreater} & \\
|
||
\textperthousand & \code{latex}{\textbackslash textperthousand} & \\
|
||
\textsection & \code{latex}{\textbackslash textsection} & \\
|
||
$\delta, \pi, \Sigma$ & \verb|\delta, \pi, \Sigma|, … & only in maths
|
||
environments \\
|
||
\textteshlig & \code{latex}{\textbackslash textteshlig} & requires the \pkg{tipa} package \\
|
||
\textmusicalnote & \code{latex}{\textbackslash textmusicalnote} & requires the \pkg{textcomp} package \\
|
||
\bottomrule
|
||
\end{tabular}
|
||
\caption{Some special characters}
|
||
\label{tbl:special-characters}
|
||
\end{table}
|
||
Whenever you need a certain symbol and don’t know its name, \emph{Detexify}\footnote{\url{http://detexify.kirelabs.org/classify.html}} comes to the rescue: You can draw the symbol and get all necessery information.
|
||
From cuneiforms to technical symbols, there is absolutely \emph{everything}\textit{,} as you can see scrolling through the \emph{Comprehensive \LaTeX{} Symbol List}\textit{.}\footnote{\url{http://tug.ctan.org/info/symbols/comprehensive/symbols-a4.pdf}}
|
||
|