-
Notifications
You must be signed in to change notification settings - Fork 0
/
uqspace-preamble.sty
445 lines (331 loc) · 13.5 KB
/
uqspace-preamble.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3} % - Load LaTeX3 packages
%% ============================================================================
%% ~~~ CLASS META-INFO ~~~
%% ____________________________________________________________________________
\ProvidesExplPackage
{uqspace-preamble} % - Name
{2024/05/22} % - Date
{2.7.0} % - Version
{Report preamble list for use by UQ Space} % - Description
%% ============================================================================
%% ============================= LaTeX3 Packages =============================
% Required package information:
%
% xparse -> Allows for custom macros with a range of inputs, including
% custom defaults, stars, delimiters, etc.
%
% xspace -> Detection of spaces and punctuation gobbled by a macro, and
% replacement of said text naturally.
%% ----------------------------------------------------------------------------
\RequirePackage { xparse }
\RequirePackage { xspace }
\RequirePackage { l3keys2e }
%% ----------------------------------------------------------------------------
% For some reason, \PassOptionsToPackage won't work for biblatex
\str_new:N \g_biblatex_style_str
\str_new:N \g_biblatex_citestyle_str
\keys_define:nn { preamble-options / biblatex }{
style .str_set:N = \g_biblatex_style_str,
citestyle .str_set:N = \g_biblatex_citestyle_str,
style .initial:n = numeric-comp,
citestyle .initial:n = numeric-comp,
style .value_required:n = true,
citestyle .value_required:n = true,
}
\ProcessKeysPackageOptions { preamble-options }
%% ============================================================================
%% ============================= General packages =============================
\RequirePackage { parskip } % Improves paragraph spacing
\RequirePackage { geometry }
\RequirePackage { afterpage }
\RequirePackage { ragged2e }
\RequirePackage [ table, x11names ]{ xcolor }
\RequirePackage { microtype } % Tweak font spacing for aesthetics
\RequirePackage { fontawesome5 }
\RequirePackage { multicol } % Multiple columns Environment
\RequirePackage { genmpage } % Minipage options
\RequirePackage [ strict ]{ changepage }
\RequirePackage [ margin-comments ]{ paperchange }
\RequirePackage { import }
\RequirePackage { pdfpages } % Allows inclusion of non-tex pdfs
%% ----------------------------- General commands -----------------------------
\linespread { 1.15 } % Nicer linespreading
\setcounter { tocdepth }{ 3 } % Count 3 levels within TOC
\NewDocumentCommand \frontmatter { }{
\pagenumbering { roman }
\pagestyle { plain }
}
\NewDocumentCommand \mainmatter { }{
\pagenumbering { arabic }
\pagestyle { headings }
}
% --- Reset page sizing after importing each section, for consistency
\let\oldimport\import
\RenewDocumentCommand \import { smm }{
\IfBooleanTF { #1 }{ }{ \newpage }
\oldimport { #2 }{ #3 }
\IfBooleanTF { #1 }{ }{ \newpage \restorepagesize }
}
%% ============================================================================
%% ============================= Acronym packages =============================
\RequirePackage { acro } % Acronyms and list-of-acronyms
\acsetup {
patch/maketitle = false
}
%% ----------------------------- Acronym commands -----------------------------
% -- Create possessive endings for acronyms
\DeclareAcroEnding { possessive } { 's } { 's }
\NewAcroCommand \acg { m }{
\acropossessive \UseAcroTemplate { first }{ #1 }
}
\NewAcroTemplate [ heading ]{ subsection* }{
\subsection* { \acrolistname }
}
% --- Creates function that takes two values, and creates an acronym belonging
% to a given class.
\cs_new:Nn \acr_new_acro:nn { }
\cs_new:Nn \acr_set_class:n {
\cs_gset:Nn \acr_new_acro:nn {
\DeclareAcronym { ##1 } {
short = { ##1 },
long = { ##2 },
tag = { #1 }
}
}
}
% --- Takes a list of key-value arguments, with each key and values being the
% short and long forms of the acronyms respectively. Has an optional
% argument representing the class the acronyms belong to.
\NewDocumentCommand \AddAcronyms { O{} m } {
\acr_set_class:n { #1 }
\keyval_parse:NNn \use_none:n \acr_new_acro:nn { #2 }
}
\NewDocumentCommand \addacronymfile { m }{
\oldimport { ./ }{ #1 }
}
%% ============================================================================
%% ========================= Maths & Science packages =========================
\RequirePackage{
amsmath, amssymb,
amsthm, amsfonts
}
\RequirePackage[ % Consistent formatting of SI Units
per-mode=symbol, % ~ e.g. \qty{8314}{\kJ\per\kg\per\K},
separate-uncertainty=true, % ~ \num{1e6}, \ang{45}, etc...
multi-part-units=single,
reset-text-series=false,
reset-text-shape=false,
mode=match
] { siunitx }
\RequirePackage { mathtools } % Space tweaking within maths
\RequirePackage { chemformula } % Chemical equations -> e.g. \ch{H20}
\RequirePackage { bm } % Bold maths symbols -> e.g. \bm{\alpha}
\RequirePackage { xfrac } % Use \sfrac{}{} for slanted fractions
\RequirePackage { esint } % Gives nicer integration symbols
\RequirePackage { cancel } % Gives \cancelto{val}{var}
\RequirePackage [ super ]{ nth } % Ordinal indicators, with superscript
% ~ e.g \nth{1} gives 1^st
\RequirePackage { circledsteps }
\RequirePackage { skmath } % Extensive simple math commands
%% ------------------------- Maths & Science commands -------------------------
\numberwithin { equation }{ section }
\let\vec\bm % Use bold notation for vectors
\DeclareSIUnit \ft { ft } % \inch and \ft for imperial units
\DeclareSIUnit [ number-unit-product = \thinspace ] \inch { in }
\DeclareSIUnit \aud { \textsc{Aud}\thinspace\$ }
\DeclareSIUnit \usd { \textsc{USD}\thinspace\$ }
%% ============================================================================
%% ============================= Figure packages ==============================
\RequirePackage { graphicx }
\RequirePackage { tikz }
\RequirePackage { tikz-3dplot }
\RequirePackage { svg }
\RequirePackage { float }
\RequirePackage [ export ]{ adjustbox }
\RequirePackage { caption }
\RequirePackage { subcaption }
%% ----------------------------- Figure commands ------------------------------
\graphicspath { { images/ } }
\ExplSyntaxOff % --> Tikz relies on spaces too much
\usetikzlibrary{arrows.meta,scopes,positioning,fadings,backgrounds,fit,calc,chains}
\ExplSyntaxOn % <--
\captionsetup {
format = hang,
figurewithin = section,
tablewithin = section,
figureposition = below,
tableposition = above,
justification = raggedright,
skip = 5pt,
font = small
}
\tikzset{debug~grid/.style = {
step = 1.0,
draw = gray!50,
very~thin,
overlay
}}
%% ============================================================================
%% ============================== Table packages ==============================
\RequirePackage { tabularray } % For customisation of tables
\RequirePackage { rotating } % Rotate cells with \begin{sideways}...
\RequirePackage { longtable } % Tables that go over multiple pages
\RequirePackage { threeparttable } % Tables that allow for notes below
\RequirePackage { tablefootnote } % Allows for footnotes within tables
%% ------------------------------ Table commands ------------------------------
% Load libraries from tabularray for easy compatibility
\UseTblrLibrary { amsmath, booktabs, siunitx }
% Default values for tblr environments
\SetTblrOuter { expand = \thead } % Expand \thead to get cell formats
\SetTblrInner { stretch = 1.2 }
% Simple column defaults for paragraphs
% NOTE: Use h instead of t to get better alignment
\NewColumnType { L }[ 1 ]{ Q[ h, l, #1 ] }
\NewColumnType { R }[ 1 ]{ Q[ h, r, #1 ] }
\NewColumnType { C }[ 1 ]{ Q[ h, c, #1 ] }
% Itemize and Enumerate column types
\NewColumnType { I }[ 2 ][ ]{
Q[
h, l, #2,
preto={\begin{softlist}{tblItem}[#1]},
appto={\end{softlist}}
]
}
\NewColumnType { E }[ 2 ][ ]{
Q[
h, l, #2,
preto={\begin{softlist}{tblEnum}[#1]},
appto={\end{softlist}}
]
}
% Define mock commands for \thead and similar
% NOTE: Must use \newcommand, as \NewExpandableDocumentCommand requires full expansion
\newcommand \thead [ 1 ]{
\SetRow { abovesep = 6pt, belowsep = 6pt }
\SetCell { c, m }
{ \theadfont \theadset #1 }
}
% Defaults only
\newcommand \theadfont { \footnotesize }
\newcommand \theadset { }
% If we wish to override all `tabular` environments to new tblr environment
\RenewDocumentEnvironment { tabular }{ O{} m +b }
{ \begin{tblr}[#1]{#2} #3 }
{ \end{tblr} }
%% ============================================================================
%% ============================== List packages ===============================
\RequirePackage [ inline ]{ enumitem } % For customisation of lists
\RequirePackage { etoolbox }
%% ------------------------------ List commands -------------------------------
% --- Remove line spacing between items
\setlist { noitemsep }
% --- Remove all vertical spacing in itemize
\setitemize { nosep, label=\textbullet }
% --- Create enumerate for within tables
\newlist { tblEnum }{ enumerate }{ 2 }
\setlist [ tblEnum ]{
nosep,
leftmargin = 3.5ex,
label =\arabic*.,
labelwidth = 2.5ex,
before* ={\mbox{}\vspace{-\baselineskip}},
}
% --- Create itemize for within tables
\newlist { tblItem }{ itemize }{ 2 }
\setlist [ tblItem ]{
nosep,
leftmargin = 3.5ex,
labelwidth = 2.5ex,
label =\textbullet,
before* ={\mbox{}\vspace{-\baselineskip}},
}
% --- Create description for List of Acronyms
\NewDocumentCommand \addcolon { m }{ #1: }
\newlist { acronyms }{ description }{ 2 }
\setlist [ acronyms ]{
noitemsep,
font =\addcolon,
labelwidth = 5em,
leftmargin = 6.5em,
itemindent = 0pt,
}
% --- Create a "soft" list, which only enables if the first token is \item
% Takes the list environment to enable as the first argument
\NewDocumentEnvironment { softlist }{ m O{} +b }{
\bool_set_false:N \l_tmpa_bool
\peek_meaning:NT \item {
\bool_set_true:N \l_tmpa_bool
\begin{#1}[#2]
}
#3
}{
\bool_if:NT \l_tmpa_bool {
\end{#1}
}
}
% \DeclareAcroListStyle { mystyle }{ list }{ list = acronyms }
\acsetup { list/template = description, list/name = Nomenclature }
\str_new:N \req_prefix_code_str
\NewDocumentEnvironment { requirements }{ O{} m }{
\str_if_empty:NF \req_prefix_code_str
{ \msg_warning:nn { Requirements }{ Cannot~change~requirement~prefix~in~subrequirements } }
\str_set:Nn \req_prefix_code_str { #2 }
\begin { subrequirements }[ #1 ]
}{
\end { subrequirements }
\str_clear:N \req_prefix_code_str
}
\NewDocumentEnvironment { subrequirements }{ O{} }{
\str_if_empty:NT \req_prefix_code_str
{ \msg_error:nn { Requirements }{ Subrequirements~must~exist~within~parent~requirement } }
\begin { reqenum }[ #1 ]
}{
\end { reqenum }
}
\tl_new:N \requirement_format_tl
\tl_set:Nn \requirement_format_tl { \textit }
\NewDocumentCommand \requirement { m }{
\item \requirement_format_tl { #1 }
}
\SetLabelAlign { fixedwidth }{ \hfil\llap{\makebox[\labelwidth][l]{#1}} }
\newlist { reqenum }{ enumerate }{ 3 }
\setlist [ reqenum ]{
label=\texttt{\req_prefix_code_str - \arabic*},
align=fixedwidth, labelsep*=0pt, labelwidth=!
}
\setlist* [ reqenum, 1 ]{ leftmargin=20mm, labelindent=0pt, itemsep=5pt }
\setlist* [ reqenum, 2 ]{ label*=\texttt{.\arabic*}, leftmargin=5mm, labelindent=-20mm }
\setlist* [ reqenum, 3 ]{ label*=\texttt{.\arabic*}, leftmargin=5mm, labelindent=-25mm }
%% ============================================================================
%% ============================== Code packages ===============================
\RequirePackage { minted }
\RequirePackage { algpseudocode }
%% ------------------------------ Code commands -------------------------------
\renewcommand \listoflistingscaption { List of source codes }
\usemintedstyle { friendly }
\setminted [ python ] {
tabsize = 4,
fontsize =\footnotesize,
frame = lines,
framesep = 0.5em,
obeytabs,
linenos
}
%% ============================================================================
%% =========================== Referencing packages ===========================
\RequirePackage [ hyphens ] { url } % breaks urls at hyphens
\RequirePackage [ hidelinks ] { hyperref }
\RequirePackage [ noabbrev, capitalise ] { cleveref }
\RequirePackage { csquotes }
\RequirePackage [ english ]{ babel }
\RequirePackage [
natbib,
backend = biber,
style = \g_biblatex_style_str,
citestyle = \g_biblatex_citestyle_str,
]{ biblatex }
\setcounter { biburlucpenalty }{ 10000 }
%% --------------------------- Referencing commands ---------------------------
% \providecommand \phantomsection \relax
%% ============================================================================