small 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 \definecolor{lstbg}{gray}{.95}
184 \lstset{%
185 basewidth=0.5em,
186 basicstyle=\tt\small,
187 breakatwhitespace=false,
188 breaklines=true,
189 captionpos=b,
190 columns=[c]fixed,
191 commentstyle=\sl,
192 escapeinside={[+}{+]}, % chktex 9
193 frame=,
194 backgroundcolor=\color{lstbg},
195 keepspaces=true,
196 keywordstyle=\bf,
197 postbreak=\mbox{\textcolor{gray}{$\hookrightarrow$}\space},
198 showspaces=false,
199 showstringspaces=false,
200 showtabs=false,
201 stringstyle=\it,
202 tabsize=4,
203 upquote=true,
204 numberstyle=\tiny,
205 }
206 \usepackage{lstlangclean}
207 \usepackage{lstlanghaskell}
208 \usepackage{lstlangarduino}
209 \lstloadlanguages{%
210 {[Arduino]C++},%
211 {c},%
212 {Python},%
213 {Clean},%
214 {[Regular]Haskell},
215 {[Lhs2Tex]Haskell}}
216 \newcommand{\cinline}[1]{\lstinline[language=c,postbreak=]|#1|}
217 \newcommand{\arduinoinline}[1]{\lstinline[language={[Arduino]C++},postbreak=]|#1|}
218 \newcommand{\pythoninline}[1]{\lstinline[language=Python,postbreak=]|#1|}
219 \newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
220 \newcommand{\cleaninputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}\lstinputlisting[escapeinside={/*}{*/},language=Clean,#1]{\subfix{#2}}}
221 \newcommand{\haskellinline}[1]{\lstinline[language={[Regular]Haskell},postbreak=]|#1|}
222 \newcommand{\haskellinputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}\lstinputlisting[language={[Regular]Haskell},#1]{\subfix{#2}}}
223 \newcommand{\haskelllhstexinline}[1]{\lstinline[language={[Lhs2Tex]Haskell},postbreak=]|#1|}
224 %For storing listings in footnotes
225 \newsavebox{\LstBox}
226 % Fix list of listings title
227 \renewcommand{\lstlistlistingname}{List of Listings}
228 % Fix list of listings chapter separator
229 \makeatletter
230 \let\my@chapter\@chapter%
231 \renewcommand*{\@chapter}{%
232 \addtocontents{lol}{\protect\addvspace{10pt}}%
233 \my@chapter}
234 \makeatother
235
236 \lstnewenvironment{lstPython}[1][]
237 {%
238 \lstset{language=Python, #1}
239 \renewcommand*{\lstlistingname}{Listing (\gls{PYTHON})}
240 }
241 {}
242 \lstnewenvironment{lstClean}[1][]
243 {%
244 \lstset{language=Clean, #1}
245 \renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}
246 }
247 {}
248 \lstnewenvironment{lstArduino}[1][]
249 {%
250 \lstset{language={[Arduino]C++}, #1}
251 \renewcommand*{\lstlistingname}{Listing (\gls{CPP})}
252 }
253 {}
254 \lstnewenvironment{lstHaskell}[1][]
255 {%
256 \lstset{language={[Regular]Haskell},#1}%
257 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
258 }
259 {}
260 \lstnewenvironment{lstHaskellLhstex}[1][]
261 {%
262 \lstset{language={[Lhs2Tex]Haskell},#1}%
263 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
264 }
265 {}
266
267 % Hyperlinks and metadata
268 \usepackage[hyphens]{url}
269 \usepackage[pdflang={en-GB},pagebackref,breaklinks]{hyperref} % hyperlinks
270 \usepackage{xr} % hyperlinks
271 \renewcommand*{\backref}[1]{}
272 \renewcommand*{\backrefalt}[4]{[{%
273 \ifcase #1 not cited.\or p.~#2.\else pp. #2.\fi%chktex 1
274 }]}
275 \hypersetup{%
276 pdftitle={\mytitle},
277 pdfauthor={\myauthor},
278 pdfkeywords={task-oriented programming, functional programming, domain specific languages, internet of things},
279 hidelinks,
280 }
281 \usepackage[nodayofweek]{datetime} % Use a fixed document date
282 \urlstyle{same}
283 \usepackage{bookmark}
284 \usepackage[noabbrev]{cleveref} % Easy references
285 \usepackage{crossreftools} % Easy references
286 \crefname{equ}{equation}{equations}
287 \crefname{part}{episode}{episodes}
288 \crefname{lstlisting}{listing}{listings}
289 \crefname{equ}{definition}{definition}
290 \usepackage{nameref} % to reference names of chapters
291 \newcommand{\fullref}[1]{\crtcref{#1}: \nameref{#1}}
292 \newcommand{\Fullref}[1]{\crtCref{#1}: \nameref{#1}}
293 \creflabelformat{equation}{#2\textup{#1}#3}
294
295 % Glossaries and acronyms
296 \usepackage[nolangwarn,abbreviations,nonumberlist,prefix]{glossaries-extra}
297 \setabbreviationstyle{long-short}
298 \setabbreviationstyle[noexpand]{short-nolong}
299 \Addlcwords{of}
300 \usepackage{glossary-mcols}
301 \pdfstringdefDisableCommands{%
302 \def\glsxtrlong#1{}%
303 \def\glsxtrlongpl#1{}%
304 \def\glsxtrshort#1{}%
305 \def\glsxtrshortpl#1{}%
306 \def\acrfull#1{}%
307 \def\acrfullpl#1{}%
308 \def\Glsxtrlong#1{}%
309 \def\Glsxtrlongpl#1{}%
310 \def\Glsxtrshort#1{}%
311 \def\Glsxtrshortpl#1{}%
312 \def\Acrfull#1{}%
313 \def\Acrfullpl#1{}%
314 \def\gls#1{}%
315 \def\glspl#1{}%
316 \def\glsentrytext#1{}%
317 \def\Gls#1{}%
318 \def\Glspl#1{}%
319 \def\Glsentrytext#1{}%
320 \def\titlecap#1{}%
321 \def\MakeUppercase#1{}%
322 }
323
324 % Index
325 %\usepackage{makeidx}
326 %\makeindex% Enable the index
327
328 % Custom enumerations
329 \usepackage[inline,shortlabels]{enumitem}
330 \setlist{noitemsep}
331 \setlist[description]{leftmargin=\parindent}
332
333 % Initialize the glossaries
334 \makeglossaries%
335 \input{glossaries}
336
337 \usepackage{subfiles}
338
339 \ifSubfilesClassLoaded{}{
340 \usepackage{xmpincl}
341 \includexmp{CC_Attribution-NoDerivatives_4.0_International}
342 }
343
344 % Custom commands
345 \newcommand{\GHCmod}[1]{\texttt{#1}}
346 \newcommand{\aramsingh}{Ramsingh, A.\ (University of Glasgow)}
347 \newcommand{\dcolon}[0]{\mathbin{::}}
348 \newcommand{\doifmt}[1]{\href{https://doi.org/#1}{#1}}
349 \newcommand{\etc}{{\fontfamily{cmr}\selectfont{\itshape\/\&\kern-0.2em c}}}
350 \newcommand{\jsinger}{Singer, dr.\ J.\ (University of Glasgow)}
351 \newcommand{\mlubbers}{Lubbers, M.\ (Radboud University)}
352 \newcommand{\pkoopman}{Koopman, dr.\ P.\ (Radboud University)}
353 \newcommand{\ptrinder}{Trinder, prof.~dr.\ P.\ (University of Glasgow)}
354 \newcommand{\rdmentry}[5]{#1 (#2): #3. #4.\ \doifmt{#5}}
355 \newcommand{\rewriterate}[2]{\langle{}#1, #2\rangle{}}
356 \newcommand{\requiresGHCmod}[2][]{\footnote{Requires \GHCmod{#2} to be enabled. #1}}
357 \newcommand{\rplasmeijer}{Plasmeijer, prof.\ dr.\ ir.\ R.\ (Radboud University)}
358 \newcommand{\erasmusplus}{ERASMUS\raisebox{.25ex}{+}}
359 \newcommand{\imtask}{\gls{ITASK}\slash\gls{MTASK}}
360 \newcommand{\Imtask}{\Gls{ITASK}\slash\gls{MTASK}}
361 \newcommand{\citask}{\gls{CLEAN}\slash\gls{ITASK}}
362 \newcommand{\Citask}{\Gls{CLEAN}\slash\gls{ITASK}}
363 \newcommand{\cimtask}{\gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
364 \newcommand{\Cimtask}{\Gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
365 \newcommand{\ccpp}{\gls{C}\slash\gls{CPP}}
366 \newcommand{\Ccpp}{\Gls{C}\slash\gls{CPP}}
367 \newcommand{\stacksize}[1]{\parallel#1\parallel}
368
369 \makeatletter
370 \newenvironment{compilationscheme}
371 {\allowdisplaybreaks\startalign}
372 {\endalign}
373 \makeatother