many smalle updates
[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 \newenvironment{chapterabstract}{\begin{quotation}\em}{\end{quotation}} %chktex 6
120
121 % Increase the depth for the table of contents
122 \setcounter{secnumdepth}{3}
123 \renewcommand{\contentsname}{Table of Contents} % change the name of the TOC
124 \AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} % to remove page numbering from the TOC
125
126 % (file) structure
127 \usepackage[subpreambles=true]{standalone} % standalone figures
128 %\usepackage{morewrites} % fix no more room for a new \write
129 \usepackage{appendix} % subappendices, appendices per chapter
130
131 % Bibliography
132 \usepackage{natbib} % Cite bib entry completely
133 \setlength{\bibsep}{0.0pt}
134 \def\bibfont{\small}
135 %\bibliographystyle{alpha}
136 \bibliographystyle{abbrvnat}
137 \apptocmd{\thebibliography}{\raggedright}{}{}
138 \usepackage{bibentry} % Cite bib entry completely
139 \nobibliography*
140 \newcommand{\citeentry}[1]{\begin{NoHyper}\bibentry{#1}\end{NoHyper}. \citep{#1}}
141
142 \makeatletter
143 \newcommand{\citepage}[1]{p.~#1}
144 \newcommand{\citepages}[1]{pp.~#1}
145 \newcommand{\citechapter}[1]{\cref@chapter@name~#1}
146 \newcommand{\citechapters}[1]{\cref@chapter@name@plural~#1}
147 \newcommand{\citesection}[1]{\cref@section@name~#1}
148 \newcommand{\citesections}[1]{\cref@section@name@plural~#1}
149 %\newcommand{\citesection}[1]{\S.~#1}
150 %\newcommand{\citesections}[1]{\S\S.~#1}
151 \newcommand{\citeparagraph}[1]{\P.~#1}
152 \newcommand{\citeparagraphs}[1]{\P\P.~#1}
153 \makeatother
154
155 % Graphics
156 \usepackage{graphicx} % Images
157 \graphicspath{{img/},{intro/img},{top/img},{tvt/img}}
158 \usepackage{caption} % subfigures/captionof
159 \usepackage{subcaption}
160 \usepackage{rotating}
161 \newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}
162 \usepackage{tikz}
163
164 % Tables
165 \usepackage{booktabs} % Nicer tables
166 \usepackage{multirow} % Multirow cells
167 \usepackage{tabularx} % Automatically wrapping tables
168 \usepackage{longtable} % Tables spanning pages
169 \usepackage{threeparttable} % Tables with footnotes
170
171 % Code
172 % Pseudocode
173 \usepackage[algochapter,linesnumbered,lined,boxed]{algorithm2e}
174 % Fix the algorithm font
175 \renewcommand\AlCapFnt{\normalfont}
176 \usepackage{listings}
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=L,
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[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 % Hyperlinks and metadata
266 \usepackage[hyphens]{url}
267 \usepackage[pdflang={en-GB},pagebackref,breaklinks]{hyperref} % hyperlinks
268 \usepackage{xr} % hyperlinks
269 \renewcommand*{\backref}[1]{}
270 \renewcommand*{\backrefalt}[4]{[{%
271 \ifcase #1 not cited.\or p.~#2.\else pp. #2.\fi%chktex 1
272 }]}
273 \hypersetup{%
274 pdftitle={\mytitle},
275 pdfauthor={\myauthor},
276 pdfkeywords={task-oriented programming, functional programming, domain specific languages, internet of things},
277 hidelinks,
278 }
279 \usepackage[nodayofweek]{datetime} % Use a fixed document date
280 \urlstyle{same}
281 \usepackage{bookmark}
282 \usepackage[noabbrev]{cleveref} % Easy references
283 \usepackage{crossreftools} % Easy references
284 \crefname{equ}{equation}{equations}
285 \crefname{part}{episode}{episodes}
286 \crefname{lstlisting}{listing}{listings}
287 \crefname{equ}{definition}{definition}
288 \usepackage{nameref} % to reference names of chapters
289 \newcommand{\fullref}[1]{\crtcref{#1}: \nameref{#1}}
290 \newcommand{\Fullref}[1]{\crtCref{#1}: \nameref{#1}}
291 \creflabelformat{equation}{#2\textup{#1}#3}
292
293 % Glossaries and acronyms
294 \usepackage[nolangwarn,abbreviations,nonumberlist,prefix]{glossaries-extra}
295 \setabbreviationstyle{long-short}
296 \setabbreviationstyle[noexpand]{short-nolong}
297 \Addlcwords{of}
298 \usepackage{glossary-mcols}
299 \pdfstringdefDisableCommands{%
300 \def\glsxtrlong#1{}%
301 \def\glsxtrlongpl#1{}%
302 \def\glsxtrshort#1{}%
303 \def\glsxtrshortpl#1{}%
304 \def\acrfull#1{}%
305 \def\acrfullpl#1{}%
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\gls#1{}%
313 \def\glspl#1{}%
314 \def\glsentrytext#1{}%
315 \def\Gls#1{}%
316 \def\Glspl#1{}%
317 \def\Glsentrytext#1{}%
318 \def\titlecap#1{}%
319 \def\MakeUppercase#1{}%
320 }
321
322 % Index
323 %\usepackage{makeidx}
324 %\makeindex% Enable the index
325
326 % Custom enumerations
327 \usepackage[inline,shortlabels]{enumitem}
328 \setlist{noitemsep}
329 \setlist[description]{leftmargin=\parindent}
330
331 % Initialize the glossaries
332 \makeglossaries%
333 \input{glossaries}
334
335 \usepackage{subfiles}
336
337 \ifSubfilesClassLoaded{}{
338 \usepackage{xmpincl}
339 \includexmp{CC_Attribution-NoDerivatives_4.0_International}
340 }
341
342 % Custom commands
343 \newcommand{\GHCmod}[1]{\texttt{#1}}
344 \newcommand{\aramsingh}{Ramsingh, A.\ (University of Glasgow)}
345 \newcommand{\dcolon}[0]{\mathbin{::}}
346 \newcommand{\doifmt}[1]{\href{https://doi.org/#1}{#1}}
347 \newcommand{\etc}{{\fontfamily{cmr}\selectfont{\itshape\/\&\kern-0.2em c}}}
348 \newcommand{\jsinger}{Singer, dr.\ J.\ (University of Glasgow)}
349 \newcommand{\mlubbers}{Lubbers, M.\ (Radboud University)}
350 \newcommand{\pkoopman}{Koopman, dr.\ P.\ (Radboud University)}
351 \newcommand{\ptrinder}{Trinder, prof.~dr.\ P.\ (University of Glasgow)}
352 \newcommand{\rdmentry}[5]{#1 (#2): #3. #4.\ \doifmt{#5}}
353 \newcommand{\rewriterate}[2]{\langle{}#1, #2\rangle{}}
354 \newcommand{\requiresGHCmod}[2][]{\footnote{Requires \GHCmod{#2} to be enabled. #1}}
355 \newcommand{\rplasmeijer}{Plasmeijer, prof.\ dr.\ ir.\ R.\ (Radboud University)}
356 \newcommand{\erasmusplus}{ERASMUS\raisebox{.25ex}{+}}
357 \newcommand{\imtask}{\gls{ITASK}\slash\gls{MTASK}}
358 \newcommand{\Imtask}{\Gls{ITASK}\slash\gls{MTASK}}
359 \newcommand{\citask}{\gls{CLEAN}\slash\gls{ITASK}}
360 \newcommand{\Citask}{\Gls{CLEAN}\slash\gls{ITASK}}
361 \newcommand{\cimtask}{\gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
362 \newcommand{\Cimtask}{\Gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
363 \newcommand{\ccpp}{\gls{C}\slash\gls{CPP}}
364 \newcommand{\Ccpp}{\Gls{C}\slash\gls{CPP}}
365 \newcommand{\stacksize}[1]{\parallel#1\parallel}
366
367 \makeatletter
368 \newenvironment{compilationscheme}
369 {\allowdisplaybreaks\startalign}
370 {\endalign}
371 \makeatother