stab at some chapters
[phd-thesis.git] / preamble.tex
1 % Input encoding
2 \usepackage[utf8]{inputenc}
3
4 % Papersize
5 \usepackage{geometry}
6 \geometry{
7 inner=25mm,
8 outer=20mm,
9 marginparsep=3mm,
10 marginparwidth=13mm,
11 top=25mm,
12 bottom=20mm,
13 paperwidth=17cm,
14 paperheight=24cm,
15 }
16
17 % Font encoding
18 \usepackage[T1,T2A]{fontenc}
19
20 % Less bad boxes
21 \usepackage{microtype}
22
23 % No more room for a new \write
24 \usepackage{morewrites}
25
26 % Internationalisation
27 \usepackage[british]{babel}
28 %\babelfont[russian]{rm}{Liberation Serif}
29
30 % Appendices
31 % TODO is this necessary?
32 \usepackage[titletoc]{appendix}
33
34 % Hyperlinks
35 %\usepackage[pagebackref]{hyperref}
36 \usepackage[pagebackref]{hyperref}
37 % Setup pdf parameters: TODO
38 \hypersetup{%
39 pdftitle={\mytitle},
40 pdfauthor={\myauthor},
41 pdfsubject={},
42 % pdfcreator={},
43 % pdfproducer={},
44 pdfkeywords={task oriented programming, functional programming, domain specific languages, internet of things},
45 hidelinks,
46 }
47
48 % Graphics
49 \usepackage{graphicx}
50 % Images directory
51 \graphicspath{{img/}}
52
53 % Nice tables
54 \usepackage{booktabs}
55
56 % Automatically wrapping tables
57 \usepackage{tabularx}
58
59 % Use a fixed document date
60 \usepackage[nodayofweek]{datetime}
61
62 % Code
63 \usepackage{stmaryrd} % Short arrow
64 \usepackage{listings}
65 % General listings settings
66 \lstset{%
67 basewidth=0.43em,
68 basicstyle=\linespread{0.9}\tt\footnotesize,
69 breakatwhitespace=false,
70 breaklines=true,
71 captionpos=b,
72 columns=[c]fixed,
73 commentstyle=\sl,
74 escapeinside={(+}{+)}, % chktex 9
75 frame=L,
76 keepspaces=true,
77 keywordstyle=\bf,
78 postbreak=\mbox{\textcolor{gray}{$\hookrightarrow$}\space},
79 showspaces=false,
80 showstringspaces=false,
81 showtabs=false,
82 stringstyle=\it,
83 tabsize=4,
84 literate=%
85 {~}{$\sim$}1
86 {\\}{{$\lambda\:$}}1
87 {->}{{$\shortrightarrow$}}2
88 {<-}{{$\shortleftarrow$}}2
89 {=>}{{$\Rightarrow$}}2
90 {<=}{{$\Leftarrow$}}2
91 {'}{{`}}1
92 {...}{{$\cdots$}}1 %chktex 11
93 {a0}{{a\textsubscript{0}}}2
94 {a1}{{a\textsubscript{1}}}2
95 {a2}{{a\textsubscript{2}}}2
96 % {an}{{a\textsubscript{n}}}2
97 {c0}{{c\textsubscript{0}}}2
98 {c1}{{c\textsubscript{1}}}2
99 {c2}{{c\textsubscript{2}}}2
100 {cn}{{c\textsubscript{n}}}2
101 {f0}{{f\textsubscript{0}}}2
102 {f1}{{f\textsubscript{1}}}2
103 {f2}{{f\textsubscript{2}}}2
104 {fn}{{f\textsubscript{n}}}2
105 {t0}{{t\textsubscript{0}}}2
106 {t1}{{t\textsubscript{1}}}2
107 {t2}{{t\textsubscript{2}}}2
108 {tn}{{t\textsubscript{n}}}2
109 {v0}{{v\textsubscript{0}}}2
110 {v1}{{v\textsubscript{1}}}2
111 {v2}{{v\textsubscript{2}}}2
112 {vn}{{v\textsubscript{n}}}2
113 {C0}{{C\textsubscript{0}}}2
114 {C1}{{C\textsubscript{1}}}2
115 {C2}{{C\textsubscript{2}}}2
116 {Cn}{{C\textsubscript{n}}}2
117 {R0}{{R\textsubscript{0}}}2
118 {R1}{{R\textsubscript{1}}}2
119 {R2}{{R\textsubscript{2}}}2
120 {Rn}{{R\textsubscript{n}}}2
121 }
122 \lstdefinestyle{haskell}{%
123 language=Haskell,
124 deletekeywords={True,False,Bool,Int,Float,Double,zip,length,Show,show,Num,Eq,print,String},
125 }
126 \lstdefinelanguage{Clean}{%
127 alsoletter={ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_`1234567890},
128 alsoletter={~!@\#$\%^\&*-+=?<>:|\\.},
129 morekeywords={generic,implementation,definition,dynamic,module,import,from,where,in,of,case,let,infix,infixr,infixl,class,instance,with,if,derive,code,In,qualified,otherwise},
130 sensitive=true,
131 morecomment=[l]{//},
132 morecomment=[n]{/*}{*/},
133 morestring=[b]", % chktex 18
134 morestring=[s]{['}{']}, % chktex 9
135 }
136 \newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
137 \newcommand{\haskellinline}[1]{\lstinline[language=Haskell,style=haskell,postbreak=]|#1|}
138 % Fix list of listings title
139 \renewcommand{\lstlistlistingname}{List of Listings}
140 % Fix list of listings chapter separator
141 \makeatletter
142 \let\my@chapter\@chapter%
143 \renewcommand*{\@chapter}{%
144 \addtocontents{lol}{\protect\addvspace{10pt}}%
145 \my@chapter}
146 \makeatother
147
148 \lstnewenvironment{lstClean}[1][]
149 {%
150 \lstset{language=Clean, #1}
151 \renewcommand*{\lstlistingname}{Listing (Clean)}
152 }
153 {}
154 \lstnewenvironment{lstHaskell}[1][]
155 {%
156 \lstset{language=Haskell,style=haskell,#1}%
157 \renewcommand*{\lstlistingname}{Listing (Haskell)}
158 }
159 {}
160
161 % Glossaries and acronyms
162 \usepackage[acronym,nonumberlist]{glossaries}
163 % Fix gls in hyperlink errors
164 \pdfstringdefDisableCommands{%
165 \def\acrlong#1{}%
166 \def\acrlongpl#1{}%
167 \def\acrshort#1{}%
168 \def\acrshortpl#1{}%
169 \def\acrfull#1{}%
170 \def\acrfullpl#1{}%
171 \def\Acrlong#1{}%
172 \def\Acrlongpl#1{}%
173 \def\Acrshort#1{}%
174 \def\Acrshortpl#1{}%
175 \def\Acrfull#1{}%
176 \def\Acrfullpl#1{}%
177 \def\gls#1{}%
178 \def\glspl#1{}%
179 \def\glsentrytext#1{}%
180 \def\Gls#1{}%
181 \def\Glspl#1{}%
182 \def\Glsentrytext#1{}%
183 \def\titlecap#1{}%
184 }
185
186 % Titlecase commands
187 \usepackage{titlecaps}
188 \Addlcwords{of}
189 % Titlecase glossary command
190 \newcommand{\glst}[1]{\titlecap{\glsentrylong{#1}}}
191 \newcommand{\Glst}[1]{\glst{#1}}
192
193 % Pseudocode
194 \usepackage[algochapter]{algorithm2e}
195 % Fix the algorithm font
196 \renewcommand\AlCapFnt{\normalfont}
197
198 % Index
199 \usepackage{makeidx}
200 % Enable the index
201 \makeindex%
202
203 % Custom enumerations
204 \usepackage[inline,shortlabels]{enumitem}
205 \setlist{noitemsep}
206 \setlist[description]{leftmargin=\parindent}
207
208 % Epigraph (lovecraft)
209 \usepackage{epigraph}
210
211 % Thumb marks on the page
212 \usepackage[
213 height={1.5cm},
214 width={12mm},
215 distance={1.55cm},
216 topthumbmargin={auto},
217 bottomthumbmargin={auto},
218 eventxtindent={.5cm},
219 oddtxtexdent={.3cm}]{thumbs}
220
221 % Custom headers and footers
222 \usepackage{fancyhdr}
223 \pagestyle{fancy}
224
225 % Tables spanning pages
226 \usepackage{longtable}
227
228 % Easy references
229 \usepackage{cleveref}
230
231 % Diagrams
232 \usepackage{tikz}
233 \usetikzlibrary{pie}
234
235 % To patch the chapter command
236 \usepackage{etoolbox}
237 % Have better page numbering in chapters
238 \patchcmd{\chapter}{plain}{headings}{}{}
239
240 % Increase the depth for the table of contents
241 \setcounter{secnumdepth}{3}
242 \renewcommand{\contentsname}{Table of Contents} % change the name of the TOC
243 \AtBeginDocument{\addtocontents{toc}{\protect\thispagestyle{empty}}} % to remove page numbering from the TOC
244
245 % Initialize the glossaries
246 \makeglossaries%
247 \input{glossaries}
248
249 % Custom commands
250 \newcommand{\GHCmod}[1]{\texttt{#1}}
251 \newcommand{\requiresGHCmod}[1]{\footnote{Requires \GHCmod{#1} to be enabled.}}
252 \newcommand{\etc}{{\fontfamily{cmr}\selectfont{\itshape\/\&c}}}