% Input encoding
\usepackage[utf8]{inputenc}

% Papersize
\usepackage{geometry}
\geometry{
	inner=25mm,
	outer=20mm,
	marginparsep=3mm,
	marginparwidth=13mm,
	top=25mm,
	bottom=20mm,
	paperwidth=17cm,
	paperheight=24cm,
}

% Font encoding
\usepackage[T1,T2A]{fontenc}

% standalone figures
\usepackage[subpreambles=true]{standalone}

% Less bad boxes
\usepackage{microtype}

% No more room for a new \write
\usepackage{morewrites}

% Internationalisation
\usepackage[dutch,russian,british]{babel}
%\babelfont[russian]{rm}{Liberation Serif}

% Appendices (used for subappendices, appendices per chapter)
\usepackage{appendix}

% Cite bib entry completely
\usepackage{bibentry}
\nobibliography*

% Hyperlinks
\usepackage{bookmark,hyperref}
%\usepackage[pagebackref]{bookmark,hyperref}
% Setup pdf parameters: TODO
\hypersetup{%
	pdftitle={\mytitle},
	pdfauthor={\myauthor},
	pdfsubject={},
%	pdfcreator={},
%	pdfproducer={},
	pdfkeywords={task-oriented programming, functional programming, domain specific languages, internet of things},
	hidelinks,
}
\urlstyle{same}
\usepackage{xmpincl}
\includexmp{CC_Attribution-NoDerivatives_4.0_International}

% Graphics
\usepackage{graphicx}
% Images directory
\graphicspath{{img/}}
%subfigures
\usepackage{caption}
\usepackage{subcaption}

% Nice tables
\usepackage{booktabs}
% Multirow cells
\usepackage{multirow}

% orcid icon
\usepackage{academicons}
\newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}

% IPA symbols
\usepackage{tipa}

% Automatically wrapping tables
\usepackage{tabularx}

% Use a fixed document date
\usepackage[nodayofweek]{datetime}

% Code
\usepackage{stmaryrd}                         % Short arrow
\usepackage{textcomp}                         % upquote
\usepackage{listings}
% General listings settings
\lstset{%
	basewidth=0.45em,
	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,
}
\usepackage{lstlangclean}
\usepackage{lstlanghaskell}
\usepackage{lstlanghaskelllhstex}
\newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
\newcommand{\haskellinline}[1]{\lstinline[language=Haskell,style=haskell,postbreak=]|#1|}
\newcommand{\haskelllhstexinline}[1]{\lstinline[language=Haskell,style=haskelllhstex,postbreak=]|#1|}
% Fix list of listings title
\renewcommand{\lstlistlistingname}{List of Listings}
% Fix list of listings chapter separator
\makeatletter
\let\my@chapter\@chapter%
\renewcommand*{\@chapter}{%
  \addtocontents{lol}{\protect\addvspace{10pt}}%
  \my@chapter}
\makeatother

\lstnewenvironment{lstClean}[1][]
	{% 
		\lstset{language=Clean, #1}
		\renewcommand*{\lstlistingname}{Listing (Clean)}
	}
	{}
\lstnewenvironment{lstHaskell}[1][]
	{%
		\lstset{language=Haskell,style=haskell,#1}%
		\renewcommand*{\lstlistingname}{Listing (Haskell)}
	}
	{}
\lstnewenvironment{lstHaskellLhstex}[1][]
	{%
		\lstset{language=Haskell,style=haskelllhstex,#1}%
		\renewcommand*{\lstlistingname}{Listing (Haskell)}
	}
	{}

% Glossaries and acronyms
\usepackage[acronym,nonumberlist]{glossaries}
% Fix gls in hyperlink errors
\pdfstringdefDisableCommands{%
	\def\acrlong#1{}%
	\def\acrlongpl#1{}%
	\def\acrshort#1{}%
	\def\acrshortpl#1{}%
	\def\acrfull#1{}%
	\def\acrfullpl#1{}%
	\def\Acrlong#1{}%
	\def\Acrlongpl#1{}%
	\def\Acrshort#1{}%
	\def\Acrshortpl#1{}%
	\def\Acrfull#1{}%
	\def\Acrfullpl#1{}%
	\def\gls#1{}%
	\def\glspl#1{}%
	\def\glsentrytext#1{}%
	\def\Gls#1{}%
	\def\Glspl#1{}%
	\def\Glsentrytext#1{}%
	\def\titlecap#1{}%
}

% Titlecase commands
\usepackage{titlecaps}
\Addlcwords{of}
% Titlecase glossary command
\newcommand{\glst}[1]{\titlecap{\glsentrylong{#1}}}
\newcommand{\Glst}[1]{\glst{#1}}

% Pseudocode
\usepackage[algochapter]{algorithm2e}
% Fix the algorithm font
\renewcommand\AlCapFnt{\normalfont}

% Index
\usepackage{makeidx}
% Enable the index
\makeindex%

% Custom enumerations
\usepackage[inline,shortlabels]{enumitem}
\setlist{noitemsep}
\setlist[description]{leftmargin=\parindent}

% Epigraph
\usepackage{epigraph}

% Thumb marks on the page
\usepackage[
	height={1.5cm},
	width={12mm},
	distance={1.55cm},
	topthumbmargin={auto},
	bottomthumbmargin={auto},
	eventxtindent={.5cm},
	oddtxtexdent={.3cm}]{thumbs}

% Custom headers and footers
\usepackage{fancyhdr}
%\pagestyle{fancy}
\pagestyle{headings}

% Tables spanning pages
\usepackage{longtable}

% Easy references
\usepackage{cleveref}

% To patch the chapter command
\usepackage{etoolbox}
% Have better page numbering in chapters
\patchcmd{\chapter}{plain}{headings}{}{}

% Increase the depth for the table of contents
\setcounter{secnumdepth}{3}
\renewcommand{\contentsname}{Table of Contents} % change the name of the TOC
\AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} % to remove page numbering from the TOC

% Initialize the glossaries
\makeglossaries%
\input{glossaries}

% Custom commands
\newcommand{\GHCmod}[1]{\texttt{#1}}
\newcommand{\requiresGHCmod}[1]{\footnote{Requires \GHCmod{#1} to be enabled.}}
\newcommand{\etc}{{\fontfamily{cmr}\selectfont{\itshape\/\&c}}}
\newcommand{\rdmentry}[6]{#1: #2 (#3): #4. #5.\ \href{https://doi.org/#6}{#6}}
\newcommand{\mlubbers}{Lubbers, M.\ (Radboud University)}
\newcommand{\pkoopman}{Koopman, dr.\ P.\ (Radboud University)}
\newcommand{\rplasmeijer}{Plasmeijer, prof.\ dr.\ ir.\ R.\ (Radboud University)}

\bibliographystyle{alpha}

\usepackage{subfiles}
