\documentclass{book}
\usepackage[total={6in, 9in}]{geometry}
\usepackage{amsmath, amssymb, amsthm, stmaryrd, mathrsfs, gensymb, dsfont}
\usepackage{mathtools, adjustbox}
\usepackage{enumitem, xfrac, xcolor, cancel, multicol, tabularx, relsize}
\usepackage[normalem]{ulem}
\usepackage{hyperref, refcount}
\usepackage{fancyhdr, titling}
\usepackage[backend=biber, citetracker=true, citestyle=alphabetic, bibstyle=ieee-alphabetic, sorting=nty, sortcites=true]{biblatex}
\usepackage{pgfplots, tikz, tikz-cd}
\usepackage{graphicx, wrapfig}
\usepackage[ordering=Kac]{dynkin-diagrams}
\usepackage{rank-2-roots}
\usepackage{imakeidx}
\usepackage{tcolorbox}
\usepackage{footnote}

% Set the default colors
\definecolor{mosgreen}{RGB}{29, 135, 17}
\definecolor{thmbackground}{RGB}{249, 249, 249}
\definecolor{thmrule}{RGB}{230, 230, 230}

% Configure fonts
\usepackage[T1]{fontenc}
\usepackage[sc]{mathpazo}
\renewcommand*\ttdefault{txtt}
\usepackage[scr=euler,cal=boondox]{mathalfa}
\hypersetup{
  colorlinks,
  citecolor=black,
  filecolor=black,
  linkcolor=black,
  urlcolor=mosgreen,
}

% Configure graphics
\usetikzlibrary{calc, shadows.blur, shapes.geometric, patterns, arrows}
\pgfplotsset{compat=1.16}

% Initialize the imakeidx package
\makeindex

% Configure the style of Dynkin diagrams
\tikzset{/Dynkin diagram,
         edge length=15mm,
         arrow shape/.style={-{To[length=7pt]}},
         mark=o,
         root-radius=.18cm,
         text style/.style={scale=1.2}}

% Configure the enumerate environment to use bold roman numerals
\setenumerate[0]{label={\color{mosgreen}\normalfont \bfseries(\roman*)}}

