\section{Template Introduction}\label{sec:introduction}
This is a basic template for a
\ifClass seminar paper or practical report \else\ifThesis bachelor's or master's thesis \fi\fi
to help you with fulfilling all formal requirements.
But it is not, by any means, authorative, or binding.
%
If you notice an error with the template, you should rather fix it, than leave it as is ``because it was already broken in the template''.
Instead, we would appreciate improvements.

This template assumes you already used \LaTeX{} before. It does not explain how to compile a document or such fundamentals.
If you have not used \LaTeX{} before, you probably will need to read through some online tutorials, or a book from the library.

This template consists of four files:
\begin{tabbing}
File name:\hspace{2cm}\= Contents:\\
\ifClass
\texttt{seminar.tex} \> \LaTeX{} source \\
\texttt{seminar.pdf} \> \LaTeX{} output file (this file) \\
\fi
\ifThesis
\texttt{thesis.tex} \> \LaTeX{} source \\
\texttt{thesis.pdf} \> \LaTeX{} output file (this file) \\
\fi
\texttt{references.bib} \> Bibliography database \\
\texttt{dbstmpl.sty} \> \LaTeX{} style file (you do not need to edit this)
\end{tabbing}

% -------------------------------------------

\subsection{Language: English or German}
We encourage you to write in English, but you are allowed to submit your thesis in German.
%
Unfortunately, if you write in German, you will end up using a lot of technical expressions in English,
or with some clumsy and uncommon translations.
Usually, it will be more elegant to write English instead when working mostly with English sources,
and it will be a good opportunity to improve your English writing skills.

To use German as default language, add the option \texttt{german} to the style file:
\par\nobreak
\texttt{\textbackslash{}usepackage[german]\{dbstmpl\}}
\par\nobreak
and it will automatically use German for built-in strings such as ``Inhaltsverzeichnis''.

% -------------------------------------------
\ifClass\clearpage\fi
\subsection{Metadata}

First, you need to choose the type and title by uncommenting the appropriate line,
and list the instructors / advisors.

\ifClass
\begin{verbatim}
%\beginnerpractical{Report Title}
%\seminar{Seminar title}{Title}
%\advancedpractical{Report Title}
\date{\today}% Date of submission.
\term{Summer}{2018}% Term and year

\instructor{Prof. Dr. Michael Gertz}
\instructor{Dr. Johanna Geiß}
\instructor{Dr. Erich Schubert}
\instructor{Sebastian Lackner}
\instructor{Andreas Spitz}
\end{verbatim}
\else\ifThesis
\begin{verbatim}
%\bachelorsthesis{Title}
%\mastersthesis{Title}
\date{\today}% Date of submission.

\advisor{Prof. Dr. Michael Gertz}
\advisor{Dr. Johanna Geiß}
\advisor{Dr. Erich Schubert}
\advisor{Sebastian Lackner}
\advisor{Andreas Spitz}
\end{verbatim}
\fi\fi

Last but not least, your personal information:

\begin{verbatim}
\author{Erika Mustermann}
\matrikelnr{1234567}
\studyprogram{Informatik}{7}
\email{erika.mustermann@informatik.uni-heidelberg.de}
\end{verbatim}

These commands will be used for generating the title page and anti-plagiarism declaration.

If your page headline is too long, you can use
\texttt{\textbackslash{}shortauthor\{E. Mustermann\}}
to shorten your name, and \texttt{\textbackslash{}shorttitle} to provide
an alternate, shorter version of the title. 

% -------------------------------------------
\clearpage
\subsection{Basic structure}

The document consists of three building blocks, known as the ``front matter'', the ``main matter'', and the ``back matter''.

Front matter will contain the title page and the table of contents: 

\begin{verbatim}
\begin{document}
\frontmatter
\maketitle                    % Generates the title page
\eigenstaendigkeitserklaerung % Anti-plagiarism declaration
\tableofcontents              % Table of contents
\end{verbatim}

The generated title page \textbf{does \emph{not} have a logo}, because \textbf{using the seal is restricted}.

\medskip
\textbf{The anti-plagiarism declaration (Eigenständigkeitserklärung), although in German,
is something you will have to read, understand, and sign in the printed version.
For more details, see \refsec{sec:antiplag}}

