\documentclass[a4paper,11pt,titlepage]{scrartcl}

%%%% Document Setup
\usepackage[top=2cm,lmargin=1in,rmargin=1in,bottom=3cm,hmarginratio=1:1]{geometry}
\usepackage{scrlayer-fancyhdr}
\usepackage{extramarks}
\usepackage{anyfontsize}
\usepackage{unicode-math}
\usepackage[scale=.85]{noto-mono} % TODO find better unicode mono font
\usepackage[final]{hyperref}
\pagestyle{fancy}
\lhead{\DocTitle}
\chead{\UniCourse}
\rhead{\firstxmark}
\lfoot{\lastxmark}
\cfoot{\thepage}
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}
%%%%

%%%% 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}
}
%%%%

%%%% Math packages
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{tikz}
\usetikzlibrary{cd, quotes}
\declaretheorem[name=Definition,style=definition,numberwithin=section]{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}
%%%%

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

%%%% 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
%%%
%%%%


\begin{document}
%% Titlepage
\maketitle
\setcounter{page}{1}
%%

%% TOC
\tableofcontents
\pagebreak
%%

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