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