\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}{Unterschiedliche Leerzeichen 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 \mintinline{tex}|\frenchspacing| above the first paragraph.
With \mintinline{tex}|\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 (\mintinline[showspaces]{tex}{.\ }) or sentence spaces (\mintinline[showspaces]{tex}{\@. }).

\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
	\mintinline{tex}|-|   & Hyphen  & a small-sized stroke \\
	\mintinline{tex}|--|  & 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) \\
	\mintinline{tex}|---| & Em dash & an interruptor 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} package.\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.}\todo{Is it because of the English document that the last example does not work?}

\begin{longtable}{@{}lp{11cm}@{}}
	\toprule
	Code      & Erläuterung \\
	\midrule
	\endhead
	\mintinline{tex}|\-| & 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). \\
	\mintinline{tex}|"-| & Additional hyphenation: The word may be hyphenated here, as well as at the default positions. \\
	\mintinline{tex}|-|  & Exclusive hyphen: Is only used for compound words and prevents the automatic hyphenation for the rest of the word (which is typographically desirable). \\
	\mintinline{tex}|"=| & Non-exclusive hyphen: Is used for long compound words when the text wrapping would not work without additional automatic hyphenation. \\
	\mintinline{tex}|""| & Cut-off point without a hyphen: Allows something like a \textsc{url} to wrap without inserting a potentially misleading hyphen. \\
	\mintinline{tex}|"~| & Non-wrapping hyphen: Keeps the hypen together with the following word, very useful in German: \emph{Vorlesungszeit und "~raum} \\
	\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.}) & \mintinline{tex}|``...''| & ``…'' & \mintinline{tex}|`...'| & `…' \\
		English (\acro{B.\,E.}) & \mintinline{tex}|`...'| & `…' & \mintinline{tex}|``...''| & ``…'' \\
		German & \mintinline{tex}|\glqq...\grqq| & \glqq…\grqq & \mintinline{tex}|\glq…\grq| & \glq…\grq \\
		German (alternatively) & \mintinline{tex}|\frqq...\flqq| & \frqq…\flqq & \mintinline{tex}|\frq…\flq| & \frq…\flq \\
		\bottomrule
	\end{tabular}
	\caption{Quotation marks}
	\label{tbl:quotation-marks}
\end{table}

We can also get more flexibility using the \mintinline{tex}{csquote} package, which provides the \mintinline{tex}|\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 \mintinline{tex}|autostyle=true| option on package import, \mintinline{tex}|\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 also do this within our source code:
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
			\verb|\`{o}| & -- & \`{o} & $\quad$ & \verb|\c{c}| & -- & \c{c} & $\quad$ & \verb|\d{u}| & -- & \d{u} \\
			\verb|\'{o}| & -- & \'{o} & & \verb|\k{a}| & -- & \k{a} & & \verb|\r{a}| & -- & \r{a} \\
			\verb|\^{o}| & -- & \^{o} & & \verb|\l{}| & -- & \l{} & & \verb|\u{o}| & -- & \u{o} \\
			\verb|\"{o}| & -- & \"{o} & & \verb|\={o}| & -- & \={o} & & \verb|\v{s}| & -- & \v{s} \\
			\verb|\H{o}| & -- & \H{o} & & \verb|\b{o}| & -- & \b{o} & & \verb|\t{oo}| & -- & \t{oo} \\
			\verb|\~{o}| & -- & \~{o} & & \verb|\.{o}| & -- & \.{o} & & \verb|\o| & -- & \o \\
		\bottomrule
	\end{tabular}
	\caption{Diakritika}
	\label{tbl:diacritics}
\end{table}

\section{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
		Zeichen & Code & Bemerkung \\
		\midrule
		?`/!` & \verb|?`/!`| & \\
		\textasciicircum & \verb|\textasciicircum| & \\
		\textasciitilde & \verb|\textasciitilde| & \\
		\textasteriskcentered & \verb|\textasteriskcentered| & \\
		\textbackslash & \verb|\textbackslash| & \\
		%\textbar & \verb|\textbar| & \\
		%\textbullet & \verb|\textbullet| & \\
		\textcopyright & \verb|\textcopyright| & \\
		\textdagger & \verb|\textdagger| & \\
		%\textdaggerdbl & \verb|\textdaggerdbl| & \\
		\textellipsis & \verb|\textellipsis| & \\
		\textless/\textgreater & \verb|\textless/\textgreater| & \\
		\textperthousand & \verb|\textperthousand| & \\
		\textsection & \verb|\textsection| & \\
		$\delta, \pi, \Sigma$ & \verb|\delta, \pi, \Sigma|, … & only in maths environments \\
		\euro & \verb|\euro| & requires the \texttt{eurosym} package \\
		\textteshlig & \verb|\textteshlig| & requires the \texttt{tipa} package \\
		\textmusicalnote & \verb|\textmusicalnote| & requires the \texttt{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}, as you can see scrolling through the \emph{Comprehensive \LaTeX{} Symbol List}.\footnote{\url{http://tug.ctan.org/info/symbols/comprehensive/symbols-a4.pdf}}

