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