\documentclass[12pt,a4paper]{report}

\overfullrule=5mm

\usepackage[utf8]{inputenc}

\usepackage{titlesec} % titleformat
\usepackage{blindtext,color,fancyhdr}

\usepackage{geometry}
\geometry{a4paper, top=25mm, left=30mm, right=35mm,  bottom=35mm, headsep=10mm, footskip=12mm}

\usepackage{multirow,tabularx,tabu}
\usepackage{spreadtab}
\usepackage{colortbl}
\usepackage[dvipsnames]{xcolor}
\usepackage{hhline}

\usepackage[backend=biber,style=numeric,citestyle=numeric,url=true]{biblatex}
\addbibresource{thesis.bib}

%\usepackage[hyphens]{url}
\Urlmuskip = 0mu plus 1mu

%\hyphenpenalty=1
\pretolerance=5000
\tolerance=5000
%\exhyphenpenalty=1

\usepackage[numberedsection,toc,numberline,nopostdot]{glossaries}
\makenoidxglossaries

\usepackage{listings}
\providecommand*{\listingautorefname}{Listing}
\usepackage{minted}
\usepackage{graphicx}
\usepackage{placeins}
\usepackage{tikz}
\usetikzlibrary{tikzmark,mindmap}
\usetikzlibrary{chains,shapes.arrows, arrows, positioning,decorations.pathreplacing,bending}
\usetikzlibrary{calc}
\usepackage{smartdiagram}
\usepackage{color}

\usepackage{caption}
\usepackage{subcaption}

\tikzset{/minted/basename/.initial=minted}
\appto\theFancyVerbLine{\tikzmark{\pgfkeysvalueof{/minted/basename}\arabic{FancyVerbLine}}}

\usepackage[parfill]{parskip}

\usepackage{amsmath}

\usepackage{etoolbox}

\newcommand{\topic}{Guarantees On In-Kernel Memory-Safety Using Rust's Static Code Analysis}

\newcommand{\authorOne}{Stefan Junker}
\newcommand{\authorOneInit}{SJ}
\newcommand{\authorOnestreet}{Alemannenstr. 7}
\newcommand{\authorOnezip}{78467}
\newcommand{\authorOnecity}{Konstanz}
\newcommand{\authorOneCountry}{Germany}
\newcommand{\authorOneId}{283751}
\newcommand{\supervisorOne}{Prof. Dr. Michael Mächtel}
\newcommand{\supervisorTwo}{Felix Schuckert}
\newcommand{\studies}{Information Technology - Embedded And Mobile Systems}
\newcommand{\startdate}{2017/4/1}
\newcommand{\submitdate}{2017/9/29}
\newcommand{\buzzwords}{memory-safety, operating system, rust}

% Numbered Subsubsections
\setcounter{secnumdepth}{3}

\date{Summersemester 2017}
\title{\topic}

\author{authorOne}

\usepackage{etoolbox}
\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}
  {}{\errmessage{Cannot patch \string\part}}

\fancypagestyle{empty}{%
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \fancyhf{}
}

\fancypagestyle{front}{%
    \pagenumbering{roman}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \fancyhf{}
}

\fancypagestyle{preamble}{%
    \pagenumbering{roman}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \fancyhf{}
    \fancyfoot[R]{\thepage{}}
}

\fancypagestyle{main}{%
    \pagenumbering{arabic}
    \renewcommand{\headrulewidth}{0.25pt}
    \renewcommand{\footrulewidth}{0.25pt}
    \fancyhf{}
    \addtolength{\headwidth}{\marginparsep}
    \headheight=15pt
    \fancyhead[L]{\footnotesize\nouppercase{\leftmark}}
    \fancyhead[C]{}
    \fancyhead[R]{}
    \fancyfoot[R]{\thepage{}}
}

\titlespacing*{\chapter}{0cm}{-1cm}{0.75cm}
\titleformat{\chapter}[hang]{\normalfont\Large\bfseries}{\thechapter}{0.5cm}{}

\usepackage{hyperref}
\usepackage{cleveref}

\makeatletter

