281 lines
12 KiB
TeX
281 lines
12 KiB
TeX
\chapter{The Appendix}
|
|
\todonote{Don't forget to remove this advice from the document}
|
|
This is the appendix with some helpful advice. If you don't need an appendix, remove this chapter from the main tex file. Otherwise, replace it with your own content.
|
|
|
|
Always write something in between headings, like here.
|
|
|
|
\section{Correct Headings} \todo{write some text here, this looks bad}
|
|
% this is bad, no text here
|
|
|
|
\subsection{Subsection}
|
|
This is a subsection.
|
|
|
|
\subsubsection{Subsubsection}
|
|
This is a subsubsection. It is created with \verb|\subsubsection{Subsubsection}| and therefore numbered. You should only use numbered sections and subsections. If you need additional headings, better use \verb|\subsubsection*{Subsubsection}| or other * variants (e.g.\ \verb|\paragraph*{The Paragraph}| or \verb|\subparagraph*{The Subparagraph}|).
|
|
However, most of the time too many headings are an indicator of poorly structured text, so you may as well change the overall structure of your document.
|
|
|
|
\subsubsection*{Subsubsection}
|
|
This subsubsection has no number.
|
|
|
|
\section{Lists}
|
|
There are different types of lists, mostly \verb|itemize|, \verb|enumerate| \verb|description|, which are shown below. They take up large parts of the document, so use them wisely.
|
|
|
|
This is an \verb|itemize| environment:
|
|
\begin{itemize}
|
|
\item First item
|
|
\item Second item
|
|
\end{itemize}
|
|
|
|
This is an \verb|enumerate| environment:
|
|
\begin{enumerate}
|
|
\item First item
|
|
\item Second item
|
|
\end{enumerate}
|
|
|
|
This is a \verb|description| environment:
|
|
\begin{description}
|
|
\item[What is this] This is the description
|
|
\item[Another point] Some more description
|
|
\end{description}
|
|
|
|
You can also configure \verb|description| to look like this:
|
|
\begin{description}
|
|
\item[What is this]\hfill\\
|
|
This is a really long description to show linebreaks at the end of each line. Some more text in this description.
|
|
\item[Another point]\hfill\\
|
|
Some more description.
|
|
\end{description}
|
|
|
|
\section{(Non-)Floating Environments}
|
|
Have a look at different types of environments.
|
|
|
|
\subsection{Floating Environments}
|
|
|
|
Some environments ``float'', i.e.\ \LaTeX{} places them somewhere in your document, not necessarily where they are in the source code. Take a look at \cref{figure1}.
|
|
|
|
\begin{figure}
|
|
\centering
|
|
\includegraphics[width=0.2\textwidth]{content/images/NES_Logo_text}
|
|
\caption{The NES logo}
|
|
\label{figure1}
|
|
\end{figure}
|
|
|
|
As you can see, this Figure is placed somewhere else. You can also use subfigures to display multiple figures side-by-side, as shown in \cref{figure2}, containing \cref{logo} and \cref{other}.
|
|
|
|
\begin{figure}
|
|
\centering
|
|
\begin{subfigure}[b]{0.25 \textwidth}
|
|
\includegraphics[width=\linewidth]{content/images/NES_Logo_text}
|
|
\caption{The NES logo}
|
|
\label{logo}
|
|
\end{subfigure}
|
|
\hfill
|
|
\begin{subfigure}[b]{0.5 \textwidth}
|
|
\missingfigure{A Subfigure}
|
|
\caption{Another subfigure}
|
|
\label{other}
|
|
\end{subfigure}
|
|
\caption{The NES logo with another figure}
|
|
\label{figure2}
|
|
\end{figure}
|
|
|
|
Tables are very similar, have a look at \cref{my_table,my_other_table}.
|
|
|
|
\begin{table}
|
|
\centering
|
|
\caption{The Caption. Don't use so many lines.}
|
|
\label{my_table}
|
|
\begin{tabular}{|l|l|l|}
|
|
\hline
|
|
a & b & c \\ \hline
|
|
d & e & f \\ \hline
|
|
\end{tabular}
|
|
\end{table}
|
|
|
|
\begin{table}
|
|
\centering
|
|
\caption{A larger table with better structure}
|
|
\label{my_other_table}
|
|
\begin{tabular}{lllccc}
|
|
\toprule
|
|
Left-aligned cells & left & left & Center-aligned cells & center & center \\
|
|
\midrule
|
|
some text here & a & b & Some really long text & c & d \\
|
|
e & f & g & h & i & j \\
|
|
\bottomrule
|
|
\end{tabular}
|
|
\end{table}
|
|
|
|
Use \verb|\toprule|, \verb|\midrule| and \verb|\bottomrule| for better horizontal lines in tables. Be careful with too many vertical lines.
|
|
Always use \verb|\caption{the caption}|, \verb|\label{the_label}| and \verb|\ref{the_label}|/\verb|\cref{the_label}| in combination with figures and tables.
|
|
|
|
\subsection{Custom Environments}
|
|
There are two custom environments, which you can use to write code and pseudocode: \verb|code| and \verb|algorithm|. You can adjust them in \verb|packages.tex|.
|
|
|
|
If you want to write code, use an \verb|lstlisting|, like in \cref{code:example_1} or \cref{code:example_2}. Depending on the language and context, you may want to configure syntax highlighting and other options.
|
|
\begin{code}{Example Code in Java}{example_1}
|
|
\begin{lstlisting}[language=Java,keywordstyle=\color{purple},numbers=left,numberstyle=\tiny]
|
|
public void main(String[] args) {
|
|
System.out.println("This is an example")
|
|
}
|
|
\end{lstlisting}
|
|
\end{code}
|
|
|
|
\begin{code}{Example Code in Python}{example_2}
|
|
\begin{lstlisting}[language=Python,keywordstyle=\color{purple},numbers=left,numberstyle=\tiny]
|
|
if __name__ == "__main__":
|
|
print("This is an example in python")
|
|
\end{lstlisting}
|
|
\end{code}
|
|
|
|
Instead of \verb|lstlisting|, you can also use the package \verb|minted|, which provides better code highlighting, but needs additional installation instructions. Take a look at the package documentation: \url{http://ctan.net/macros/latex/contrib/minted/minted.pdf}
|
|
|
|
Instead of writing real code, you can also use pseudo-code, which looks like shown in \cref{alg:pseudo_example}.
|
|
|
|
\begin{algorithm}{An Example for Pseudo-Code}{pseudo_example}
|
|
\pr{doStuff}(A): $\mathbb{R} \rightarrow \mathbb{R}$ \\
|
|
\begin{tabular}{@{}ll}
|
|
\textbf{Input:} & $A \gets \text{list of input elements}$ \\
|
|
\textbf{Output:} & $B \gets \text{list of output elements}$
|
|
\end{tabular}
|
|
\begin{pseudo}
|
|
Initialize state $C = \emptyset$ \\
|
|
\ForAll $a \in A$ \\+
|
|
\If some condition related to $a$ \\+
|
|
$ C = C \cup \left\lbrace a \right\rbrace $ \\--
|
|
Initialize some other set $C' = $ \hspace*{1cm} \pseudoct{You can also add comments}\\+
|
|
some elements from $C$ \\-
|
|
$B = C'$ \\
|
|
\Return $B$
|
|
\end{pseudo}
|
|
\end{algorithm}
|
|
|
|
\section{Punctuation and Spaces}
|
|
This section explains spaces, linebreaks and quotation marks.
|
|
|
|
\subsection{Space}
|
|
There are different kinds of space, use them correctly. First, the ``normal'' space (interword space) is used by pressing the space bar on your keyboard. You probably use it all the time. However, a space at the beginning of a sentence can be larger. \LaTeX{} detects sentences by the presence of periods, which is sometimes wrong. Have a look at the following examples:
|
|
|
|
\begin{minipage}{0.9\textwidth}
|
|
This is a normal sentence. This is the next sentence. \\
|
|
The physicist Prof. A. Einstein defined $E = mc^2$. \\
|
|
The physicist Prof.\ A.\ Einstein defined $E = mc^2$. \\
|
|
Einstein et al. defined even more equations. \\
|
|
Einstein et al.\ defined even more equations. \\
|
|
The equation $E = mc^2$ was defined by Mister E. This is great. \\
|
|
The equation $E = mc^2$ was defined by Mister E\@. This is great. \\
|
|
\end{minipage}
|
|
|
|
If you have abbreviations with small letters, use ``\textbackslash\ '' (backslash+space) or ``$\sim$'' (tilde, non-breaking space) to use a normal space. If a sentence ends with a single capital letter, end the sentence with ``\textbackslash@.'' (backslash+at+period) to use a sentence-beginning space afterwards.
|
|
|
|
\subsection{Linebreaks}
|
|
\LaTeX{} sometimes decides to break lines at unwanted places. Always use $\sim$ in references, citations etc.\ to prevent \LaTeX{} from breaking this space, e.g.\ this is a citation~\cite{Ikeda1997}, and this is a reference to Figure~\ref{figure1}. However, you can also use \verb|\cref| for figures and tables, e.g. \cref{figure1} and \cref{my_table,my_other_table}.
|
|
|
|
Additionally, \LaTeX{} likes to break compound words at a hyphen. If you want to prevent this, you can wrap the word in an mbox, e.g.\ \verb|\mbox{the-word}|.
|
|
If \LaTeX{} doesn't know how to break a word, you get a warning. You can add \verb|\-| (backslash+hyphen) to tell \LaTeX{} how to break this word.
|
|
If you want to manually add linebreaks, you can use \verb|\linebreak|, \verb|\newline| or \verb|\\|.
|
|
Never use a new line to start a new paragraph, always use a blank line in the source code.
|
|
|
|
This is a new paragraph, no command is needed.
|
|
|
|
|
|
\subsection{Quotation Marks}
|
|
There are many different quotation marks available. Using \verb|"| is always wrong. Depending on the language, \verb|"| is a closing quotation mark or marks characters as umlauts. Depending on the encoding, the used font, and other metrics, \verb|"| might look like '', or it might not. Compare " and ''.
|
|
|
|
\begin{minipage}{0.9\textwidth}
|
|
\centering
|
|
This is a sentence where an "a" is quoted.\\
|
|
\begin{otherlanguage}{ngerman}
|
|
Dies ist ein Satz, in welchem ein "a" zitiert wird.\\
|
|
\end{otherlanguage}
|
|
This is a sentence where an ``a'' is quoted.\\
|
|
\begin{otherlanguage}{ngerman}
|
|
Dies ist ein Satz, in welchem ein ``a'' zitiert wird.\\
|
|
Dies ist ein Satz, in welchem ein \glqq a\grqq{} zitiert wird.
|
|
\end{otherlanguage}
|
|
\end{minipage}
|
|
|
|
Instead, you should use \verb|``quote''| (double \verb|`| + double \verb|'|) or other language appropriate quotation marks, e.g.\ \verb|\glqq|, \verb|\grqq|, \verb|\flqq|, \verb|\frqq|.
|
|
|
|
\section{Glossaries}
|
|
If you want to use the package \verb|glossaries|, you can define entries in the file \verb|content/lists/glossary|. You can use the with \verb|\gls| and related commands:
|
|
|
|
The \gls{cpu} is an important part of the computer. Some computers even use multiple \glspl{cpu} and also multiple \glspl{gpu}. As you can see, the first use of each abbreviation is written in full, while subsequent uses use the abbreviated version. The first use is reset at the beginning of every chapter.
|
|
|
|
Symbols are used similarly, see \gls{alpha} and \gls{beta}.
|
|
|
|
\section{Math}
|
|
There are two types of math available, inline and display.
|
|
Inline equations can be shown in the text by using \verb|$equation$|. This is an example containing $E=mc^2$ and also $a^2+b^2=c^2$.
|
|
Display equations can be created with the \verb|equation| environment. Have a look at \cref{eq1}:
|
|
|
|
\begin{equation}
|
|
\label{eq1}
|
|
\pi = \sqrt{12} \sum_{k=0}^{\infty} \frac{\left( -3 \right)^{-k}}{2k+1}
|
|
= \sqrt{12} \left( 1 - \frac{1}{3*3} + \frac{1}{5*3^2} - \frac{1}{7*3^3} + \ldots \right)
|
|
\end{equation}
|
|
|
|
Always use numbered equations (created with \verb|equation|, not \verb|equation*|).
|
|
If you want to define variables in your equations, either use symbols or define them with \verb|mathrm|, never write text in math mode. See Equation~\ref{eq2} for examples:
|
|
|
|
\begin{equation}
|
|
\label{eq2}
|
|
area = \left\lbrace
|
|
\begin{array}{l}
|
|
a^2 if square\\
|
|
a*b if rectangle
|
|
\end{array}
|
|
\right.
|
|
\qquad
|
|
\mathrm{area} = \left\lbrace
|
|
\begin{array}{ll}
|
|
a^2 & \text{if square}\\
|
|
a*b & \text{if rectangle}
|
|
\end{array}
|
|
\right.
|
|
\end{equation}
|
|
|
|
\section{Bibliography}
|
|
|
|
When using references, always watch out for warnings and errors from \textrm{Bib}\TeX. Sometimes, entries can be imported, but are formatted wrong. Always check the output.
|
|
Here are some examples of typical errors when handling \textrm{Bib}\TeX\ citations:
|
|
|
|
\begin{minipage}{0.9\textwidth}
|
|
\centering
|
|
\begin{tabular}{lcc}
|
|
\toprule
|
|
Error & Example & Correct \\
|
|
\midrule
|
|
Missing fields & \cite{field_missing1,field_missing2} & \cite{field_missing_correct1,field_missing_correct2} \\
|
|
Institution Author & \cite{institution_author1} & \cite{institution_author_correct} \\
|
|
Multiple Authors & \cite{multiple_authors1} & \cite{multiple_authors_correct} \\
|
|
\bottomrule
|
|
\end{tabular}
|
|
\end{minipage}
|
|
|
|
\section{Other useful commands}
|
|
|
|
\subsection{TODO-related commands}
|
|
The commands \verb|\todo| and \verb|\missingfigure| can be useful to add annotations to the text without changing the text itself. The command \verb|\todo| can be seen here. \todo{do something}
|
|
It is also possible to add an inline todo comment:
|
|
|
|
\todo[inline]{An inline todo comment}
|
|
|
|
Other useful todo-related commands may be \verb|\note|, \verb|\todonote|, \verb|\citationneeded| and \verb|\phantomtodo|. Take a look at their definitions to understand what they do~\citationneeded.
|
|
|
|
\phantomtodo{This TODO example is only visible in the list of todos}
|
|
|
|
\todonote{An alternative inline todo comment}
|
|
|
|
The command \verb|\missingfigure| can be used to add a placeholder to figures, see e.g.\ Figure~\ref{placeholder}.
|
|
|
|
\begin{figure}
|
|
\centering
|
|
\missingfigure{A missing figure}
|
|
\caption{An example for a missing figure}
|
|
\label{placeholder}
|
|
\end{figure}
|
|
|
|
\subsection{The pages command}
|
|
The usage of the \verb|\pages| command is demonstrated in this document. You can use this command to estimate how much pages you will write. \LaTeX\ will group each estimate by section and display a list of the estimated pages at the front of this document. Make sure to remove \verb|\input{content/page_estimate_commands}| before you print your document.
|