insert first-class datatype
[phd-thesis.git] / preamble.tex
1 % Fonts
2 \usepackage[utf8]{inputenc} % Input encoding
3 \usepackage[T1]{fontenc} % Font encoding
4 \usepackage{lmodern} % Nicer font
5 \usepackage{microtype} % Better kerning
6 \usepackage{tipa} % IPA symbols
7 \usepackage{stmaryrd} % short arrows
8 \usepackage{textcomp} % upquote
9 \usepackage{titlecaps} % titlecase commands
10 \usepackage{amsmath} % extra math
11 \usepackage{amssymb} % extra math symbols
12 \usepackage{relsize} % \smaller command
13 \usepackage{atveryend} % \smaller command
14 \everymath{\it\/}
15 \DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39} %chktex 18
16 \newcommand{\dcolon}[0]{\mathbin{::}}
17
18 % Internationalisation
19 \usepackage[dutch,russian,british]{babel}
20 \input{hyphenation}
21 %\babelfont[russian]{rm}{Liberation Serif}
22
23 % Papersize and layout
24 \usepackage{geometry}
25 \geometry{
26 inner=25mm,
27 outer=20mm,
28 marginparsep=3mm,
29 marginparwidth=13mm,
30 top=25mm,
31 bottom=20mm,
32 paperwidth=17cm,
33 paperheight=24cm,
34 }
35 \usepackage{float}
36 \usepackage{fancyhdr} % Custom headers and footers
37 %\pagestyle{headings}
38 \pagestyle{fancy}
39 \fancyhead{}
40 \fancyfoot{}
41 \setlength{\unitlength}{18mm}
42 \newcommand{\blob}{\rule[-.2\unitlength]{2\unitlength}{.5\unitlength}}
43 \fancyhead[RE]{\rightmark}
44 \fancyhead[LO]{\leftmark}
45 \newcommand{\frontmatterfancy}[0]{
46 \fancyhead[RO]{\thepage}
47 \fancyhead[LE]{\thepage}
48 }
49 \newcommand{\mainmatterfancy}[0]{
50 \fancyhead[RO]{
51 \thepage%
52 \begin{picture}(0,0)
53 \put(1,-\value{chapter}){\blob}
54 \end{picture}
55 }
56 \fancyhead[LE]{
57 \begin{picture}(0,0)
58 \put(-3,-\value{chapter}){\blob}
59 \end{picture}%
60 \thepage%
61 }
62 }
63 \newcommand{\backmatterfancy}[0]{
64 \fancyhead[RO]{
65 \thepage%
66 \begin{picture}(0,0)
67 \put(1,-1){\blob}
68 \end{picture}
69 }
70 \fancyhead[LE]{
71 \begin{picture}(0,0)
72 \put(-3,-1){\blob}
73 \end{picture}%
74 \thepage%
75 }
76 }
77 \renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
78 \renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
79 %\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername}\ \thechapter.\ #1}{}}
80 %\renewcommand{\headrulewidth}{0pt}
81 \renewcommand{\footrulewidth}{0pt}
82 \usepackage{etoolbox} % To patch the chapter command
83 % Have better page numbering in chapters
84 \patchcmd{\chapter}{plain}{headings}{}{}
85 \usepackage{epigraph} % Epigraph
86 \renewcommand\partname{Movement} % Rename parts to movements (rhapsody uhu)
87 \addto\captionsbritish{\renewcommand{\partname}{Movement}}
88 \usepackage{titlesec}
89 \makeatletter
90 \titleformat{\part}[block]
91 {\Huge}
92 {\partname~\thepart:}
93 {20pt}
94 {}
95
96 \newenvironment{chapterabstract}
97 {\begin{quote}}
98 {\end{quote}}
99
100 % Increase the depth for the table of contents
101 \setcounter{secnumdepth}{3}
102 \renewcommand{\contentsname}{Table of Contents} % change the name of the TOC
103 \AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} % to remove page numbering from the TOC
104
105 % (file) structure
106 \usepackage[subpreambles=true]{standalone} % standalone figures
107 \usepackage{morewrites} % fix no more room for a new \write
108 \usepackage{appendix} % subappendices, appendices per chapter
109
110 % Bibliography
111 \usepackage{bibentry} % Cite bib entry completely
112 \nobibliography*
113 \bibliographystyle{alpha}
114
115 % Graphics
116 \usepackage{graphicx} % Images
117 \graphicspath{{img/},{introduction/img}}
118 \usepackage{caption} % subfigures
119 \usepackage{subcaption}
120 \newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}
121
122 % Tables
123 \usepackage{booktabs} % Nicer tables
124 \usepackage{multirow} % Multirow cells
125 \usepackage{tabularx} % Automatically wrapping tables
126 \usepackage{longtable} % Tables spanning pages
127
128 % Code
129 % Pseudocode
130 \usepackage[algochapter]{algorithm2e}
131 % Fix the algorithm font
132 \renewcommand\AlCapFnt{\normalfont}
133 \usepackage{listings}
134 % General listings settings
135 \lstset{%
136 basewidth=0.5em,
137 basicstyle=\tt,
138 breakatwhitespace=false,
139 breaklines=true,
140 captionpos=b,
141 columns=[c]fixed,
142 commentstyle=\sl,
143 escapeinside={[+}{+]}, % chktex 9
144 frame=L,
145 keepspaces=true,
146 keywordstyle=\bf,
147 postbreak=\mbox{\textcolor{gray}{$\hookrightarrow$}\space},
148 showspaces=false,
149 showstringspaces=false,
150 showtabs=false,
151 stringstyle=\it,
152 tabsize=4,
153 upquote=true,
154 }
155 \usepackage{lstlangclean}
156 \usepackage{lstlanghaskell}
157 \usepackage{lstlanghaskelllhstex}
158 \usepackage{lstlangarduino}
159 \newcommand{\cinline}[1]{\lstinline[language=c,postbreak=]|#1|}
160 \newcommand{\arduinoinline}[1]{\lstinline[language={[Arduino]C++},postbreak=]|#1|}
161 \newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
162 \newcommand{\haskellinline}[1]{\lstinline[language=Haskell,style=haskell,postbreak=]|#1|}
163 \newcommand{\haskelllhstexinline}[1]{\lstinline[language=Haskell,style=haskelllhstex,postbreak=]|#1|}
164 %For storing listings in footnotes
165 \newsavebox{\LstBox}
166 % Fix list of listings title
167 \renewcommand{\lstlistlistingname}{List of Listings}
168 % Fix list of listings chapter separator
169 \makeatletter
170 \let\my@chapter\@chapter%
171 \renewcommand*{\@chapter}{%
172 \addtocontents{lol}{\protect\addvspace{10pt}}%
173 \my@chapter}
174 \makeatother
175
176 \lstnewenvironment{lstClean}[1][]
177 {%
178 \lstset{language=Clean, #1}
179 \renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}
180 }
181 {}
182 \lstnewenvironment{lstArduino}[1][]
183 {%
184 \lstset{language={[Arduino]C++}, #1}
185 \renewcommand*{\lstlistingname}{Listing (\gls{ARDUINO})}
186 }
187 {}
188 \lstnewenvironment{lstHaskell}[1][]
189 {%
190 \lstset{language=Haskell,style=haskell,#1}%
191 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
192 }
193 {}
194 \lstnewenvironment{lstHaskellLhstex}[1][]
195 {%
196 \lstset{language=Haskell,style=haskelllhstex,#1}%
197 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
198 }
199 {}
200
201 % Hyperlinks and metadata
202 \usepackage[pagebackref]{hyperref} % hyperlinks
203 \renewcommand*{\backref}[1]{}
204 \renewcommand*{\backrefalt}[4]{[{%
205 \ifcase #1 not cited.\or p.~#2.\else pp. #2.\fi%chktex 1
206 }]}
207 \hypersetup{%
208 pdftitle={\mytitle},
209 pdfauthor={\myauthor},
210 pdfkeywords={task-oriented programming, functional programming, domain specific languages, internet of things},
211 hidelinks,
212 }
213 \usepackage[nodayofweek]{datetime} % Use a fixed document date
214 \urlstyle{same}
215 \usepackage{bookmark}
216 \usepackage{cleveref} % Easy references
217 \crefname{part}{movement}{movements}
218 \crefname{lstlisting}{listing}{listing}
219
220 % Glossaries and acronyms
221 \usepackage[acronym,nonumberlist]{glossaries}
222 \Addlcwords{of}
223 % Titlecase glossary commands
224 \newcommand{\glst}[1]{\titlecap{\glsentrylong{#1}}}
225 \newcommand{\Glst}[1]{\glst{#1}}
226 % Fix gls in hyperlink errors
227 \pdfstringdefDisableCommands{%
228 \def\acrlong#1{}%
229 \def\acrlongpl#1{}%
230 \def\acrshort#1{}%
231 \def\acrshortpl#1{}%
232 \def\acrfull#1{}%
233 \def\acrfullpl#1{}%
234 \def\Acrlong#1{}%
235 \def\Acrlongpl#1{}%
236 \def\Acrshort#1{}%
237 \def\Acrshortpl#1{}%
238 \def\Acrfull#1{}%
239 \def\Acrfullpl#1{}%
240 \def\gls#1{}%
241 \def\glspl#1{}%
242 \def\glsentrytext#1{}%
243 \def\Gls#1{}%
244 \def\Glspl#1{}%
245 \def\Glsentrytext#1{}%
246 \def\titlecap#1{}%
247 }
248
249 % Index
250 %\usepackage{makeidx}
251 %\makeindex% Enable the index
252
253 % Custom enumerations
254 \usepackage[inline,shortlabels]{enumitem}
255 \setlist{noitemsep}
256 \setlist[description]{leftmargin=\parindent}
257
258 % Initialize the glossaries
259 \makeglossaries%
260 \input{glossaries}
261
262 \usepackage{subfiles}
263
264 \ifSubfilesClassLoaded{}{
265 \usepackage{xmpincl}
266 \includexmp{CC_Attribution-NoDerivatives_4.0_International}
267 }
268
269 % Custom commands
270 \newcommand{\GHCmod}[1]{\texttt{#1}}
271 \newcommand{\requiresGHCmod}[1]{\footnote{Requires \GHCmod{#1} to be enabled.}}
272 \newcommand{\etc}{{\fontfamily{cmr}\selectfont{\itshape\/\&c}}}
273 \newcommand{\rdmentry}[6]{#1: #2 (#3): #4. #5.\ \href{https://doi.org/#6}{#6}}
274 \newcommand{\mlubbers}{Lubbers, M.\ (Radboud University)}
275 \newcommand{\pkoopman}{Koopman, dr.\ P.\ (Radboud University)}
276 \newcommand{\rplasmeijer}{Plasmeijer, prof.\ dr.\ ir.\ R.\ (Radboud University)}
277
278 \newcommand{\mychapter}[2]{
279 \chapter{#2}%
280 \label{#1}%
281 }
282 \newcommand{\myappendix}[2]{
283 \chapter{#2}%
284 \label{#1}%
285 }
286 \newcommand{\mybackmatter}[2]{
287 \chapter{#2}%
288 \label{#1}%
289 }
290 \newcommand{\mypart}[3]{\part[#2: #3]{#2\\[2ex]\smaller{}#3}\label{#1}}