\documentclass[a4paper,11pt,titlepage,numbers=noenddot]{scrbook}

%%%% Document Setup
\usepackage[top=2cm,lmargin=1in,rmargin=1in,bottom=3cm,hmarginratio=1:1]{geometry}
\usepackage{scrlayer-scrpage}
\usepackage[ngerman, english]{babel}
\babeltags{german=ngerman}
\usepackage{anyfontsize}
\usepackage{unicode-math}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{booktabs}
\usepackage[scale=.85]{noto-mono} % TODO find better unicode mono font
\usepackage[final]{hyperref}
\usepackage{scrhack}
\automark{chapter}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\subsectionmark}[1]{\markright{\thesubsection\ #1}}
\pagestyle{scrheadings}
\newcounter{resumeenum} % for resuming enumerated lists, https://tex.stackexchange.com/a/1702

%%%%

%%%% Metadata
\newcommand{\DocTitle}{Lecture notes}
\newcommand{\UniCourse}{Algebra of Programming}
\newcommand{\UniProf}{Prof.\ Dr.\ Stefan Milius}
\author{Leon Vatthauer}
%%%%

%%%% Title
\title{
    \vspace{2in}
    \textmd{\textbf{\UniCourse\\\DocTitle}}\\
    \vspace{0.1in}\large{\textit{\UniProf\ }}
    \vspace{3in}
}
%%%%

%%%% Code listings
\usepackage{minted}
\setminted[haskell]{
  linenos=true,
  breaklines=true,
  encoding=utf8,
  fontsize=\small,
  autogobble
}
\setmintedinline[haskell]{
    style=bw
}
%%%%

%%%% Spacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt}
\setlength{\marginparsep}{0cm}
\AtBeginEnvironment{minted}{\setlength{\parskip}{0pt}}
%%%%

%%%% Math packages
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{tikz}
\usetikzlibrary{cd, babel, quotes}
\usepackage{quiver}
\declaretheorem[name=Definition,style=definition,numberwithin=chapter]{definition}
\declaretheorem[name=Example,style=definition,sibling=definition]{example}
\declaretheorem[style=definition,numbered=no]{exercise}
\declaretheorem[name=Remark,style=definition,sibling=definition]{remark}
\declaretheorem[name=Assumption,style=definition,sibling=definition]{assumption}
\declaretheorem[name=Observation,style=definition,sibling=definition]{observation}
\declaretheorem[name=Theorem,sibling=definition]{theorem}
\declaretheorem[sibling=definition]{corollary}
\declaretheorem[name=Fact,sibling=definition]{fact}
\declaretheorem[sibling=definition]{lemma}
\declaretheorem[sibling=lemma]{proposition}
%%%%

%%%% href
\makeatletter
\hypersetup{
  pdfauthor={\@author},
  pdftitle={\UniCourse},
  % kill those ugly red rectangles around links
  hidelinks,
}
\makeatother
%%%%

%%%% Bibliography
\usepackage[style=ieee, sorting=ynt, language=british]{biblatex} % advanced citations, british to make dates DD-MM-YYYY
\usepackage[english=british]{csquotes} % biblatex recommended to load this
\addbibresource{bib.bib}
%%%%

%%%% Custom definitions: Commands and environments

%%% Case distinction environment
% Defines the `mycase` environment, copied from https://tex.stackexchange.com/questions/251053/how-to-use-case-1-case-2-in-a-proof-ieee-confs
\newcounter{cases}
\newcounter{subcases}[cases]
\newenvironment{mycase}
{
    \setcounter{cases}{0}
    \setcounter{subcases}{0}
    \newcommand{\case}
    {
        \par\indent\stepcounter{cases}\textbf{Case \thecases.}
    }
    \newcommand{\subcase}
    {
        \par\indent\stepcounter{subcases}\textit{Subcase (\thesubcases):}
    }
}
{
    \par
}
\renewcommand*\thecases{\arabic{cases}}
\renewcommand*\thesubcases{\roman{subcases}}
%%%

%%% Custom label command
\makeatletter
\newcommand{\customlabel}[2]{%
  \protected@write \@auxout {}{\string \newlabel {#1}{{#2}{\thepage}{#2}{#1}{}} }% chktex 1
  \hypertarget{#1}{#2}%
}
\makeatother
%%%

%%% Notation
%% Categories
\newcommand{\C}{\ensuremath{\mathscr{C}}}
\newcommand{\D}{\ensuremath{\mathscr{D}}}
%% Objects of category
\newcommand{\obj}[1]{\ensuremath{\vert #1 \vert}}
%% Dual category
\newcommand{\dual}[1]{\ensuremath{#1^{op}}}
%%%
%%%%

\begin{document}
%% Titlepage
\maketitle
\thispagestyle{empty}
\null\newpage
\setcounter{page}{1}
%%

%% TOC
\tableofcontents
%%

%% Contents
\include{sections/01_introduction}
\include{sections/02_categories}
\include{sections/03_constructions}
%%

\appendix
\emergencystretch=1em
\printbibliography[heading=bibintoc]{}
\end{document}