6 and finale
[phd-thesis.git] / preamble.tex
1 % chktex-file 17
2 % chktex-file 15
3 % Fonts
4 \usepackage[utf8]{inputenc} % Input encoding
5 \usepackage[T2A,T1]{fontenc} % Font encoding
6 \usepackage{lmodern} % Nicer font
7 \usepackage{microtype} % Better kerning
8 \usepackage{tipa} % IPA symbols
9 \usepackage{stmaryrd} % short arrows
10 \usepackage{textcomp} % upquote
11 \usepackage{titlecaps} % titlecase commands
12 \usepackage{amsmath} % extra math
13 \usepackage{amssymb} % extra math symbols
14 \usepackage{wasysym} % circle symbols
15 \usepackage{relsize} % \smaller command
16 \usepackage{siunitx} % typeset units
17 \usepackage{xcolor} % colors
18 \usepackage{fnpct} % footnotekerning
19 \usepackage[all]{nowidow} % Kill widows and orphans
20 \DeclareSIUnit\noop{\relax}
21 \DeclareSIUnit\celcius{{}^{\circ}\kern-\scriptspace\mathsf{C}}
22 \everymath{\it\/}
23 \DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39} %chktex 18
24
25 % Internationalisation
26 \usepackage[dutch,russian,british]{babel}
27 \input{hyphenation}
28 %\babelfont[russian]{rm}{Liberation Serif}
29
30 % Papersize and layout
31 \usepackage{geometry}
32 \geometry{
33 inner=25mm,
34 outer=20mm,
35 marginparsep=3mm,
36 marginparwidth=13mm,
37 top=25mm,
38 bottom=20mm,
39 paperwidth=17cm,
40 paperheight=24cm,
41 }
42 \usepackage{pdflscape}
43 \usepackage{float}
44 \usepackage{newfloat}
45 \DeclareFloatingEnvironment[
46 fileext=loq,
47 listname={List of definitions},
48 name=Definition,
49 placement=tbp,
50 within=chapter,
51 chapterlistsgaps=on,
52 ]{equ}
53 \usepackage{fancyhdr} % Custom headers and footers
54 \usepackage[fit]{truncate}
55 %\pagestyle{headings}
56 \pagestyle{fancy}
57 \fancyhead{}
58 \fancyfoot{}
59 \setlength{\unitlength}{18mm}
60 \newcommand{\blob}{{\color{gray}\rule[-.2\unitlength]{2\unitlength}{.5\unitlength}}}
61 \fancyhead[RE]{\truncate{.95\headwidth}{\rightmark}}
62 \fancyhead[LO]{\truncate{.95\headwidth}{\leftmark}}
63 \newcommand{\frontmatterfancy}[0]{
64 \fancyhead[RO]{\thepage}
65 \fancyhead[LE]{\thepage}
66 }
67 \newcommand{\mainmatterfancy}[0]{
68 \fancyhead[RO]{
69 \thepage%
70 \begin{picture}(0,0)
71 \put(1,-\value{chapter}){\blob}
72 \end{picture}
73 }
74 \fancyhead[LE]{
75 \begin{picture}(0,0)
76 \put(-3,-\value{chapter}){\blob}
77 \end{picture}%
78 \thepage%
79 }
80 }
81 \newcommand{\backmatterfancy}[0]{
82 \fancyhead[RO]{
83 \thepage%
84 \begin{picture}(0,0)
85 \put(1,-1){\blob}
86 \end{picture}
87 }
88 \fancyhead[LE]{
89 \begin{picture}(0,0)
90 \put(-3,-1){\blob}
91 \end{picture}%
92 \thepage%
93 }
94 }
95 \renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
96 \renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
97 %\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername}\ \thechapter.\ #1}{}}
98 %\renewcommand{\headrulewidth}{0pt}
99 \renewcommand{\footrulewidth}{0pt}
100 \usepackage{etoolbox} % To patch the chapter command
101 % Have better page numbering in chapters
102 \patchcmd{\chapter}{plain}{headings}{}{}
103 \usepackage{epigraph} % Epigraph
104 \renewcommand\partname{Episode} % Rename parts to episodes (rhapsody uhu)
105 \addto\captionsbritish{\renewcommand{\partname}{Episode}}
106 \usepackage{titlesec}
107 \titleformat{\part}[block]
108 {\Huge}
109 {\partname~\thepart:}
110 {20pt}
111 {}
112 % This is required to make \nameref work (https://tex.stackexchange.com/questions/211035/problems-with-nameref-not-refering-to-the-correct-label-x-titlesec)
113 \makeatletter
114 \let\titlesec@part\part%
115 \renewcommand{\part}{\@ifstar\part@star\part@nostar}
116 \def\part@star#1{\NR@gettitle{#1}\titlesec@part*{#1}}
117 \def\part@nostar{\@ifnextchar[\part@nostar@opt\part@nostar@nopt} % chktex 9
118 \def\part@nostar@nopt#1{\NR@gettitle{#1}\titlesec@part{#1}}
119 \def\part@nostar@opt[#1]#2{\NR@gettitle{#1}\titlesec@part[#1]{#2}}
120 \makeatother
121
122 \usepackage{framed}
123 \definecolor{lstbg}{gray}{.95}
124 \definecolor{shadecolor}{named}{lstbg}
125 \newenvironment{chapterabstract}{\begin{shaded}\begin{quotation}}{\end{quotation}\end{shaded}} %chktex 6
126
127 % Increase the depth for the table of contents
128 \setcounter{secnumdepth}{3}
129 \renewcommand{\contentsname}{Table of Contents} % change the name of the TOC
130 \AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} % to remove page numbering from the TOC
131
132 % (file) structure
133 \usepackage[subpreambles=true]{standalone} % standalone figures
134 %\usepackage{morewrites} % fix no more room for a new \write
135 \usepackage{appendix} % subappendices, appendices per chapter
136
137 % Bibliography
138 \usepackage[square]{natbib} % Cite bib entry completely
139 \setlength{\bibsep}{0.0pt}
140 %\def\bibfont{\small}
141 %\bibliographystyle{alpha}
142 \bibliographystyle{abbrvnat}
143 %\apptocmd{\thebibliography}{\raggedright}{}{}
144 \usepackage{bibentry} % Cite bib entry completely
145 \nobibliography*
146 \newcommand{\citeentry}[1]{\begin{NoHyper}\bibentry{#1}\end{NoHyper}. \citep{#1}}
147 \newcommand{\refurl}[2]{\url{#1}, accessed on: #2}
148
149 \makeatletter
150 \newcommand{\citepage}[1]{p.~#1}
151 \newcommand{\citepages}[1]{pp.~#1}
152 \newcommand{\citechapter}[1]{\cref@chapter@name~#1}
153 \newcommand{\citechapters}[1]{\cref@chapter@name@plural~#1}
154 \newcommand{\citesection}[1]{\cref@section@name~#1}
155 \newcommand{\citesections}[1]{\cref@section@name@plural~#1}
156 %\newcommand{\citesection}[1]{\S.~#1}
157 %\newcommand{\citesections}[1]{\S\S.~#1}
158 \newcommand{\citeparagraph}[1]{\P.~#1}
159 \newcommand{\citeparagraphs}[1]{\P\P.~#1}
160 \newcommand{\citelisting}[1]{\cref@listing@name~#1}
161 \makeatother
162
163 % Tables
164 \usepackage{booktabs} % Nicer tables
165 \usepackage{multirow} % Multirow cells
166 \usepackage{tabularx} % Automatically wrapping tables
167 \usepackage{longtable} % Tables spanning pages
168 \usepackage{threeparttable} % Tables with footnotes
169
170 % Code
171 % Pseudocode
172 \usepackage[algochapter,linesnumbered,lined,boxed]{algorithm2e}
173 % Fix the algorithm font
174 \renewcommand\AlCapFnt{\normalfont}
175 \usepackage{listings}
176 \newcounter{tmp}
177 % https://tex.stackexchange.com/questions/149056/how-can-i-define-additional-literate-replacements-without-deleting-existing-ones
178 \makeatletter
179 \def\addToLiterate#1{\edef\lst@literate{\unexpanded\expandafter{\lst@literate}\unexpanded{#1}}}
180 \lst@Key{moreliterate}{}{\addToLiterate{#1}}
181 \makeatother
182 % General listings settings
183 \lstset{%
184 basewidth=0.5em,
185 basicstyle=\tt\small,
186 breakatwhitespace=false,
187 breaklines=true,
188 captionpos=b,
189 columns=[c]fixed,
190 commentstyle=\sl,
191 escapeinside={[+}{+]}, % chktex 9
192 frame=,
193 backgroundcolor=\color{lstbg},
194 keepspaces=true,
195 keywordstyle=\bf,
196 postbreak=\mbox{\textcolor{gray}{$\hookrightarrow$}\space},
197 showspaces=false,
198 showstringspaces=false,
199 showtabs=false,
200 stringstyle=\it,
201 tabsize=4,
202 upquote=true,
203 numberstyle=\tiny,
204 }
205 \usepackage{lstlangclean}
206 \usepackage{lstlanghaskell}
207 \usepackage{lstlangarduino}
208 \lstloadlanguages{%
209 {[Arduino]C++},%
210 {c},%
211 {Python},%
212 {Clean},%
213 {[Regular]Haskell},
214 {[Lhs2Tex]Haskell}}
215 \newcommand{\cinline}[1]{\lstinline[language=c,postbreak=]|#1|}
216 \newcommand{\arduinoinline}[1]{\lstinline[language={[Arduino]C++},postbreak=]|#1|}
217 \newcommand{\pythoninline}[1]{\lstinline[language=Python,postbreak=]|#1|}
218 \newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
219 \newcommand{\cleaninputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}\lstinputlisting[escapeinside={/*}{*/},language=Clean,#1]{\subfix{#2}}}
220 \newcommand{\haskellinline}[1]{\lstinline[language={[Regular]Haskell},postbreak=]|#1|}
221 \newcommand{\haskellinputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}\lstinputlisting[language={[Regular]Haskell},#1]{\subfix{#2}}}
222 \newcommand{\haskelllhstexinline}[1]{\lstinline[language={[Lhs2Tex]Haskell},postbreak=]|#1|}
223 %For storing listings in footnotes
224 \newsavebox{\LstBox}
225 % Fix list of listings title
226 \renewcommand{\lstlistlistingname}{List of Listings}
227 % Fix list of listings chapter separator
228 \makeatletter
229 \let\my@chapter\@chapter%
230 \renewcommand*{\@chapter}{%
231 \addtocontents{lol}{\protect\addvspace{10pt}}%
232 \my@chapter}
233 \makeatother
234
235 \lstnewenvironment{lstPython}[1][]
236 {%
237 \lstset{language=Python, #1}
238 \renewcommand*{\lstlistingname}{Listing (\gls{PYTHON})}
239 }
240 {}
241 \lstnewenvironment{lstClean}[1][]
242 {%
243 \lstset{language=Clean, #1}
244 \renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}
245 }
246 {}
247 \lstnewenvironment{lstArduino}[1][]
248 {%
249 \lstset{language={[Arduino]C++}, #1}
250 \renewcommand*{\lstlistingname}{Listing (\gls{CPP})}
251 }
252 {}
253 \lstnewenvironment{lstHaskell}[1][]
254 {%
255 \lstset{language={[Regular]Haskell},#1}%
256 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
257 }
258 {}
259 \lstnewenvironment{lstHaskellLhstex}[1][]
260 {%
261 \lstset{language={[Lhs2Tex]Haskell},#1}%
262 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
263 }
264 {}
265
266 % Graphics
267 \usepackage{graphicx} % Images
268 \graphicspath{{img/},{intro/img},{top/img},{tvt/img}}
269 \usepackage{dpfloat}
270 \usepackage{caption} % subfigures/captionof
271 \usepackage{subcaption}
272 \usepackage{rotating}
273 \usepackage{adjustbox} % Make table fit page
274 \newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}
275 \usepackage{tikz}
276
277 % Index
278 %\usepackage{makeidx}
279 %\makeindex% Enable the index
280
281 % Custom enumerations
282 \usepackage[inline,shortlabels]{enumitem}
283 \setlist{noitemsep}
284 \setlist[description]{leftmargin=\parindent}
285
286 % Hyperlinks and metadata
287 \usepackage[hyphens]{url}
288 \usepackage[pdflang={en-GB},pagebackref,breaklinks]{hyperref} % hyperlinks
289 \usepackage{xr} % hyperlinks
290 \renewcommand*{\backref}[1]{}
291 \renewcommand*{\backrefalt}[4]{[{%
292 \ifcase #1 not cited.\or p.~#2.\else pp. #2.\fi%chktex 1
293 }]}
294 \hypersetup{%
295 pdftitle={\mytitle},
296 pdfauthor={\myauthor},
297 pdfkeywords={task-oriented programming, functional programming, domain specific languages, internet of things},
298 hidelinks,
299 }
300 \usepackage[nodayofweek]{datetime} % Use a fixed document date
301 \urlstyle{same}
302 \usepackage{bookmark}
303 \usepackage[noabbrev]{cleveref} % Easy references
304 \usepackage{crossreftools} % Easy references
305 \crefname{equ}{equation}{equations}
306 \crefname{part}{episode}{episodes}
307 \crefname{lstlisting}{listing}{listings}
308 \crefname{equ}{definition}{definition}
309 \usepackage{nameref} % to reference names of chapters
310 \newcommand{\fullref}[1]{\crtcref{#1}: \nameref{#1}}
311 \newcommand{\Fullref}[1]{\crtCref{#1}: \nameref{#1}}
312 \creflabelformat{equation}{#2\textup{#1}#3}
313
314 % Glossaries and acronyms
315 \usepackage[nolangwarn,abbreviations,nonumberlist,prefix]{glossaries-extra}
316 \setabbreviationstyle{long-short}
317 \setabbreviationstyle[noexpand]{short-nolong}
318 \Addlcwords{of}
319 \usepackage{glossary-mcols}
320 \pdfstringdefDisableCommands{%
321 \def\glsxtrlong#1{}%
322 \def\glsxtrlongpl#1{}%
323 \def\glsxtrshort#1{}%
324 \def\glsxtrshortpl#1{}%
325 \def\acrfull#1{}%
326 \def\acrfullpl#1{}%
327 \def\Glsxtrlong#1{}%
328 \def\Glsxtrlongpl#1{}%
329 \def\Glsxtrshort#1{}%
330 \def\Glsxtrshortpl#1{}%
331 \def\Acrfull#1{}%
332 \def\Acrfullpl#1{}%
333 \def\gls#1{}%
334 \def\glspl#1{}%
335 \def\glsentrytext#1{}%
336 \def\Gls#1{}%
337 \def\Glspl#1{}%
338 \def\Glsentrytext#1{}%
339 \def\titlecap#1{}%
340 \def\MakeUppercase#1{}%
341 }
342
343 % Initialize the glossaries
344 \makeglossaries%
345 \input{glossaries}
346
347 \usepackage{subfiles}
348
349 \ifSubfilesClassLoaded{}{
350 \usepackage{xmpincl}
351 \includexmp{CC_Attribution-NoDerivatives_4.0_International}
352 }
353
354 % Custom commands
355 \newcommand{\GHCmod}[1]{\texttt{#1}}
356 \newcommand{\aramsingh}{Ramsingh, A.\ (University of Glasgow)}
357 \newcommand{\dcolon}[0]{\mathbin{::}}
358 \newcommand{\doifmt}[1]{\href{https://doi.org/#1}{#1}}
359 \newcommand{\etc}{{\fontfamily{cmr}\selectfont{\itshape\/\&\kern-0.2em c}}}
360 \newcommand{\jsinger}{Singer, dr.\ J.\ (University of Glasgow)}
361 \newcommand{\mlubbers}{Lubbers, M.\ (Radboud University)}
362 \newcommand{\pkoopman}{Koopman, dr.\ P.\ (Radboud University)}
363 \newcommand{\ptrinder}{Trinder, prof.~dr.\ P.\ (University of Glasgow)}
364 \newcommand{\rdmentry}[5]{#1 (#2): #3. #4.\ \doifmt{#5}}
365 \newcommand{\rewriterate}[2]{\langle{}\mathit{#1}, \mathit{#2}\rangle{}}
366 \newcommand{\requiresGHCmod}[2][]{\footnote{Requires \GHCmod{#2} to be enabled. #1}}
367 \newcommand{\rplasmeijer}{Plasmeijer, prof.\ dr.\ ir.\ R.\ (Radboud University)}
368 \newcommand{\erasmusplus}{ERASMUS\raisebox{.25ex}{+}}
369 \newcommand{\imtask}{\gls{ITASK}\slash\gls{MTASK}}
370 \newcommand{\citask}{\gls{CLEAN}\slash\gls{ITASK}}
371 \newcommand{\Citask}{\Gls{CLEAN}\slash\gls{ITASK}}
372 \newcommand{\cmtask}{\gls{CLEAN}\slash\gls{MTASK}}
373 \newcommand{\Cmtask}{\Gls{CLEAN}\slash\gls{MTASK}}
374 \newcommand{\cimtask}{\gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
375 \newcommand{\Cimtask}{\Gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
376 \newcommand{\ccpp}{\texorpdfstring{\gls{C}\slash\gls{CPP}}{C\slash{}C\texttt{++}}}
377 \newcommand{\Ccpp}{\texorpdfstring{\Gls{C}\slash\gls{CPP}}{C\slash{}C\texttt{++}}}
378 \newcommand{\stacksize}[1]{\parallel#1\parallel}
379
380 \makeatletter
381 \newenvironment{compilationscheme}
382 {\allowdisplaybreaks\startalign}
383 {\endalign}
384 \makeatother