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