255 lines
10 KiB
TeX
255 lines
10 KiB
TeX
\chapter{The Appendix - Some \LaTeX\ Advice}
|
|
\todo[inline]{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 Section and Subsection 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. Have a look at Figure~\ref{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 Figure~\ref{figure2}, containing Figure~\ref{logo} and Figure~\ref{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 Table~\ref{my_table} and Table~\ref{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}| in combination with figures and tables.
|
|
|
|
\subsection{Non-Floating Environments}
|
|
Many other environments appear exactly where they are placed in the source code. Some of them are explained here.
|
|
|
|
If you want to write code, use an \verb|lstlising|, like in Code~\ref{example_1} or Code~\ref{example_2}. Depending on the language and context, you may want to configure syntax highlighting and other options.
|
|
|
|
\begin{lstlisting}[language=Java, label=example_1, caption={Example Code in Java}]
|
|
public void main(String[] args) {
|
|
System.out.println("This is an example")
|
|
}
|
|
\end{lstlisting}
|
|
|
|
\begin{lstlisting}[language=Python, label=example_2, caption={Example Code in Python}]
|
|
if __name__ == "__main__":
|
|
print("This is an example in python")
|
|
\end{lstlisting}
|
|
|
|
Instead of writing real code, you can also use pseudo-code, which looks like shown in Algorithm~\ref{pseudo_example}.
|
|
|
|
|
|
\begin{algorithm}
|
|
\caption{An Example for Pseudo-Code}\label{pseudo_example}
|
|
\begin{algorithmic}[1]
|
|
\Procedure{doStuff}{$A$}
|
|
\Statex $\textbf{Input:} \qquad A \gets \text{list of input elements}$
|
|
\Statex $\textbf{Output:} \quad B \gets \text{list of output elements}$
|
|
\State Initialize state $C = \emptyset$
|
|
\ForAll{$a \in A$}
|
|
\If{some condition related to $a$}
|
|
\State $ C = C \cup \left\lbrace a \right\rbrace $
|
|
\EndIf
|
|
\EndFor
|
|
\State Initialize some other set $C' = $ \Comment{You can also add comments and split lines}
|
|
\item[] \hskip\algorithmicindent \hskip\algorithmicindent some elements from $C$
|
|
\State $B = C'$
|
|
\State \Return $B$
|
|
\EndProcedure
|
|
\end{algorithmic}
|
|
\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}{\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}.
|
|
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.
|
|
|
|
\begin{minipage}{\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}
|
|
\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{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 Equation~\ref{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}{\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{The todo command}
|
|
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}
|
|
|
|
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}
|