+% (file) structure
+\usepackage[subpreambles=true]{standalone} % standalone figures
+%\usepackage{morewrites} % fix no more room for a new \write
+\usepackage{appendix} % subappendices, appendices per chapter
+
+% Bibliography
+\usepackage{natbib} % Cite bib entry completely
+\setlength{\bibsep}{0.0pt}
+\def\bibfont{\small}
+%\bibliographystyle{alpha}
+\bibliographystyle{abbrvnat}
+\apptocmd{\thebibliography}{\raggedright}{}{}
+\usepackage{bibentry} % Cite bib entry completely
+\nobibliography*
+\newcommand{\citeentry}[1]{\begin{NoHyper}\bibentry{#1}\end{NoHyper}. \citep{#1}}
+
+\makeatletter
+\newcommand{\citepage}[1]{p.~#1}
+\newcommand{\citepages}[1]{pp.~#1}
+\newcommand{\citechapter}[1]{\cref@chapter@name~#1}
+\newcommand{\citechapters}[1]{\cref@chapter@name@plural~#1}
+\newcommand{\citesection}[1]{\cref@section@name~#1}
+\newcommand{\citesections}[1]{\cref@section@name@plural~#1}
+%\newcommand{\citesection}[1]{\S.~#1}
+%\newcommand{\citesections}[1]{\S\S.~#1}
+\newcommand{\citeparagraph}[1]{\P.~#1}
+\newcommand{\citeparagraphs}[1]{\P\P.~#1}
+\makeatother
+
+% Graphics
+\usepackage{graphicx} % Images
+\graphicspath{{img/},{intro/img},{top/img},{tvt/img}}
+\usepackage{caption} % subfigures
+\usepackage{subcaption}
+\usepackage{rotating}
+\newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}
+\usepackage{tikz}
+
+% Tables
+\usepackage{booktabs} % Nicer tables
+\usepackage{multirow} % Multirow cells
+\usepackage{tabularx} % Automatically wrapping tables
+\usepackage{longtable} % Tables spanning pages
+\usepackage{threeparttable} % Tables with footnotes
+
+% Code
+% Pseudocode
+\usepackage[algochapter,linesnumbered,lined,boxed]{algorithm2e}
+% Fix the algorithm font
+\renewcommand\AlCapFnt{\normalfont}
+\usepackage{listings}
+% https://tex.stackexchange.com/questions/149056/how-can-i-define-additional-literate-replacements-without-deleting-existing-ones
+\makeatletter
+\def\addToLiterate#1{\edef\lst@literate{\unexpanded\expandafter{\lst@literate}\unexpanded{#1}}}
+\lst@Key{moreliterate}{}{\addToLiterate{#1}}
+\makeatother
+% General listings settings
+\lstset{%
+ basewidth=0.5em,
+ basicstyle=\tt\small,
+ breakatwhitespace=false,
+ breaklines=true,
+ captionpos=b,
+ columns=[c]fixed,
+ commentstyle=\sl,
+ escapeinside={[+}{+]}, % chktex 9
+ frame=L,
+ keepspaces=true,
+ keywordstyle=\bf,
+ postbreak=\mbox{\textcolor{gray}{$\hookrightarrow$}\space},
+ showspaces=false,
+ showstringspaces=false,
+ showtabs=false,
+ stringstyle=\it,
+ tabsize=4,
+ upquote=true,
+ numberstyle=\tiny,
+}
+\usepackage{lstlangclean}
+\usepackage{lstlanghaskell}
+\usepackage{lstlangarduino}
+\lstloadlanguages{%
+ {[Arduino]C++},%
+ {c},%
+ {Python},%
+ {Clean},%
+ {[Regular]Haskell},
+ {[Lhs2Tex]Haskell}}
+\newcommand{\cinline}[1]{\lstinline[language=c,postbreak=]|#1|}
+\newcommand{\arduinoinline}[1]{\lstinline[language={[Arduino]C++},postbreak=]|#1|}
+\newcommand{\pythoninline}[1]{\lstinline[language=Python,postbreak=]|#1|}
+\newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
+\newcommand{\cleaninputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}\lstinputlisting[language=Clean,#1]{#2}}
+\newcommand{\haskellinline}[1]{\lstinline[language={[Regular]Haskell},postbreak=]|#1|}
+\newcommand{\haskellinputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}\lstinputlisting[language={[Regular]Haskell},#1]{#2}}
+\newcommand{\haskelllhstexinline}[1]{\lstinline[language={[Lhs2Tex]Haskell},postbreak=]|#1|}
+%For storing listings in footnotes
+\newsavebox{\LstBox}