\documentclass[
paper=a4,
fontsize=12pt,
twoside=false, % set to true for two-sided printing, but theses are typically printed one-sided.
parskip=half,
listof=totoc,
DIV=calc % calculate type area (see KOMA documentation!)
]{scrbook}
%% Exam Regulations tell us to use Arial size 11pt, which we could get by doing the following
%% (we would be cheating slightly by using the very similar Helvetica font)
%% However, this looks awful. Uncomment at your own risk.
%\usepackage[scaled=0.92]{helvet} % scaled to match it with rm font
%\renewcommand\familydefault{\sfdefault}% % use sans-serif font for the rest of the document
%% Reset margins:
%\typearea[current]{calc} % recalculate type area (needed when changing fonts) -- KOMA style (large margins!)
%% -- or --
%\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry} % geometry package (small margins)
\usepackage{scrhack} % fixes warnings caused by listings package
\usepackage{setspace} % for \setstretch
% TODO: margins
%% language settings
\usepackage{cmap} % make copy-paste work
\usepackage[utf8]{inputenc} % not always necessary
\usepackage[T1]{fontenc}
\usepackage[babel=true,expansion=alltext,protrusion=alltext-nott]{microtype} % better kerning and general typography
\usepackage[english]{babel}
\usepackage{csquotes} % for \enquote{...}
\DisableLigatures{encoding = T1, family = tt* } % disable minus-minus ligature for typewriter font
%% color and graphics
\usepackage{xcolor} % for colors. Pass the option "table" to colorize table rows, and "dvipsnames or "svgnames" to use more color names
%% bibliography
\usepackage[style = authoryear, backend = biber, natbib = true, minnames=1, maxcitenames=2, maxbibnames=99]{biblatex}
\addbibresource{bibliography.bib}
%% figures
\usepackage{graphicx} % for \includegraphics
\graphicspath{{figures/}} % set default path for figures
\usepackage[caption=false]{subfig} % for subfigures: \subfloat[Caption]{\includegraphics[...]{...}}
%% tables
\usepackage{longtable} % if you need tables that span multiple pages: \begin{longtable}{...} ... \end{longtable}
% nicer tables
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule
\renewcommand{\arraystretch}{1.2} % more space between rows
% code listings and algorithms
\usepackage{algorithm} % for algorithms: \begin{algorithm} ... \end{algorithm}
\usepackage{listings} % for code listings: \begin{lstlisting}[language=Python] ... \end{lstlisting}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
keepspaces=true,
upquote=true,
showstringspaces=false,
commentstyle=\color{gray},
keywordstyle=\color{blue},
stringstyle=\color{red}
}
\usepackage{algpseudocode} % for pseudocode: \begin{algorithmic} ... \end{algorithmic}
%% acronyms
%\usepackage[printonlyused]{acronym}
%% math
\usepackage{amsmath} % for \DeclareMathOperator, \text, \mathbb, etc.
\usepackage{amsfonts} % declares mathematical fonts
\usepackage{amssymb} % declares mathematical symbols
\usepackage{bm} % bold math symbols: use \bm{\lambda}
\usepackage{mathtools} % for \DeclarePairedDelimiter
\input{definitions/math} % custom math commands
%% various helpers
\usepackage{titling} % make \theauthor, \thetitle, \thedate available
\usepackage{xstring} % for StrCount, so "Supervisor(s)" can be pluralized
\usepackage{ifthen}
%% todo-notes
\usepackage[colorinlistoftodos]{todonotes}
%% Headers. Note that scrbook is not compatible with fancyhdr.
%\usepackage[automark,headsepline,plainheadsepline]{scrlayer-scrpage}
%\clearpairofpagestyles
%\ihead{\leftmark}
%\ohead*{\pagemark}
%\addtokomafont{pagehead}{\normalfont}
%\renewcommand\chaptermarkformat{\ifnumbered{chapter}{\chapapp\ \thechapter:\enskip}{}}
%% Make "List of X" (e.g. "List of Figures") conditional on there being any X
\usepackage{assoccnt}
\usepackage{totcount}
% Figures
\regtotcounter{figure}
\newtotcounter{totfigures}
\DeclareAssociatedCounters{figure}{totfigures}
% Tables
\regtotcounter{table}
\newtotcounter{tottables}
\DeclareAssociatedCounters{table}{tottables}
% Listings
\regtotcounter{lstlisting}
\newtotcounter{totlistings}
\DeclareAssociatedCounters{lstlisting}{totlistings}
% Algorithms
\regtotcounter{algorithm}
\newtotcounter{totalgorithms}
\DeclareAssociatedCounters{algorithm}{totalgorithms}
\PassOptionsToPackage{hyphens}{url} % is loaded by other packages, so we need to pass the option here
%% hyperlinks within the document -- this should be the last package
\usepackage[hidelinks]{hyperref} % "hidelinks" removes the colored boxes around links that are otherwise present when viewing the document electronically
\usepackage[hyphens]{url}
\usepackage[capitalize]{cleveref} % \cref{}: automatically adds "Figure" etc. to references.
%% glossaries, load after hyperref
\usepackage{ragged2e} % for \Centering, \RaggedLeft and \RaggedRight used in glossary entries
% this creates the 'list of acronyms'. Remove 'nonumberlist' to include a list of forward references to where the acronyms occur in the list of acronyms.
\usepackage[toc,acronyms,nonumberlist]{glossaries}
\makeglossaries
\input{definitions/acronyms}
\usepackage[all,defaultlines=3]{nowidow} % prevent widows and orphans
\usepackage{footnotehyper} % for footnotes in tables
\makesavenoteenv{tabular} % recommended by footnotehyper docs
\makesavenoteenv{table} % ditto
\setcounter{tocdepth}{1} % table of contents depth: 0 = chapter, 1 = section, 2 = subsection, 3 = subsubsection
% Add 'appendix' in ToC.
% Note that the 'title' and 'header' option of the 'appendix' package does not work in the scrbook-class!
\usepackage[titletoc]{appendix}
\input{definitions/metadata}
\makeatletter
\hypersetup{
pdftitle={\thetitle}, % Title
pdfauthor={\theauthor}, % Author
pdfsubject={\thesisfield}
}
\makeatother
\newcommand{\printsupervisors}{
\StrCount{\supervisor}{\\}[\numberofsupervisors]
\textbf{\ifthenelse{\numberofsupervisors > 0}{Supervisors:}{Supervisor:}}
\hspace*{0.1cm}
\begin{tabular}[t]{@{}p{9cm}@{}}
\supervisor
\end{tabular}
}
%\usepackage{showframe}
\begin{document}
\begin{titlepage}
\begin{center}
\LARGE
\university\\
\vspace{0.2cm}
\large
{\setstretch{1.5}
\institution
}
\vspace{1cm}
\Huge
\hrule
\textbf{\thetitle}
\vspace{\topskip}
\hrule
\vspace{1cm}
\LARGE
\textbf{\theauthor}
\vfill
\large
A Thesis Submitted in Partial Fulfillment \\ of the Requirements for the Degre of\\
\vspace{0.5cm}
\textit{\thesisdegree}\\
\vspace{0.5cm}
in the Field of \thesisfield
\vspace{0.8cm}
%% \includegraphics[width=0.4\textwidth]{figures/lmu-logo}
\vspace{0.8cm}
\printsupervisors
\vspace{0.5cm}
\textbf{\Large\thedate}
\vspace{-\footskip} % pull down the date to the bottom of the page (footnote height)
\end{center}
\end{titlepage}
\frontmatter
\onehalfspacing
\renewcommand{\familydefault}{\sfdefault} % use sans-serif font for the rest of the document
\chapter*{Abstract}
\input{chapters/00_abstract}
\include{chapters/05_front_matter}
\tableofcontents
\ifnum\totvalue{totfigures}>0
\listoffigures
\fi
\ifnum\totvalue{tottables}>0
\listoftables
\fi
\ifnum\totvalue{totlistings}>0
\lstlistoflistings
\fi
\ifnum\totvalue{totalgorithms}>0
\listofalgorithms
\fi
\printglossary[type=\acronymtype,title=List of Acronyms]
% TODO: how to do short captions in the list of figures etc? \caption[shortcap]{longcaaaaap}
% TODO: glossaries, notation, abbreviations
%\printglossaries
%\listofabbreviations
%\listofnomenclature
% actual content
\mainmatter
\include{chapters/10_introduction}
\include{chapters/20_background}
\include{chapters/30_related}
\include{chapters/40_methods}
\include{chapters/50_experiments}
\include{chapters/60_results}
\include{chapters/70_discussion}
\include{chapters/80_conclusion}
% Bibliography
\chapter{Bibliography}
\printbibliography[heading=none]
% Appendices
\begin{appendices}
\renewcommand\chapterformat{Appendix~\thechapter.\enskip}
\include{chapters/90_appendix}
\end{appendices}
% \include{chapters/91_appendix_<name>}
% \include{chapters/92_appendix_<name>}
%\textcquote{knuth:ct}{This is a quote.}
%\blockcquote[pages 100--101]{knuth:ct}{This is a quote.}
\backmatter
\cleardoublepage
\thispagestyle{empty}
%% "Eigenstaendigkeitserklaerung" / Declaration of Authorship
%
% Hiermit versichere ich, dass ich die vorliegende Arbeit selbstständig verfasst und keine anderen als die angegebenen Quellen und Hilfsmittel benutzt habe.
\section*{Declaration of Authorship}
I hereby declare that this thesis is my own work and that I have not used any sources or aids except the ones declared or referenced.
Text passages quoted verbatim or near-verbatim from external sources, as well as figures taken from or based on external sources, are marked as such.
\noindent
I further declare that this thesis has not been submitted to any other examination board in the same or similar form.
\vspace{2cm}
\begin{center}
\begin{tabular}{@{}p{6cm}@{}}
\dotfill \\
\hspace*{0.5cm}Place, Date \\
\end{tabular}
\hfill
\begin{tabular}{@{}p{6cm}@{}}
\dotfill \\
\hspace*{0.5cm}\theauthor \\
\end{tabular}
\end{center}
\end{document}