\documentclass[12pt, abstract]{scrartcl}
\usepackage{xstring}
\usepackage[pdfversion=1.4,colorlinks]{hyperref}
\usepackage{etoolbox}

\usepackage[inkscapeformat=eps]{svg}

\AddToHook{cmd/section/before}{\clearpage}

\usepackage{microtype}
\usepackage{suffix}

\usepackage[a4paper]{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}
\usepackage{enumitem}

\usepackage{float}
\usepackage{biblatex}
\usepackage[dvipsnames]{xcolor}

\usepackage{caption}

\newcommand{\repeatcaption}[2]{%
  \renewcommand{\thefigure}{\ref{#1}}%
  \captionsetup{list=no}%
  \caption{#2 (repeated from page \pageref{#1})}%
  \addtocounter{figure}{-1}% So that next figure after the repeat gets the right number.
}

\usepackage{fontawesome5}
\usepackage{scalefnt}


\usepackage[outputdir=output]{minted}
\newmintinline[lean]{lean4}{breaklines}
\newminted[leancode]{lean4}{}
\usemintedstyle{sas}  % a nice, colorful theme

\newcommand{\leandoc}[1]{\href{https://segfault.party/thesis-docs/find/?pattern=#1\#doc}{\lean{#1}}}

\WithSuffix\newcommand\leandoc*[2]{\href{https://segfault.party/thesis-docs/find/?pattern=#1\#doc}{\lean{#2}}}

\newcommand{\ldsym}[1]{\href{https://segfault.party/thesis-docs/find/?pattern=#1\#doc}{\raisebox{1ex-0.55\height}{\textcolor{black}{\scalefont{0.66}\faExternalLink*}}}}

\usepackage{csquotes}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{positioning,calc}
\usepackage{xifthen}
\usepackage{outlines}
\usepackage[capitalize]{cleveref}

\hypersetup{
    linkcolor=blue!50!black,
    citecolor=blue!50!black,
    filecolor=blue!50!black,
    urlcolor=Green,
    menucolor=blue!50!black,
    runcolor=blue!50!black,
    linkbordercolor=blue!50!black,
    citebordercolor=blue!50!black,
    filebordercolor=blue!50!black,
    urlbordercolor=NavyBlue,
    menubordercolor=blue!50!black,
    runbordercolor=blue!50!black,
}

\addbibresource{thesis.bib}

\makeatletter
\def\verbatim@nolig@list{}
\makeatother

\setlist{itemsep=0pt,topsep=7.5pt}

\defaultfontfeatures{ Scale = MatchAveragecase }
\defaultfontfeatures[\rmfamily]{Scale = 1}

\setmathfont[Scale=MatchUppercase,StylisticSet={3}]{Garamond-Math.otf}
\setmainfont[Ligatures={Common, TeX},WordSpace={1,1.05,0.5}]{EB Garamond}
%\setmainfont[Ligatures={Common,TeX}]{Adobe Caslon Pro}
\setsansfont{Fira Sans}
% \setmonofont[Contextuals=Alternate,BoldFont={Iosevka Bold}, BoldFeatures={Contextuals=Alternate,SizeFeatures={Size=9.75}}, SizeFeatures={Size=9.75}]{Iosevka}
\setmonofont[Contextuals=Alternate,BoldFont={Iosevka Bold}, BoldFeatures={Contextuals=Alternate}]{Iosevka}


\newfontface\mytitlefont{Fira Sans Condensed Medium}
\newfontface\mysubtitlefont{Fira Sans Condensed}

\setkomafont{disposition}{\normalcolor\mytitlefont}
\setkomafont{sectionentry}{\mytitlefont}

\DeclareTOCStyleEntries[%
    entryformat=\mysubtitlefont,
    pagenumberformat=\mysubtitlefont
]{section}{subsection,subsubsection}


\newcommand{\arsdef}[3]{$\mathcal{#1} = (#2, \to_{#3})$}
\newcommand{\iarsdef}[3]{$\mathcal{#1} = (#2, \{ \,\to_{\MakeLowercase{#3}} |\; \MakeLowercase{#3} \in #3 \,\})$}
\newcommand{\goesto}[3]{$#2 \to_{#1} #3$}

\renewcommand{\implies}{\Rightarrow}
\newcommand{\ot}{\leftarrow}
\newcommand{\otto}{\leftrightarrow}
\newcommand{\toto}{\twoheadrightarrow}
\newcommand{\otot}{\twoheadleftarrow}

\newcommand{\mx}{\ot_\#}
\newcommand{\mxone}{\ot_\#^1}
\newcommand{\mxplus}{\ot_\#^+}

\renewcommand{\AA}{\mathcal{A}}
\newcommand{\BB}{\mathcal{B}}
\newcommand{\GG}{\mathcal{G}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\CC}{\mathcal{C}}
\newcommand{\landscape}[2]{$#1 = {#1}_0 \leftrightarrow \cdots \leftrightarrow {#1}_n = #2$}
\WithSuffix\newcommand\landscape*[4]{$#1 = {#2}_0 \leftrightarrow \cdots \leftrightarrow {#2}_{#3} = #4$}

\newif\ifdraft
\draftfalse

\newtheoremstyle{plainwitharg}
  {} % ABOVESPACE
  {} % BELOWSPACE
  {\itshape} % BODYFONT
  {0pt} % INDENT (empty value is the same as 0pt)
  {\bfseries} % HEADFONT
  {} % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  % CUSTOM-HEAD-SPEC
  {\thmname{#1} \thmnumber{#2}\ifdefempty{\theoremarg}{}{ \,\ldsym{\theoremarg}\,}\textnormal{\thmnote{ (#3).}}}

\newtheoremstyle{witharg}
  {} % ABOVESPACE
  {} % BELOWSPACE
  {} % BODYFONT
  {0pt} % INDENT (empty value is the same as 0pt)
  {\bfseries} % HEADFONT
  {} % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  % CUSTOM-HEAD-SPEC
  {\thmname{#1} \thmnumber{#2}\ifdefempty{\theoremarg}{}{ \,\ldsym{\theoremarg}\,}\textnormal{\thmnote{ (#3).}}}
\newcommand{\theoremarg}{}

\theoremstyle{plainwitharg}

\newtheorem{theoreminner}{Theorem}[section]
\newtheorem{lemmainner}[theoreminner]{Lemma}
\newtheorem{corollaryinner}[theoreminner]{Corollary}
\newtheorem{exampleinner}[theoreminner]{Example}
  
\theoremstyle{witharg}
\newtheorem{definitioninner}[theoreminner]{Definition}

\NewDocumentEnvironment{theorem}{od<>}
 {%
  \IfNoValueF{#2}{\renewcommand{\theoremarg}{#2}}%
  \IfNoValueTF{#1}{\theoreminner}{\theoreminner[{#1}]}\ignorespaces
 }
 {\endtheoreminner}

\NewDocumentEnvironment{lemma}{od<>}
 {%
  \IfNoValueF{#2}{\renewcommand{\theoremarg}{#2}}%
  \IfNoValueTF{#1}{\lemmainner}{\lemmainner[{#1}]}\ignorespaces
 }
 {\endlemmainner}

\NewDocumentEnvironment{example}{od<>}
 {%
  \IfNoValueF{#2}{\renewcommand{\theoremarg}{#2}}%
  \IfNoValueTF{#1}{\exampleinner}{\exampleinner[{#1}]}\ignorespaces
 }
 {\endexampleinner}

\NewDocumentEnvironment{definition}{od<>}
 {%
  \IfNoValueF{#2}{\renewcommand{\theoremarg}{#2}}%
  \IfNoValueTF{#1}{\definitioninner}{\definitioninner[{#1}]}\ignorespaces
 }
 {\enddefinitioninner}

\NewDocumentEnvironment{corollary}{od<>}
 {%
  \IfNoValueF{#2}{\renewcommand{\theoremarg}{#2}}%
  \IfNoValueTF{#1}{\corollaryinner}{\corollaryinner[{#1}]}\ignorespaces
 }
 {\endcorollaryinner}

\newlist{defnumerate}{enumerate}{2}
\setlist[defnumerate]{label=(\roman*),ref=\thedefinitioninner (\roman*)}
\crefname{defnumeratei}{Definition}{Definitions}

\crefname{corollaryinner}{Corollary}{Corollaries}
\crefname{theoreminner}{Theorem}{Theorems}
\crefname{lemmainner}{Lemma}{Lemmas}
\crefname{definitioninner}{Definition}{Definitions}
\crefname{exampleinner}{Example}{Examples}

\newcommand{\mono}[1]{\texttt{\detokenize{#1}}}

\usepackage{tcolorbox}

\newtcolorbox{note}[1]{title={\mysubtitlefont#1}}

\newcommand{\CPC}{\ensuremath{\text{CP}^\equiv}}
\newcommand{\CP}{\ensuremath{\text{CP}}}
\newcommand{\SN}{\ensuremath{\text{SN}}}
\newcommand{\WF}{\ensuremath{\text{WF}}}
\newcommand{\CR}{\ensuremath{\text{CR}}}
\newcommand{\DCR}[1]{\ensuremath{\text{DCR}\ifblank{#1}{}{_{#1}}}}
\newcommand{\DCRtwo}{\ensuremath{\text{DCR}_2}}

\begin{document}

\include{0_frontpage}

\newpage
\tableofcontents
\newpage

\include{1_introduction}
\include{2_lean}
\include{3_abstractrewriting}
\include{4_newman}
\include{5_cofinality}
\include{6_dcr}
\include{7_conclusion}

\printbibliography

\end{document}