
% font with unicode support
\usepackage{fontspec}

% clickable tocs
\usepackage{hyperref}

% use english
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}

% floating figures
\usepackage{float}

% for appendices
\usepackage[toc,page]{appendix}

% for multiple cites
\usepackage{cite}

\usepackage{tikz}
\usetikzlibrary{matrix, arrows, decorations}
\tikzset{node distance=2.5em, row sep=2.2em, column sep=2.7em, auto}

\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{caption}
\usepackage{subcaption}

% Matrices have a upper bound for its size
\setcounter{MaxMatrixCols}{20}

% for the fib arrow
\usepackage{amssymb}

% mathbb for lowercase bbs
\usepackage{bbm}

% Some basic objects
\newcommand{\N}{\mathbb{N}}				% natural numbers
\newcommand{\Np}{{\mathbb{N}^{>0}}}		% positive numbers
\newcommand{\Z}{\mathbb{Z}}				% integers
\newcommand{\R}{\mathbb{R}}				% reals
\newcommand{\Q}{\mathbb{Q}}				% rationals
\renewcommand{\k}{\mathbbm{k}}			% default ground ring

% Basic category stuff
\newcommand{\cat}[1]{\mathbf{#1}}		% the category of ...
\newcommand{\opCat}[1]{{#1}^{\text{op}}}% opposite category
\newcommand{\Hom}{\mathbf{Hom}}
\newcommand{\id}{\mathbf{id}}
\newcommand{\Ho}{\cat{Ho}}

% Categories
\newcommand{\Set}{\cat{Set}}			% sets
\newcommand{\Top}{\cat{Top}}			% topological spaces
\newcommand{\Ab}{\cat{Ab}}				% abelian groups
\newcommand{\DELTA}{\boldsymbol{\Delta}}% the simplicial cat
\newcommand{\simplicial}[1]{\cat{s{#1}}}% simplicial objects
\newcommand{\sSet}{\simplicial{\Set}}	% simplicial sets
\newcommand{\Mod}[1]{\cat{{#1}Mod}}		% modules over a ring
\newcommand{\Alg}[1]{\cat{{#1}Alg}}		% algebras over a ring
\newcommand{\grMod}[1]{\cat{gr\mbox{-}{#1}Mod}}	% graded modules over a ring
\newcommand{\grAlg}[1]{\cat{gr\mbox{-}{#1}Alg}}	% graded algebras over a ring
\newcommand{\dgMod}[1]{\cat{dg\mbox{-}{#1}Mod}}	% differential graded modules over a ring
\newcommand{\dgAlg}[1]{\cat{dg\mbox{-}{#1}Alg}}	% differential graded algebras over a ring
\newcommand{\Ch}[1]{\cat{Ch_{n\geq0}({#1})}}	% chain complexes
\newcommand{\CoCh}[1]{\cat{Ch^{n\geq0}({#1})}}	% cochain complexes
\newcommand{\DGA}{\cat{DGA}}			% cochain algebras
\newcommand{\CDGA}{\cat{CDGA}}			% commutative cochain algebras

\newcommand{\cof}{\hookrightarrow}		% cofibration
\newcommand{\fib}{\twoheadrightarrow}	% fibration
\newcommand{\we}{\tot{\simeq}}			% weak equivalence

%\newcommand{\leftadj}{\ooalign{\hss\rightleftarrows\hss\cr\bot}}
\newcommand{\leftadj}{\rightleftarrows}

% Notation and operators
\newcommand{\I}{\,\mid\,}				% seperator in set notation
\newcommand{\del}{\partial}				% boundary
\newcommand{\iso}{\cong}				% isomorphic
\newcommand{\eq}{\sim}					% homotopic
\newcommand{\tot}[1]{\xrightarrow{\,\,{#1}\,\,}}	% arrow with name
\newcommand{\toti}[1]{\xleftarrow{\,\,{#1}\,\,}}	% left arrow with name
\newcommand{\mapstot}[1]{\xmapsto{\,\,{#1}\,\,}}	% mapsto with name
\DeclareMathOperator*{\im}{im}
\DeclareMathOperator*{\coker}{coker}
\DeclareMathOperator*{\colim}{colim}
\DeclareMathOperator*{\Tor}{Tor}
\DeclareMathOperator*{\Ext}{Ext}
\DeclareMathOperator*{\tensor}{\otimes}
\DeclareMathOperator*{\bigtensor}{\bigotimes}
\renewcommand{\deg}[1]{{|{#1}|}}
\newcommand{\Char}[1]{char({#1})}
\newcommand{\RH}{\widetilde{H}}			% reduced homology

% restriction of a function
\newcommand\restr[2]{{% we make the whole thing an ordinary symbol
  \left.\kern-\nulldelimiterspace % automatically resize the bar with \right
  #1 % the function
  \vphantom{\big|} % pretend it's a little taller at normal size
  \right|_{#2} % this is the delimiter
  }}

% Todos in the margin
\newcommand{\todo}[1]{
	\addcontentsline{tdo}{todo}{\protect{#1}}
	$\ast$ \marginpar{\tiny $\ast$ #1}
}
% Big todos in text
\newcommand{\TODO}[1]{
	\addcontentsline{tdo}{todo}{\protect{#1}}
	{\tiny $\ast$ #1}
}
% TODO item, as itemize does not work
\newcommand{\titem}[0]{\\-\qquad}
% List of todos
\makeatletter
	\newcommand \listoftodos{\section*{Todo list} \@starttoc{tdo}}
	\newcommand\l@todo[2]{
		\par\noindent \textit{#2}, \parbox{10cm}{#1}\par
	}
\makeatother

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{claim}[theorem]{Claim}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{example}[theorem]{Example}

\newcommand{\EnvTemp}[4]{
	\begin{#1}\label{#2:#3}
		{#4}
	\end{#1}
}

\newcommand{\RefTemp}[3]{{#1}~\ref{#2:#3}}

\newcommand{\Theorem}{\EnvTemp{theorem}{thm}}
\newcommand{\Proposition}{\EnvTemp{proposition}{prop}}
\newcommand{\Lemma}{\EnvTemp{lemma}{lem}}
\newcommand{\Corollary}{\EnvTemp{corollary}{cor}}
\newcommand{\Claim}{\EnvTemp{claim}{clm}}
\newcommand{\Proof}[1]{\begin{proof}{#1}\end{proof}}

\newcommand{\Def}{\emph}
\newcommand{\Definition}{\EnvTemp{definition}{def}}
\newcommand{\Notation}{\EnvTemp{notation}{not}}
\newcommand{\Example}{\EnvTemp{example}{eg}}

\newcommand{\TheoremRef}{\RefTemp{Theorem}{thm}}
\newcommand{\LemmaRef}{\RefTemp{Lemma}{lem}}

% headings for a table
\newcommand*{\thead}[1]{\multicolumn{1}{c}{\bfseries #1}}

% simple way to center an image
\newcommand{\cimage}[2][]{
	\begin{center}
	\includegraphics[#1]{#2}
	\end{center}
}