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