-
Notifications
You must be signed in to change notification settings - Fork 3
/
packages.sty
262 lines (230 loc) · 8.05 KB
/
packages.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
\usepackage[a4paper,bottom=1in]{geometry}
% Fix fancyhdr warnings
\setlength{\headheight}{14.5pt}
\usepackage[english]{babel}
% Only used for text generation in the template
%
\usepackage{lipsum}
%%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[final]{microtype}
\usepackage[ttscale=.75]{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{relsize}
% Set nicer (= less bold, less vertical spacing) mathcal font
\usepackage[cal=cm]{mathalpha}
% Set up the opening page for the chapters
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\Huge}
{\filleft\textsc{\chaptertitlename} \thechapter}
{4ex}
{\bfseries
\titlerule%
\vspace{2ex}%
\filright}
[\vspace{2ex}%
\titlerule]
% Set up the headers and footers
\usepackage{fancyhdr}
\usepackage{ifthen}
\pagestyle{fancy}
\fancyhf{}
% Use ifthenelse to work around the fact that we wish to have alternate headers
% but a onesided document
% (https://tex.stackexchange.com/questions/69100/distinguish-even-odd-pages-in-header-with-oneside-option)
\fancyhead[R]{\ifthenelse{\isodd{\value{page}}}{\thepage\hfill\textsc{\nouppercase\leftmark}}{}}
\fancyhead[L]{\ifthenelse{\isodd{\value{page}}}{}{\textsc{\nouppercase\rightmark}\hfill\thepage}}
\fancyfoot{}
% Remove page numbers on the first page of a chapter
% https://tex.stackexchange.com/questions/278420/remove-page-number-on-chapter-page
\fancypagestyle{plain}{%
\renewcommand{\headrulewidth}{0pt}%
\fancyhf{}%
}
% See the excellent biblatex documentation for more information
\usepackage[
backend=biber,%
style=alphabetic,%
block=ragged,%
backref=true,%
useprefix=true,%
maxnames=8,%
minnames=7,%
minalphanames=3,%
maxalphanames=4,%
backrefstyle=two]%
{biblatex}
\addbibresource{references.bib}
\renewcommand{\subtitlepunct}{\addcolon\addspace}
% Enumerations and tables
\usepackage{calc}
\usepackage[shortlabels]{enumitem}
\setlist{nosep}
\setlist[description]{font={\textnormal},labelindent=\parindent}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[width=.8\textwidth]{caption}
\captionsetup[table]{skip=1em}
% Math packages
\usepackage{mathtools}
\usepackage{savesym}
\usepackage{amsmath}
\savesymbol{openbox}
\usepackage{amsthm}
\usepackage{thmtools}
\savesymbol{Bbbk}
\usepackage{amssymb}
\usepackage{stmaryrd}
% tocbibind allows us to have the toc in the toc
\usepackage[notbib,notindex]{tocbibind}
% Supposedly it should also allow us to have the index and the bibliography in
% the toc, but it has some bugs (e.g. displaying the right page number in the
% toc, but getting the wrong link with hyperref), so we disable those options
% here and use corresponding separate options for the index, index of symbols
% (nomenclature) and bibliography instead.
%
% The whole is rather finicky and it is somehow crucial that tocbibind is loaded
% *before* imakeidx.
\usepackage{imakeidx}
\makeindex[intoc,columns=2]
\usepackage[refpage,intoc,noprefix]{nomencl}
% Set fixed width so that descriptions in the index of symbols are aligned.
\setlength{\nomlabelwidth}{5cm}
\renewcommand{\nomname}{Index of symbols}
% Make page numbers links
\renewcommand*{\pagedeclaration}[1]{\unskip, \hyperpage{#1}}
\makenomenclature%
% Used in hyperref's setup, and must be loaded before tikz-cd.
\usepackage[dvipsnames]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{tikz-cd}
\usepackage[
colorlinks=true % Remove the boxes
, linktocpage=true % Make page numbers (not section titles) links in ToC
, linkcolor=NavyBlue % Colour for internal links
, citecolor=Green % Colour for bibliographical citations
, urlcolor=BrickRed % Colour for (external) urls
]{hyperref}
% Metadata setup (define using \subject, \degree, \institution, etc. in main.tex)
\makeatletter
\newcommand{\subject}[1]{\gdef\@subject{#1}}%
\newcommand{\@subject}{PhD thesis}
\newcommand{\degree}[1]{\gdef\@degree{#1}}%
\newcommand{\@degree}{Doctor of Philosophy}
\newcommand{\institution}[1]{\gdef\@institution{#1}}%
\newcommand{\@institution}{University of Foo}
\newcommand{\school}[1]{\gdef\@school{#1}}%
\newcommand{\college}[1]{\gdef\@college{#1}}%
\newcommand{\keywords}[1]{\gdef\@keywords{#1}}%
\newcommand{\@keywords}{some, descriptive, keywords}
\AtBeginDocument{
\hypersetup{
pdftitle = {\@title},
pdfauthor = {\@author},
pdfsubject = {\@subject},
pdfkeywords = {\@keywords}
}
}
\makeatother
\usepackage[noabbrev,capitalize]{cleveref}
\creflabelformat{equation}{#2\textup{#1}#3} % Write Equation x.y.z instead of Equation (x.y.z)
% Label tables just like equations, theorems, definitions, etc.
%
% NB: This can be confusing if LaTeX does not place the table at the point of
% writing (e.g. for lack of space)!
\numberwithin{equation}{section}
\numberwithin{table}{section}
\makeatletter
\let\c@equation\c@table
\makeatother
% Setting up the coloured environments
%
\newbool{shade-envs}
% This can be used to toggle the coloured environments on or off.
\setboolean{shade-envs}{true}
%%
\ifthenelse{\boolean{shade-envs}}{%
% Colours are as in Andrej Bauer's notes on realizability:
% https://github.com/andrejbauer/notes-on-realizability
\colorlet{ShadeOfPurple}{blue!5!white}
\colorlet{ShadeOfYellow}{yellow!5!white}
\colorlet{ShadeOfGreen} {green!5!white}
\colorlet{ShadeOfBrown} {brown!10!white}
% But we also shade proofs
\colorlet{ShadeOfGray} {gray!10!white}
}
% If we don't want to have shaded environments, then we use a closing symbol
% \lozenge to mark the end of remarks, definitions and examples.
{%
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
bodyfont=\normalfont,
qed=\(\lozenge\)
]{definitionwithbox}
\declaretheoremstyle[
headfont=\itshape,
bodyfont=\normalfont,
qed=\(\lozenge\)
]{remarkwithbox}
}
\ifthenelse{\boolean{shade-envs}}{%
\declaretheorem[sibling=equation]{theorem}
\declaretheorem[sibling=theorem]{lemma,proposition,corollary}
\declaretheorem[sibling=theorem,style=definition]{definition}
\declaretheorem[sibling=theorem,style=definition]{example}
\declaretheorem[sibling=theorem,style=remark]{remark}
% Now we set the shading using the tcolorbox package.
%
% The related thmtools' option "shaded" and the package mdframed seem to have
% issues: the former does not allow for page breaks in shaded environments and
% the latter puts double spacing between two shaded environments.
%
% Since tcolorbox puts stuff inside a minipage or \parbox (according to this
% stackexchange answer: https://tex.stackexchange.com/a/250170), new
% paragraphs aren't indented. We can fix this by grabbing the parindent
% value and passing it to tcbset.
\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}
\tcbset{shadedenv/.style={
colback={#1},
frame hidden,
enhanced,
breakable,
boxsep=0pt,
left=2mm,
right=2mm,
% LaTeX thinks this is too wide (as becomes clear from the many "Overfull
% \hbox" warnings, but optically it looks spot on.
add to width=1.1mm,
enlarge left by=-0.6mm,
before upper={\setlength{\parindent}{\normalparindent}}}
}
\newcommand{\setenvcolor}[2]{%
\tcolorboxenvironment{#1}{shadedenv={#2}}
\addtotheorempreheadhook[#1]{\tikzcdset{background color=#2}}
}
%
\setenvcolor{theorem}{ShadeOfPurple}
\setenvcolor{lemma}{ShadeOfPurple}
\setenvcolor{proposition}{ShadeOfPurple}
\setenvcolor{corollary}{ShadeOfPurple}
\setenvcolor{definition}{ShadeOfYellow}
\setenvcolor{example}{ShadeOfGreen}
\setenvcolor{remark}{ShadeOfBrown}
\setenvcolor{proof}{ShadeOfGray}
}{% Use closing symbols if we don't have colours
\declaretheorem[sibling=equation]{theorem}
\declaretheorem[sibling=theorem]{lemma,proposition,corollary}
\declaretheorem[sibling=theorem,style=definitionwithbox]{definition}
\declaretheorem[sibling=theorem,style=definitionwithbox]{example}
\declaretheorem[sibling=theorem,style=remarkwithbox]{remark}
}
\declaretheorem[sibling=theorem,style=remark,numbered=no]{claim}
% Note that proofs will still have the \qed symbol at the end, even when shaded,
% because we prefer to keep up the tradition.
% Set table of contents depth
\setcounter{tocdepth}{2}