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