more 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 \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
131 % Graphics
132 \usepackage{graphicx} % Images
133 \graphicspath{{img/},{intro/img},{top/img},{tvt/img}}
134 \usepackage{caption} % subfigures
135 \usepackage{subcaption}
136 \usepackage{rotating}
137 \newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}
138 \usepackage{tikz}
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 \usepackage{threeparttable} % Tables with footnotes
146
147 % Code
148 % Pseudocode
149 \usepackage[algochapter]{algorithm2e}
150 % Fix the algorithm font
151 \renewcommand\AlCapFnt{\normalfont}
152 \usepackage{listings}
153 % https://tex.stackexchange.com/questions/149056/how-can-i-define-additional-literate-replacements-without-deleting-existing-ones
154 \makeatletter
155 \def\addToLiterate#1{\edef\lst@literate{\unexpanded\expandafter{\lst@literate}\unexpanded{#1}}}
156 \lst@Key{moreliterate}{}{\addToLiterate{#1}}
157 \makeatother
158 % General listings settings
159 \lstset{%
160 basewidth=0.5em,
161 basicstyle=\tt\small,
162 breakatwhitespace=false,
163 breaklines=true,
164 captionpos=b,
165 columns=[c]fixed,
166 commentstyle=\sl,
167 escapeinside={[+}{+]}, % chktex 9
168 frame=L,
169 keepspaces=true,
170 keywordstyle=\bf,
171 postbreak=\mbox{\textcolor{gray}{$\hookrightarrow$}\space},
172 showspaces=false,
173 showstringspaces=false,
174 showtabs=false,
175 stringstyle=\it,
176 tabsize=4,
177 upquote=true,
178 numberstyle=\tiny,
179 }
180 \usepackage{lstlangclean}
181 \usepackage{lstlanghaskell}
182 \usepackage{lstlangarduino}
183 \lstloadlanguages{%
184 {[Arduino]C++},%
185 {c},%
186 {Python},%
187 {Clean},%
188 {[Regular]Haskell},
189 {[Lhs2Tex]Haskell}}
190 \newcommand{\cinline}[1]{\lstinline[language=c,postbreak=]|#1|}
191 \newcommand{\arduinoinline}[1]{\lstinline[language={[Arduino]C++},postbreak=]|#1|}
192 \newcommand{\pythoninline}[1]{\lstinline[language=Python,postbreak=]|#1|}
193 \newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
194 \newcommand{\haskellinline}[1]{\lstinline[language={[Regular]Haskell},postbreak=]|#1|}
195 \newcommand{\haskelllhstexinline}[1]{\lstinline[language={[Lhs2Tex]Haskell},postbreak=]|#1|}
196 %For storing listings in footnotes
197 \newsavebox{\LstBox}
198 % Fix list of listings title
199 \renewcommand{\lstlistlistingname}{List of Listings}
200 % Fix list of listings chapter separator
201 \makeatletter
202 \let\my@chapter\@chapter%
203 \renewcommand*{\@chapter}{%
204 \addtocontents{lol}{\protect\addvspace{10pt}}%
205 \my@chapter}
206 \makeatother
207
208 \lstnewenvironment{lstPython}[1][]
209 {%
210 \lstset{language=Python, #1}
211 \renewcommand*{\lstlistingname}{Listing (\gls{PYTHON})}
212 }
213 {}
214 \lstnewenvironment{lstClean}[1][]
215 {%
216 \lstset{language=Clean, #1}
217 \renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}
218 }
219 {}
220 \lstnewenvironment{lstArduino}[1][]
221 {%
222 \lstset{language={[Arduino]C++}, #1}
223 \renewcommand*{\lstlistingname}{Listing (\gls{ARDUINO})}
224 }
225 {}
226 \lstnewenvironment{lstHaskell}[1][]
227 {%
228 \lstset{language={[Regular]Haskell},#1}%
229 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
230 }
231 {}
232 \lstnewenvironment{lstHaskellLhstex}[1][]
233 {%
234 \lstset{language={[Lhs2Tex]Haskell},#1}%
235 \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
236 }
237 {}
238
239 % Hyperlinks and metadata
240 \usepackage[pdflang={en-GB},pagebackref]{hyperref} % hyperlinks
241 \usepackage{xr} % 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{\etc}{{\fontfamily{cmr}\selectfont{\itshape\/\&\kern-0.2em c}}}
316 \newcommand{\rdmentry}[6]{#1: #2 (#3): #4. #5.\ \href{https://doi.org/#6}{#6}}
317 \newcommand{\mlubbers}{Lubbers, M.\ (Radboud University)}
318 \newcommand{\pkoopman}{Koopman, dr.\ P.\ (Radboud University)}
319 \newcommand{\rplasmeijer}{Plasmeijer, prof.\ dr.\ ir.\ R.\ (Radboud University)}
320
321 \newcommand{\mypart}[3]{
322 \part[#2: #3]{#2\\[2ex]\smaller{}#3}%
323 \label{#1}
324 }