\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsxtra}
\usepackage[scr=rsfs]{mathalfa} %for \mathsrc
\usepackage{xspace} %correct space after i.e. and e.g.
\usepackage{comment} %comment large blocks of text
\usepackage{tikz}
\usetikzlibrary{cd}
\tikzcdset{
  arrow style=math font
}

\usepackage{comment}
\usepackage{textcomp}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage[colorlinks=true,linkcolor=purple,citecolor=teal,urlcolor=blue]{hyperref}


%%Theorems
%%========
\newtheorem{theorem}{Theorem}[section]
\newtheorem*{theorem*}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem*{corollary*}{Corollary}
\newtheorem{question}[theorem]{Question}
\newtheorem*{question*}{Question}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem*{conjecture*}{Conjecture}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{nonexample}[theorem]{Counterexample}
\newtheorem{remark}[theorem]{Remark}
\newtheorem*{remark*}{Remark}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{exercise}[theorem]{Exercise}

%% Misc. 
\newcommand{\ie}{i.e.\xspace}
\newcommand{\eg}{e.g.\xspace}
\newcommand{\loccit}{\textit{loc.\,cit.}\xspace}
\newcommand{\abs}[1]{\lvert #1\rvert}
\newcommand{\op}{\mathrm{op}} % opposite symbol
\newcommand{\fg}{\mathrm{fg}} %finitely generated
\newcommand{\fp}{\mathrm{fp}} %finitely presented

\renewcommand{\phi}{\varphi}
\renewcommand{\epsilon}{\varepsilon}

%% Boldface or BBold 
\newcommand{\num}[1]{\mathbb{#1}}
\newcommand{\ZZ}{\num{Z}}
\newcommand{\QQ}{\num{Q}}
\newcommand{\RR}{\num{R}}
\newcommand{\CC}{\num{C}}

%% Arrows: Isomorphisms, equivalences, homotopies
\newcommand{\too}{\longrightarrow}%long rightarrow
\newcommand{\lto}{\too}%same
\newcommand{\iso}{\cong}
\newcommand{\we}{\overset{\simeq}{\to}}
\newcommand{\lwe}{\overset{\simeq}{\lto}}
\newcommand{\cof}{\rightarrowtail}
\newcommand{\fib}{\twoheadrightarrow}

%% Operators
\DeclareMathOperator{\Aut}{Aut}
\DeclareMathOperator{\coker}{Coker}
\newcommand{\Colim}{\varinjlim}
\DeclareMathOperator{\colim}{colim}
\DeclareMathOperator{\Cone}{Cone}
\DeclareMathOperator{\Cyl}{Cyl}
\DeclareMathOperator{\End}{End}
\DeclareMathOperator{\Ext}{Ext}
\DeclareMathOperator{\Fun}{Fun}
\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\bHom}{\mathbf{Hom}}
\DeclareMathOperator{\id}{id}
\renewcommand{\Im}{\operatorname{Im}}
\renewcommand{\ker}{\operatorname{Ker}}
\DeclareMathOperator{\Ker}{Ker}
\newcommand{\Lim}{\varprojlim}
%%\lim is already defined
\DeclareMathOperator{\Nat}{Nat}
\DeclareMathOperator{\Obj}{Obj}
\DeclareMathOperator{\Path}{Path}
\newcommand{\ts}{\textsuperscript}
\DeclareMathOperator{\Tor}{Tor}
\DeclareMathOperator{\Tot}{Tot}

%% Categories
\newcommand{\cat}[1]{\mathscr{#1}}
\newcommand{\catA}{\cat{A}}
\newcommand{\catB}{\cat{B}}
\newcommand{\catC}{\cat{C}}
\newcommand{\catD}{\cat{D}}

\newcommand{\Set}{\mathbf{Set}} %Category of sets
\newcommand{\Grp}{\mathbf{Grp}} %Category of groups
\newcommand{\Ab}{\mathbf{Ab}} %Abelian groups
\newcommand{\Mod}[1]{#1\text{-}\mathbf{Mod}} %Modules
\newcommand{\RMod}{\Mod{R}}
\newcommand{\SMod}{\Mod{S}}
