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