\medskip
The main matter will contain your main contents:

\begin{verbatim}
\mainmatter
%% Introduction, related work, theory, experiments, conclusions, ... 
\end{verbatim}

The back matter will contain optional appendixes, and the generated bibliography:

\begin{verbatim}
\backmatter
%% Optional appendix sections:
%\appendix
%\section{An appendix section}
%% Mandatory bibliography:
\cleardoublepage
\printbibliography % Bibliography
\cdpage            % A page to attach your CD (theses only)
\end{document}
\end{verbatim}

% -------------------------------------------

\clearpage
\subsection{Anti-Plagiarism Declaration}\label{sec:antiplag}

You have to sign the declaration that you adhere to ``good academic practice''.\\
In particular, you should be aware of the university guidelines on academic misconduct, 
partially reproduced here:%
\footnote{For further information, see in English / in German:\\
\url{https://www.uni-heidelberg.de/university/profile/academic_practice/} \\ 
\url{https://www.uni-heidelberg.de/universitaet/profil/wissenschaftliche_praxis/}}

{\small\singlespacing
\paragraph{§1 Academic misconduct -- definition}\quad
Academic misconduct applies in particular when deliberately, or with
gross negligence, false statements are made in scientific and other
scholarly studies, the intellectual property of others is violated or their
research activity is intentionally harmed in some other way.
Misconduct occurs, in particular, in the following cases:

\begin{enumerate}
\item[a)] False statements
\begin{itemize}
  \item Inventing data
  \item Faking data, e.g.{} by
  \begin{itemize}
    \item selecting and rejecting undesired results, without making this known
    \item manipulating a drawing or figure
    \item giving incorrect information in an application for a post or for funding (including false statements about publications in the printing process regarding the journal or other organ);
  \end{itemize}
\end{itemize}
\item[b)] Violating intellectual property
\begin{itemize}
\item in connection with work protected by copyright, or of
essential scientific findings, hypotheses, teachings or
research approaches stemming from others:
\begin{itemize}
\item unauthorised use, claiming authorship (plagiarism)
\item exploiting research approaches and ideas,
particularly as referee (stealing ideas)
\item appropriating or, without grounds, assuming
academic authorship or co-authorship
\item faking content
\item deliberately delaying publication of a scientific or
other scholarly study, particularly as editor or
referee, or
\item going ahead with the unauthorised publication and
enabling accessibility to third parties before the
work, the findings, the hypothesis, the teaching or
the research approach have been made available to
the public;
\end{itemize}
\end{itemize}
\item[c)] the claiming of (co)authorship of another person without his/her
consent;
\item[d)] the sabotage of research activities (including the damaging,
destroying or manipulating of experimental designs, equipment, 
documents, hardware, software, chemicals, cell and
microorganism cultures or other items required by another person
to carry out an experiment);
\item[e)] misappropriation of budgetary funds and private grants;
\item[f)] disposal of original data, if this is against statutory regulations or
-- depending on the discipline -- recognised principles of scientific
or other scholarly work.
\end{enumerate}
}

% -------------------------------------------

\ifThesis % Does not apply to seminar and practicals
\clearpage
\subsection{Submission}

For bachelor and master theses,
there is a (probably German only) document on the web page
\href{http://www.informatik.uni-heidelberg.de/studium-und-lehre/abschlussarbeiten}{%
\nolinkurl{www.informatik.uni-heidelberg.de/studium-und-lehre/abschlussarbeiten}}\\
with some requirements:
\href{http://www.informatik.uni-heidelberg.de/images/perSemester/Formulare/Leitfaden-zur-Erstellung-der-Bachelorarbeit.pdf}{%
\nolinkurl{Leitfaden-zur-Erstellung-der-Bachelorarbeit}}.

\begin{itemize}
\item Three formal copies, with permanent binding (avoid spirals which allow modifications)
\item Empty cover page, possibly transparent film
\item Formal title page
\item Anti-plagiarism declaration (\emph{signed!})
\item Abstract, in German \emph{and} English
\item Table of contents
\item Bibliography
\item CD/DVD with electronic copy of the thesis, source code, data, etc.\\
(To allow reproducing your experiments)
%\item Email the PDF to your advisors, in particular to PhD students that assisted supervision
\end{itemize}