% Macro for creating boxed theorem environments
\newcounter{theorem}[chapter]
\renewcommand{\thetheorem}{\thechapter.\arabic{theorem}}
\newcommand{\newboxedtheorem}[2]
  {
    \newtheorem{inner#1}[theorem]{#2}
    \newenvironment{#1}[1][{}]
      {
        \savenotes
        \begin{tcolorbox}[colback=thmbackground, colframe=thmrule]
        \begin{inner#1}[##1]
      }
      {\end{inner#1}\end{tcolorbox}\spewnotes}
  }

% Green theorem styles
\newtheoremstyle{coloredtheorem}{}{}{\em}{}{\bf\color{mosgreen}}{.}{.5em}{}
\newtheoremstyle{coloreddefinition}{}{}{}{}{\bf\color{mosgreen}}{.}{.5em}{}
\newtheoremstyle{coloredremark}{}{}{}{}{\itshape\color{mosgreen}}{.}{.5em}{}

% Useful theorem definitions
\theoremstyle{coloredtheorem}
\newboxedtheorem{theorem}{Theorem}
\newboxedtheorem{lemma}{Lemma}
\newboxedtheorem{corollary}{Corollary}
\newboxedtheorem{proposition}{Proposition}
\theoremstyle{coloreddefinition}
\newboxedtheorem{definition}{Definition}
\newtheorem{example}[theorem]{Example}
\theoremstyle{coloredremark}
\newtheorem*{note}{Remark}

% Custom page style
\fancypagestyle{custom}{%
    \fancyhead[EL]{%
    \raisebox{0.5em}{\thepage}%
    }
    \fancyhead[ER]{%
    \raisebox{0.5em}{\nouppercase{\leftmark}}%
    }
    \fancyhead[OL]{%
    \raisebox{0.5em}{\S\nouppercase{\rightmark}}%
    \vspace*{-0.5em}%
    }
    \fancyhead[OR]{%
    \raisebox{0.5em}{\thepage}%
    }
    \fancyfoot{}
}
\pagestyle{custom}

% Dedication environment
\newenvironment{dedication}
  {\clearpage            % We want a new page
   \thispagestyle{empty} % No header and footer
   \vspace*{\stretch{1}} % Some space at the top
   \begin{center}        % Centralize text
   \huge                 % Make the text larger
   \itshape              % The text is in italics
  }
  {\par                  % End the paragraph
   \end{center}
   \vspace{\stretch{3}}  % Space at bottom is three times that at the top
   \clearpage            % Finish off the page
   \null
   \thispagestyle{empty}
   \clearpage            % Skip a page
  }

% Command to print licensing information
\newcommand{\printlicense}
  {\clearpage
   \thispagestyle{empty}
   \vspace*{1cm} % Some space at the top
   \begin{center}
   This work is licensed under a \textbf{Creative Commons Attributions 4.0
   International License}
   \par
   \vspace{1em}
   \includegraphics[width=2cm]{images/by.eps}
   \end{center}
   \null\vfill
   \begin{center}Last updated \today\end{center}
   \clearpage
  }

% Command to define the subtitle in the cover of the book
\newcommand{\subtitle}[1]{\def\thesubtitle{#1}}

% Use \blacksquare for \qed
\renewcommand{\qedsymbol}{\ensuremath{\blacksquare}}

% Only use \smallsetminus
\renewcommand{\setminus}{\smallsetminus}

% Get propper inequality symbols
\renewcommand{\leq}{\leqslant}
\renewcommand{\le}{\leqslant}
\renewcommand{\geq}{\geqslant}
\renewcommand{\ge}{\geqslant}
\renewcommand{\preceq}{\preccurlyeq}
\renewcommand{\succeq}{\succcurlyeq}

% Add missing arrows
\newcommand{\longhookrightarrow}{\lhook\joinrel\longrightarrow}
\newcommand{\longhookleftarrow}{\longleftarrow\joinrel\rhook}
\DeclareRobustCommand\longtwoheadrightarrow
  {\relbar\joinrel\twoheadrightarrow}

% Fix the subset/supset symbols
\renewcommand{\subset}{\subseteq}
\renewcommand{\supset}{\supseteq}

% A semantic alternative to \textbf
\newcommand{\strong}[1]{\textbf{#1}}

% Display long arrows instead of short ones
\renewcommand{\to}{\longrightarrow}
\renewcommand{\mapsto}{\longmapsto}

% Fix the goddamn \chi macro!
% For some reason the default LaTeX fonts place this character much lower than
% where people actually expect it to be. This new definition place it in with
% the appropriate spacing
\renewcommand{\chi}{\ensuremath \raisebox{\depth}{$\mathchar"11F$}}

% Macro for Mathieu's coherent extension
\newcommand{\mExt}{\mathcal{E\!x\!t}}

% Notation for twisted modules
\newcommand{\twisted}[2]{{}^{#2}\!{#1}}

% Isomorphism arrow
\newcommand{\isoto}{\xlongrightarrow{\sim}}

% Quotient object
\newcommand{\mfrac}[2]{\mathlarger{\sfrac{#1}{#2}}}

% A normal subobject in a pointed cathegory
\newcommand{\normal}{\triangleleft}

% Command for marking a node inside a matrix
\newcommand{\tm}[2]{%
  \tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {$#2$};%
}

% Command for drawing a vertical line between nodes in a matrix
\newcommand{\DrawVLine}[3][]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[shorten <=0.3ex, #1] (#2.north) -- (#3.south);
  \end{tikzpicture}
}

% Command for drawing a horizontal line between nodes in a matrix
\newcommand{\DrawHLine}[3][]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[shorten <=0.2em, #1] (#2.west) -- (#3.east);
  \end{tikzpicture}
}

% Command for printing the number of pages between two labels
\newcommand{\pagedifference}[2]{%
  \number\numexpr\getpagerefnumber{#2}-\getpagerefnumber{#1}\relax}


\DrawVLine}[3][]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[shorten <=0.3ex, #1] (#2.north) -- (#3.south);
  \end{tikzpicture}
}

% Command for drawing a horizontal line between nodes in a matrix
\newcommand{\DrawHLine}[3][]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[shorten <=0.2em, #1] (#2.west) -- (#3.east);
  \end{tikzpicture}
}

% Command for printing the number of pages between two labels
\newcommand{\pagedifference}[2]{%
  \number\numexpr\getpagerefnumber{#2}-\getpagerefnumber{#1}\relax}

ewcommand{\DrawHLine}[3][]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[shorten <=0.2em, #1] (#2.west) -- (#3.east);
  \end{tikzpicture}
}

% Command for printing the number of pages between two labels
\newcommand{\pagedifference}[2]{%
  \number\numexpr\getpagerefnumber{#2}-\getpagerefnumber{#1}\relax}

