-
Notifications
You must be signed in to change notification settings - Fork 2
/
ist-thesis.cls
389 lines (357 loc) · 13.5 KB
/
ist-thesis.cls
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
%% ist-thesis.cls
%% Copyright 2020 Daniel de Schiffart
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Daniel de Schiffart.
%
% This work consists of the file ist-thesis.cls.
%
% The most recent version of this work, along with
% documentation and examples, can be found online
% at https://github.com/ekspek/ist-thesis
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ist-thesis}[2020/05/05 v1.1.4 Unofficial IST thesis class]
\typeout{_____________________________________________________________________________}
\typeout{_____________________________________________________________________________}
\typeout{__________________`:::::::::::::::::::::::::::::::::::::::`__________________}
\typeout{__________________.ooooooooooooooooooooooooooooooooooooooo`__________________}
\typeout{__________________.oooooooooooooooooooo/://:/+oooooooooooo`__________________}
\typeout{__________________.oooooooooooooooooo-`_:oo-_`-ooooooooooo`__________________}
\typeout{__________________.ooooooooooooooooo/___+oo+___+oooooooooo`__________________}
\typeout{__________________.ooooooooooooooooo/___+ooo+/+ooooooooooo`__________________}
\typeout{__________________.oooooooooo+///ooo/___+o///////ooooooooo`__________________}
\typeout{__________________.oooooooooo:___+oo/___+o.`___`.ooooooooo`__________________}
\typeout{__________________.oooooooooo:___+oo/___+o+/___/+ooooooooo`__________________}
\typeout{__________________.oooooooooo:___+oo/___+oo/___/oooooooooo`__________________}
\typeout{__________________.oooooooooo:___+oo/___+oo/___/oooooooooo`__________________}
\typeout{__________________`oooooooooo:___+oo/___+oo/___/oooooooooo___________________}
\typeout{___________________+ooooooooo:___+oo/___+oo/___/ooooooooo+___________________}
\typeout{___________________-ooooooooo:___+oo/___+oo/___/ooooooooo-___________________}
\typeout{____________________+oooooooo+///ooo/___+ooo///ooooooooo/____________________}
\typeout{____________________.ooooooooo//+ooo/___+oooooooooooooo+`____________________}
\typeout{_____________________.+oooooo/__`ooo/___+ooooooooooooo+`_____________________}
\typeout{______________________`+ooooo+.`_/o+-_`:ooooooooooooo/`______________________}
\typeout{_______________________`:oooooo+/:////oooooooooooooo:________________________}
\typeout{_________________________.+ooooooooooooooooooooooo/`_________________________}
\typeout{___________________________-+ooooooooooooooooooo/.___________________________}
\typeout{_____________________________./ooooooooooooooo/._____________________________}
\typeout{_______________________________`:+ooooooooo+-`_______________________________}
\typeout{__________________________________.:+ooo+:.__________________________________}
\typeout{_____________________________________.-`_____________________________________}
\typeout{_____________________________________________________________________________}
\typeout{_____________________________________________________________________________}
% Packages loaded for class commands and engine checks
\RequirePackage{etoolbox}
\RequirePackage{ifluatex}
\RequirePackage{ifxetex}
\RequirePackage{ifpdf}
% Booleans for class options
\newbool{@portuguese}
\newbool{@english}
\newbool{@origmath}
\newbool{@bw}
% Bind the class option interface to the respective booleans
\DeclareOption{portuguese} {\booltrue{@portuguese}\PassOptionsToClass{portuguese}{report}}
\DeclareOption{english} {\booltrue{@english}\PassOptionsToClass{english}{report}}
\DeclareOption{origmath} {\booltrue{@origmath}}
\DeclareOption{bw} {\booltrue{@bw}}
% Use the basic LaTeX report class with the twoside option as base
% Portuguese is on by default
\PassOptionsToClass{twoside}{report}
\ExecuteOptions{portuguese}
\ProcessOptions\relax
\LoadClass{report}
% Unicode boolean for either XeTeX or LuaTeX
\newbool{unicode}
\ifbool{xetex}{
\booltrue{unicode}
}{
\ifbool{luatex}
{ \booltrue{unicode} }
{ \boolfalse{unicode} }
}
% Language sanity check (english option takes priority if chosen)
\ifbool{@english}{\boolfalse{@portuguese}}
\RequirePackage{mathtools}
\RequirePackage{graphicx}
\RequirePackage{xcolor}
\RequirePackage[hidelinks]{hyperref}
\RequirePackage{geometry}
% Font and language settings
% These settings are very engine dependent and need careful treatment
\ifbool{unicode}{
% Font settings
\RequirePackage[no-math]{fontspec}
\IfFontExistsTF{texgyreheros-regular.otf}{
\setsansfont[
UprightFont = *-regular,
Extension = .otf,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic]{texgyreheros}
}{}
\renewcommand{\familydefault}{\sfdefault}
\setmonofont[Scale = 1.14]{InconsolataN}
}{
% Font settings
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{tgheros}
\renewcommand{\familydefault}{\sfdefault}
\RequirePackage[scaled = 1.14, narrow]{inconsolata}
}
% Language settings
\ifbool{@portuguese}
{ \RequirePackage[main = portuguese, british]{babel} }
{ \RequirePackage[main = british, portuguese]{babel} }
% Load the newtxsf math font (engine agnostic) if origmath isn't activated
\notbool{@origmath}{\RequirePackage{newtxsf}}{}
\RequirePackage{microtype}
\RequirePackage{tocbibind}
\RequirePackage{setspace}
\RequirePackage{caption}
\RequirePackage{totpages}
% Default IST regulations
\geometry{a4paper,margin = 2.5cm}
\setstretch{1.5}
% Prevent paragraph alignment between odd and even pages
\raggedbottom
% Caption definitions, not mandatory but look a bit better
\captionsetup{labelfont = bf, margin = 15pt}
\captionsetup[table]{position = top, skip = 3pt}
% Set the IST colors if the bw option is not chosen
\ifbool{@bw}{
\definecolor{ist-cyan}{cmyk}{1,1,1,1}
\definecolor{ist-gray}{cmyk}{1,1,1,1}
}{
\definecolor{ist-cyan}{cmyk}{1,0,0,0}
\definecolor{ist-gray}{cmyk}{0.2,0,0,0.8}
}
% Bind the defined colors to their hyperref targets
\hypersetup{colorlinks,
linkcolor = {ist-cyan},
citecolor = {ist-cyan},
urlcolor = {ist-cyan}
}
% Prevent the ToC from getting colors
\notbool{@bw}{
\preto\tableofcontents{\begingroup\hypersetup{linkcolor = black}}
\appto\tableofcontents{\endgroup}
\preto\listoffigures{\begingroup\hypersetup{linkcolor = black}}
\appto\listoffigures{\endgroup}
\preto\listoftables{\begingroup\hypersetup{linkcolor = black}}
\appto\listoftables{\endgroup}
}
% Define a warning if the document surpasses 100 pages (IST rules)
\def\maxPages{100}
\AfterEndDocument{
\ifnumcomp{\theTotPages}{>}{\maxPages}{
\ClassWarningNoLine{ist-thesis}{%
Number of pages exceeds IST regulated maximum for\MessageBreak
a dissertation (\theTotPages\space pages out of a maximum of \maxPages).\MessageBreak
Remove content and compile again}
}{}
}
% Define PDF metadata for PDF readers to use
\hypersetup{unicode = true}
\ifbool{unicode}
{ \hypersetup{pdfcreator = {Xe/LuaLaTeX with the ist-thesis class}} }
{ \hypersetup{pdfcreator = {pdfLaTeX with the ist-thesis class}} }
\ifbool{@english}
{ \hypersetup{pdflang = {English}} }
{ \hypersetup{pdflang = {Português}} }
% Defining class metadata variables for various purposes
\newrobustcmd*\tsubtitle{}
\newrobustcmd*\tsupervisor{Prof. Lorem Ipsum \tand Prof. Lorem Ipsum}
\newrobustcmd*\tcsupervisor{Prof. Lorem Ipsum}
\newrobustcmd*\tchairperson{Prof. Lorem Ipsum}
\newrobustcmd*\tcommittee{Prof. Lorem Ipsum \tand Prof. Lorem Ipsum}
\newrobustcmd*\tinstitution{Instituto Superior Técnico}
\newrobustcmd*\tcoverimage{example-image}
\newrobustcmd*\tcoverimagewidth{0.5}
\newrobustcmd*\tand{\\ &}
\newrobustcmd*\tcoverbacktext{}
% Default values for class metadata (language dependent)
\ifbool{@english}{
\newrobustcmd*\ttitle{[Thesis Title]}
\newrobustcmd*\tauthor{[Candidate Full Name]}
\newrobustcmd*\tdegree{[Scientific Field]}
\newrobustcmd*\tdate{[Month and Year]}
}{
\newrobustcmd*\ttitle{[Título da Dissertação]}
\newrobustcmd*\tauthor{[Nome Completo do(a) Candidato(a)]}
\newrobustcmd*\tdegree{[Nome do Curso]}
\newrobustcmd*\tdate{[Mês e Ano]}
}
% Define user commands to set the class metadata (and some PDF metadata entries too)
\newrobustcmd*\settitle[1]{\renewcommand\ttitle{#1}\hypersetup{pdftitle = {#1}}}
\newrobustcmd*\setsubtitle[1]{\renewcommand\tsubtitle{#1}\hypersetup{pdfsubject = {#1}}}
\newrobustcmd*\setauthor[1]{\renewcommand\tauthor{#1}\hypersetup{pdfauthor = {#1}}}
\newrobustcmd*\setdegree[1]{\renewcommand\tdegree{#1}}
\newrobustcmd*\setinstitution[1]{\renewcommand\tinstitution{#1}}
\newrobustcmd*\setdate[1]{\renewcommand\tdate{#1}}
\newrobustcmd*\setsupervisor[1]{\renewcommand\tsupervisor{#1}}
\newrobustcmd*\setcsupervisor[1]{\renewcommand\tcsupervisor{#1}}
\newrobustcmd*\setchairperson[1]{\renewcommand\tchairperson{#1}}
\newrobustcmd*\setcommittee[1]{\renewcommand\tcommittee{#1}}
\newrobustcmd*\setcoverimage[2][0.5]{
\renewcommand\tcoverimage{#2}
\renewcommand\tcoverimagewidth{#1}
}
\newrobustcmd*\setcoverbacktext[1]{\renewcommand\tcoverbacktext{#1}}
% Create the cover layout and attribute it to the makecover command
\newrobustcmd{\makecover}{
\pagenumbering{roman}
\setcounter{page}{0}
\begin{titlepage}
\includegraphics[viewport=9.5cm 11cm 0cm 0cm,scale=0.29]{IST_A_CMYK_POS}
\begin{center}
\vspace*{17mm}
\includegraphics[width=\tcoverimagewidth\linewidth]{\tcoverimage}
\par\vspace{\fill}
{\LARGE\bfseries \ttitle}
\par\vspace{10mm}
{\Large \tsubtitle}
\par\vspace{10mm}
{\Large\bfseries
\begin{tabular}{c c}
&\tauthor
\end{tabular}
}
\par\vspace{10mm}
\ifbool{@english}
{\large Thesis to obtain the Master of Science Degree in}
{\large Dissertação para obtenção do Grau de Mestre em}
\par\medskip
{\LARGE\bfseries \tdegree}
\par\vspace{10mm}
{\large\renewcommand\arraystretch{0.9}
\begin{tabular}{r l}
\ifbool{@english}{Supervisor:}{Orientador:} & \tsupervisor
\end{tabular}
}
\par\vspace{7mm}
{\large\bfseries \ifbool{@english}{Examination Committee}{Júri}}
\par\vspace{3mm}{\large\renewcommand\arraystretch{0.9}
\begin{tabular}{r l}
\ifbool{@english}
{Chairperson:}{Presidente:} & \tchairperson{} \\
\ifbool{@english}
{Supervisor:}{Orientador:} & \tcsupervisor{} \\
\ifbool{@english}
{Members of the Committee:}{Vogais:} & \tcommittee{}
\end{tabular}
}
\par\vspace{10mm}
{\large\bfseries \tdate{}}
\end{center}
\newpage
\thispagestyle{empty}
\vspace*{\fill}
\small\setstretch{1}\noindent
\begin{flushleft}
\textcolor{gray}{\tcoverbacktext}
\end{flushleft}
\cleardoublepage
\end{titlepage}
}
% Create the spine and attribute it to the makespine command
\newrobustcmd{\makespine}{
\newpage
\thispagestyle{empty}
\begin{tikzpicture}[remember picture, overlay]
\newlength{\spinewidth}\setlength\spinewidth{2.5cm}
\path (current page.north) coordinate (spinenorth) ++(-0.5\spinewidth,0) coordinate (spinenorthwest) ++(\spinewidth,0) coordinate (spinenortheast);
\path (current page.south) coordinate (spinesouth) ++(-0.5\spinewidth,0) coordinate (spinesouthwest) ++(\spinewidth,0) coordinate (spinesoutheast);
\path (spinenorth) -- coordinate (spinecenter) (spinesouth);
\path (spinesouth) ++(0,2cm) coordinate (logopos);
%
\path [draw, dashed, darkgray] (spinenorthwest) -- (spinenortheast) -- (spinesoutheast) -- (spinesouthwest) -- cycle;
\node [rotate = 90, anchor = west, inner sep = 0pt] at (logopos) {\includegraphics[trim = {172.4pt 202.7pt 172.6pt 201.4pt}, clip, height = 0.4\spinewidth]{graphics/IST_A_CMYK_POS.pdf}};
\node at (spinecenter) [rotate = 90, anchor = center, align = center, inner sep = 0pt] {\textbf{\large{\ttitle{}}}\\\tsubtitle{}\\\textbf{\tauthor{}}};
\end{tikzpicture}
}
% Define the dedication environment
\newenvironment{dedication}{
\newpage
\vspace*{40mm}
\setstretch{1.1}
\itshape
\begin{flushright}
}{
\end{flushright}
\cleardoublepage
}
% Define the acknowledgement environment
\newenvironment{acknowledgements}{
\newpage
\vspace*{30mm}
\ifbool{@english}
{ \section*{Acknowledgements} }
{ \section*{Agradecimentos} }
\noindent
}{
\cleardoublepage
}
% Define the abstract environment with an optional keyword argument
% Defined as tabstract to prevent confusion with the report class abstract environment
\newenvironment{tabstract}[1]{
\newpage
\newcommand*\abskey[1]{#1}
\vspace*{60mm}
\begin{center}
\ifbool{@english}
{ \section*{Abstract} }
{ \section*{Resumo} }
\end{center}
}{
\par\vspace{\fill}
\ifbool{@english}
{ {\noindent\large\textbf{Keywords:} \abskey{}} }
{ {\noindent\large\textbf{Palavras-Chave:} \abskey{}} }
\cleardoublepage
}
% Foreign language abstract environment
% Identical to tabstract except for the language definitions
\newenvironment{fabstract}[1]{
\newpage
\newcommand*\abskey[1]{#1}
\vspace*{60mm}
\ifbool{@english}{
\begingroup
\selectlanguage{portuguese}
\begin{center}
\section*{Resumo}
\end{center}
}{
\begingroup
\selectlanguage{english}
\begin{center}
\section*{Abstract}
\end{center}
}
}{
\par\vspace{\fill}
\ifbool{@english}{
{\noindent\large\textbf{Palavras-Chave:} \abskey{}}
\endgroup
\selectlanguage{english}
}{
{\noindent\large\textbf{Keywords:} \abskey{}}
\endgroup
\selectlanguage{portuguese}
}
\cleardoublepage
}
% Define the mainstart command to start the main part of the text
% Assists in switching from roman to arabic page numbering
\newrobustcmd\mainstart{\cleardoublepage\pagenumbering{arabic}}