Please also email the PDF to all your advisors as they may not get a formal copy.
\fi

% -------------------------------------------

\clearpage
\section{Mathematics, Figures, Tables, and Algorithms}\label{sec:tables}
\LaTeX{} largely automates enumeration, referencing, and placement of floating objects such as figures.
Because of page layout rules this can sometimes behave a bit surprising, and we recommend that you do not
waste too much time to fight these rules, but let \LaTeX{} perform the layouting.
Some important rules to follow:

\begin{itemize}
\item Preferably place the float just after or just before the paragraph first referencing it.
\item Avoid ``here'' placement of figures. At the top of a page is fine.
\item A \texttt{\textbackslash{}clearpage} before a new \texttt{\textbackslash{}section} will keep figures in their section.
\item \emph{Always} provide a \texttt{\textbackslash{}caption} and a \texttt{\textbackslash{}label}.
\item Use \texttt{\textbackslash{}ref} to reference enumerated items (e.g., \texttt{Figure\textasciitilde\textbackslash{}ref\{fig:abc\}}).
\item Prefixes like \texttt{fig:}, \texttt{tab:}, \texttt{sec:} for labels reduce duplicate names.
\end{itemize}

We also provide macros: \texttt{\textbackslash{}refsec\{sec:some-section\}},
\texttt{\textbackslash{}reffig\{fig:some-figure\}},
\texttt{\textbackslash{}reftab\{tab:some-table\}},
\texttt{\textbackslash{}refalg\{alg:some-algorithm\}},
\ldots

% -------------------------------------------

\subsection{Mathematical Expressions}

\LaTeX{} is known for its high-quality typesetting of mathematical expressions.

