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