\newcommand{\cnameref}[1]{\cref{#1} \textit{(\nameref{#1})}}
\newcommand{\Cnameref}[1]{\Cref{#1} \textit{(\nameref{#1})}}

%\renewcommand\paragraph{\startsection{paragraph}{4}{\z}%
%                                     {-3.25ex\plus -1ex \minus -.2ex}%
%                                     {0.0001pt \plus 0.2ex}%
%                                     {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\startsection{subparagraph}{5}{\z}%
                                     {-3.25ex\plus -1ex \minus -.2ex}%
                                     {0.0001pt \plus 0.2ex}%
                                     {\normalfont\normalsize\bfseries}}

\newcommand{\iitemA}{\setlength\itemindent{0pt}\item}
\newcommand{\iitemB}{\setlength\itemindent{25pt}\item}
\newcommand{\iitemC}{\setlength\itemindent{50pt}\item}

\let\Partmark\partmark
\def\partmark#1{\def\Partname{#1}\Partmark{#1}}
\let\Chaptermark\chaptermark
\def\chaptermark#1{\def\Chaptername{#1}\Chaptermark{#1}}
\let\Sectionmark\sectionmark
\def\sectionmark#1{\def\Sectionname{#1}\Sectionmark{#1}}
\let\Subsectionmark\subsectionmark
\def\subsectionmark#1{\def\Subsectionname{#1}\Subsectionmark{#1}}
\let\Subsubsectionmark\subsubsectionmark
\def\subsubsectionmark#1{\def\Subsubsectionname{#1}\Subsubsectionmark{#1}}


\newenvironment{compactminted}{%
    \VerbatimEnvironment
    \let\FV@ListVSpace\relax
    \begin{minted}}%
    {\end{minted}}

\tikzset{west above/.code=\tikz@lib@place@handle@{#1}{south west}{0}{1}{north west}{1}}
\tikzset{west below/.code=\tikz@lib@place@handle@{#1}{north west}{0}{-1}{south west}{1}}
\tikzset{east above/.code=\tikz@lib@place@handle@{#1}{south east}{0}{1}{north east}{1}}
\tikzset{east below/.code=\tikz@lib@place@handle@{#1}{north east}{0}{-1}{south east}{1}}

% Tikzmark code helpers {
\newcommand{\tikzmarkprefix}{\pgfkeysvalueof{/tikz/tikzmark prefix}}
\newcommand{\tikzmarkcountprep}[1]{%
\tikzset{tikzmark prefix=#1}%
%\tikzset{tikzmark prefixes/#1/counter/.initial=0}%
\newcounter{Tikzcounter#1}%
}
\newcommand{\tikzmarkcount}[1][\tikzmarkprefix]{%
\stepcounter{Tikzcounter#1}%
\tikzmark{\arabic{Tikzcounter#1}}%
}
\newcommand{\tikzmarkgetcount}[1][\tikzmarkprefix]{%
\expandafter\arabic\expandafter{Tikzcounter#1}%
}
\newcommand{\tikzmarkcircle}[1]{%
    \tikz[baseline=-0.77ex]\fill circle[fill=black,radius=1.1ex] node[font=\small,color=white]{#1};
}
\newcommand{\tikzmarkdrawcircles}{%
    \begin{tikzpicture}[remember picture,overlay]
        \foreach \x in {1,...,\expandafter\arabic\expandafter{Tikzcounter\expandafter\tikzmarkprefix}}
        \fill (pic cs:\x)+(1.3ex,0.5ex) circle[fill=black,radius=1.1ex,anchor=west] node[font=\small,color=white]{$\x$};
    \end{tikzpicture}%
}

% }
                                 
\makeatother
\include{glossary}

\overfullrule=1cm

\begin{document}

    %TODO: \include{cover}
\pagestyle{front}
    \include{title}

\pagestyle{preamble}
    \include{abstract}
    %TODO: \include{affidavit}
    \cleardoublepage
    \newcounter{roman_pagenumbers} % save page number
    \setcounter{roman_pagenumbers}{\value{page}}

\pagestyle{main}
	%TODO \include{acknowledgments}
    %TODO abstract

    \chapter*{Preface}
    This thesis is original, unpublished, independent work by me, \authorOne.
    I strongly believe in openness and collaboration in the development of new technology, therefore the development will be based solely on Open-Source software.
    The source of this document and the code I have worked on will be freely available on my personal Gitlab site\footnote{https://gitlab.com/steveeJ/msc-thesis} once the academic process of this project is complete.


	\tableofcontents

    \part{Context}
    \label{context}

    \printnoidxglossary

    \include{parts/context/context}

    \part{Research And Development}
    \label{rnd}
    \include{parts/research_and_development/research_and_development}

    \part{Evaluation And Conclusion}
    \label{eval_and_conclusion}
    \include{parts/eval_and_conclusion/eval_and_conclusion}

	\newpage
	%TODO \listofmyequations
	\listoftables
	%TODO \lstlistoflistings
	\listoffigures
    \printbibliography

\end{document}