They can be used inline (e.g.\ $x=42$), or as display math:
\newcommand{\deriv}[1]{\,\mathrm{\mathstrut d}#1} % Derivative macro
$$
\int_x \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left(\frac{-(x-\mu)^2}{2\sigma^2} \right) \deriv{x} = 1 
$$
\undef\deriv

For longer derivations, it is beneficial to use the \texttt{align} environment,
which allows aligning equations by inserting the \texttt{\&} symbol before the \texttt{=}:
\begin{align}
\sum\nolimits_{x=1}^{n} x
&=
1 + 2 + 3 + 4 + \ldots + n
\notag
\shortintertext{can be rearranged according to Gauss into:}
&=
1 + n + 2 + (n-1) + 3 + (n-2) + \ldots
\notag
\\
&=
(n+1) + (n+1) + (n+1) + \ldots
\notag
\\
&=
(n+1)\cdot \tfrac{n}{2} = \tfrac{n^2+n}{2}
\label{eqn:gauss-sum} 
\end{align}

The \texttt{align*} environment will not enumerate equations, whereas \texttt{\textbackslash{}notag} only
omits a single number. Use \texttt{\textbackslash{}label} to name an equation.
You can reference the equation
using \texttt{Equation\textasciitilde\textbackslash{}eqref\{label\}}
or the shorthand \texttt{\textbackslash{}refeqn\{label\}}.

For example, we get the sentence ``According to \refeqn{eqn:gauss-sum}, we can compute the sum of the first $n$ integers
in $O(1)$ time.'' by writing
\begin{verbatim}
According to \refeqn{eqn:gauss-sum}, we can compute the sum of the
first $n$ integers in $O(1)$ time.
\end{verbatim}

% -------------------------------------------

\subsection{Figures}\label{subsec:figures}

\reffig{fig:figure} shows an example figure generated directly from \LaTeX{} using TikZ.
You can also include an external file, which should be either a PDF, PNG or a JPEG file, using
\begin{verbatim}
\begin{figure}\centering
\includegraphics[width=.8\linewidth]{figures/example.jpg}
\caption{Explanation of the figure}
\label{fig:figure-label}
\end{figure}
\end{verbatim}

It is often convenient to size figures relative to the \texttt{\textbackslash{}linewidth},
and to use cropped files.

Usually it is best to let \LaTeX{} do the figure placement.
Do not waste time to manually force figures into your preferred location.

\begin{figure}\centering
%%% External images can be added instead of using tikzpicture, too:
% \includegraphics[width=.4\linewidth]{figures/example.jpg}
\begin{tikzpicture}
\draw (0, 1.155) -- (-1, -0.557) -- (1, -0.557) -- cycle;
\fill[blue, opacity=.25, thick] (0, 1.155) circle (1.732cm);
\fill[green, opacity=.25, thick] (-1, -0.557) circle (1.732cm);
\fill[red, opacity=.25, thick] (1, -0.557) circle (1.732cm);
\node at (0,1.732) {Beispiel};
\node at (-1.5,-.866) {Grafik};
\node at (1.5,-.866) {$\aleph_0$};
\node at (0,0) {TikZ};
\end{tikzpicture}
\caption{Every figure should have a caption and a label.\newline
Unless you created the figure yourself, always give a reference in the caption.}
\label{fig:figure}
\end{figure}

% -------------------------------------------

\pagebreak
\subsection{Tables}\label{subsec:tables}

\begin{table}\centering
\caption{This is an example table.}
\label{tab:table}
\begin{tabular}{|l|l|}
\hline
first row; first column & first row; second column  \\
\hline
second row; first column & second row; second column \\
\hline
\multicolumn{2}{c}{both columns, no lines}\\
\end{tabular}
\end{table}

Tabular data is, unfortunately, often a bit clumsy in \LaTeX.

\reftab{tab:table} on \refpage{tab:table} gives a very basic example.

\texttt{\textbackslash{}reftab\{tab:table\} on \textbackslash{}refpage\{tab:table\} gives a very basic example.}

Many designers frown on the overuse of lines in tables, but this is personal taste.

% -------------------------------------------

\subsection{Algorithms}

There are several packages to display algorithms.
A popular and up to date package is \texttt{algorithm2e}, which shines with a very detailed and good documentation (the syntax is not that easy to learn, though).

When including algorithms, use \textbf{pseudocode} that gives a high-level description of the algorithm, instead of source code.
Source code itself is better attached as a CD to the thesis.

\refalg{alg:pseudocode} is an example algorithm using this package.

\IncMargin{1em}
\begin{algorithm}
\caption{Deep Thought}\label{alg:pseudocode}
\KwIn{The question of life, the universe, and everything}
\KwOut{The answer}
\KwData{Data banks, the size of a small city}
\BlankLine

\For{$x\in [1\ldots 7.500.000]$}{
Sleep 1 Year\tcc*{Pretend to think}
}
\newcommand{\deriv}[1]{\,\mathrm{\mathstrut d}#1} % Ableitung
$x \leftarrow 6\cdot 7 + \left(e^{i\pi} + 1\right) \displaystyle\int_x\int_y\int_z \log \sqrt[z]{x^y} \deriv{x} \deriv{y} \deriv{z}$%
\tcc*{Compute the answer}
\undef\deriv
\Return{$x$}\;

\end{algorithm}
\DecMargin{1em}

\pagebreak
\subsection{Theorems and Proofs}

You can define environments for theorems, propositions, etc.{} easily:

\begin{verbatim}
\newtheorem{theorem}{Theorem}
\newtheorem{proposition}{Proposition}
\newtheorem{corollary}{Corollary}
\begin{theorem}{Theorem}\label{thm:theorem}
There is at least one theorem in this appendix.
\end{theorem}
\begin{proof}
See Theorem~\ref{thm:theorem}
\end{proof}
\end{verbatim}

\newtheorem{appendixtheorem}{Theorem}
\begin{appendixtheorem}{Theorem}\label{thm:theorem}
There is at least one theorem in this appendix.
\end{appendixtheorem}
\begin{proof}
See Theorem~\ref{thm:theorem}
\end{proof}

% -------------------------------------------

\subsection{Utility Commands}\label{appendix:utility}

This templates includes some additional commands:

\begin{tabbing}
\texttt{\textbackslash{}TODO\{things to do\}} \quad produces: \quad
\=
\TODO{things to do}
\\
\texttt{\textbackslash{}reffig\{fig:label\}}
\>
\reffig{fig:figure}
\\
\texttt{\textbackslash{}reftab\{tab:label\}}
\>
\reftab{tab:table}
\\
\texttt{\textbackslash{}refsec\{sec:label\}}
\>
\refsec{appendix:utility}
\\
\texttt{\textbackslash{}refalg\{alg:label\}}
\>
\refalg{alg:pseudocode}
\\
\texttt{\textbackslash{}refpage\{sec:label\}}
\>
\refpage{appendix:utility}
\end{tabbing}

For example, to get:
``\reftab{tab:table} on \refpage{tab:table} shows an example.''
we only need:\\
\texttt{
\textbackslash{}reftab\{tab:table\} on \textbackslash{}refpage\{tab:table\} shows an example.
}

\section{Tips \& Tricks for \LaTeX{}}

Nice guides and examples for \LaTeX{} can be found, for example, here:

\url{http://latex-cookbook.net/}
\quad and \quad
\url{http://texample.net/}

% -------------------------------------------

\pagebreak
\section{References and Literature}
\subsection{Citing Literature}

It is \emph{very} important that you give appropriate credit to the sources that you used.

Try to avoid direct quotes, but it is preferrable if you rephrase the information \emph{in your own words}.
But even then you must give credit to the source of the information appropriately.

References should use BibTeX. Pay extra attention to completeness and correctness.

Important: \textbf{Check all your references carefully!}

\medskip
Different kinds of references (books, journal articles, papers in conference proceedings, \ldots)
require different fields (page numbers, conference title, journal title, \ldots{} see, e.g., \cite{enwiki:bibtex}).

\medskip
Warning: Google Scholar, Mendeley, and even publishers often generate flawed entries:\\
missing authors, wrong authors, missing journal titles, wrong syntax, \ldots%
\footnote{Tip: DBLP \url{http://dblp.org/} has good BibTeX-entries for much of the literature in our domain.}

\medskip
Some basic style guides:
\begin{itemize}
\item Reference ideas (and quotes), but not every single word.
\item Chapter and page information is only needed for longer works such as books. 
\item It is common to postfix references: ``We use the LOAD graph \cite{DBLP:conf/sigir/SpitzG16}.''
\item When used as subject, use the names: ``\textcite{DBLP:conf/sigir/SpitzG16} show that \ldots''\\
  With a single author, use singular, with multiple authors, use plural.
\item The sentence should be grammatically correct without any bracketed term.\\
  \ldots but this violation of the rule is usually accepted: ``as used in \cite{DBLP:conf/sigir/SpitzG16}.''
\end{itemize}

\medskip
Pro-Tip: \emph{First} add the references to bibtex, \emph{then} write the sentences and insert the reference \emph{immediately}.
Do not postpone references, because reconstructing them days later is \emph{much} more work than
typing ``\texttt{\textbackslash{}cite\{abc\}}'' as you write the text.
It does not harm to add a bibtex entry and never use it -- only used entries are included.

\pagebreak
\subsection{Citing Web Pages}

With web pages you have to give the title, authors, URL, \textbf{access date}, and -- if possible --
an \textbf{archived copy}, because web pages can change at any time.%
\ifThesis\footnote{For a bachelor and masters thesis, it is recommended to include a copy on the CD.}\fi

The appropriate BibTeX type for a web page is \texttt{@misc}.

\medskip
If you \emph{really} cannot find a \emph{better} source than Wikipedia
(primary sources are always preferrable to secondary sources such as Wikipedia,
and with Wikipedia you do not know who the real author of a statement is),
then at least use the ``cite this page'' function.\\
But even this function produces flawed BibTeX entries, so \emph{fix the errors}.

Example with a \emph{permanent} URL (but unspecific authors): ``\fullcite{enwiki:bibtex}''

\subsection{Citing Images}
Images are usually considered to be stand-alone, copyrighted, works.

\medskip
§60a UrhG allows the use of figures and excerpts in education \emph{to a large extent},%
\footnote{You need to look up the legislation details yourself,
e.g., on \url{https://www.bmbf.de/de/neues-urheberrechtsgesetz-fuer-die-wissenschaft-4431.html} (German)}
but:

\medskip
§63 UrhG:
``When a work or part of a work [\ldots]
is duplicated or distributed,
\textbf{you must always clearly indicate the source}.''
(name the author, \emph{not just give an URL}!)

\bigskip
Obey copyright laws (i.e., German Urheberrecht). It's not fun, but necessary.

