-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuscegthesis.cls
259 lines (220 loc) · 8.38 KB
/
nuscegthesis.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
% nuscegthesis.cls
% LaTeX class for typesetting a thesis for Computer Engineering undergraduates
% at the National University of Singapore (NUS)
% Author: Kabir Khandpur
%
% The most recent version can be found here:
% https://github.com/kabir-plod/nuscegthesis/blob/master/nuscegthesis.cls
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{nuscegthesis}[2018/12/14 v0.1 National University of Singapore Computer Engineering Undergraduate Thesis Class]
% ****************************************
% * OPTIONS *
% ****************************************
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions\relax
\LoadClass{report}
% ****************************************
% * PACKAGES *
% ****************************************
% To change margins temporarily, use the \changemargin macro defined below
\RequirePackage[a4paper,left=4cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\RequirePackage{setspace} % easy switching between single/double spacing
\RequirePackage{titlesec} % format titles
\RequirePackage{parskip} % remove indentation at start of paragraphs
\RequirePackage{tabularx,ragged2e} % table formatting
\RequirePackage[sorting=none]{biblatex} % number citations in order of appearance
\addbibresource{references.bib}
\RequirePackage{tocbibind} % automatically include list of figures/tables in toc
\RequirePackage[final]{listings} % code formatting
\RequirePackage{subcaption} % subfigures
\RequirePackage{hyperref} % import hyperref last
% ****************************************
% * CONFIG *
% ****************************************
\doublespacing % double spacing
\pagestyle{plain} % page number at bottom centre
\setlength{\parskip}{2ex} % blank line between paragraphs
% Centered bold uppercase chapter titles
\titleformat{\chapter}[display]
{\normalfont\Large\bfseries\centering}
{\thechapter}
{0em}
{\MakeUppercase}
% Chapter number and name on separate lines
\titlespacing*{\chapter}
{0em}
{-50pt}
{2.5ex}
% Column type for tabularx with line breaks in-cell
\newcolumntype{C}{>{\Centering\arraybackslash}X} % centered "X" column
\newcolumntype{L}{>{\Left\arraybackslash}X} % left-aligned "X" column
% Change font for lstlisting code
\lstset{basicstyle=\ttfamily,breaklines=true}
% JavaScript code formatting with lstlisting
\lstdefinelanguage{JavaScript}{
keywords={break, case, catch, continue, debugger, default, delete, do, else, finally, for, function, if, in, instanceof, new, return, switch, this, throw, try, typeof, var, void, while, with},
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]",
sensitive=true
}
% ****************************************
% * USER MACROS *
% ****************************************
\newcommand{\code}[1]{\texttt{#1}} % print text as code
% ****************************************
% * FRONT MATTER *
% ****************************************
% DECLARATIONS
%
% These macros are used to declare arguments needed for the
% construction of the front matter.
% The full (unabbreviated) name of the degree
\def\degree#1{\gdef\@degree{#1}}
% The name of your thesis department (eg. Electrical and Computer Engineering)
\def\department#1{\gdef\@department{#1}}
% The academic year in which the project was undertaken (eg. 2018/2019)
\def\academicyear#1{\gdef\@academicyear{#1}}
% The ID of your project
\def\projectid#1{\gdef\@projectid{#1}}
% The name of your supervisor
\def\supervisor#1{\gdef\@supervisor{#1}}
% The deliverables of your project
\def\deliverables#1{\gdef\@deliverables{#1}}
\def\deliverablestwo#1{\gdef\@deliverablestwo{#1}}
\def\deliverablesthree#1{\gdef\@deliverablesthree{#1}}
% \maketitle outputs the complete title page. It requires all the
% above macros.
% Temporarily change margins to centre text
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist
% Set the block letters that will be used in the cover and title pages
\def\blocklt#1{\textbf{\MakeUppercase{#1}}}
\def\blockltit#1{\textit{\textbf{\MakeUppercase{#1}}}}
% TITLE (COVER) PAGE
\def\maketitle{
\thispagestyle{empty}
\begin{changemargin}{-1cm}{0cm}
\begin{singlespace}
\begin{center}
\blockltit{\@title}\par
\vfill
Submitted by\\
\@author\\~\\
Department of \@department\par
\vfill
In partial fulfillment of the\\
requirements for the Degree of\\
\@degree\\
National University of Singapore\par
\end{center}
\end{singlespace}
\end{changemargin}
\pagebreak
}
% (SECONDARY) TITLE PAGE
\newcommand\secondarytitlepage{
\thispagestyle{empty}
\begin{changemargin}{-1cm}{0cm}
\begin{center}
B.Eng Dissertation\par
\vspace{8em}
\blocklt{\@title}\par
\vspace{8em}
By\\\
\@author\\\
National University of Singapore\\
\@academicyear\par
\vfill
\end{center}
\begin{flushleft}
\begin{singlespace}
Project ID: \@projectid\\
Project Supervisor: \@supervisor\\~\\
Deliverables:\\
\hspace{4em}{\@deliverables}\\
\ifdefined \deliverablestwo
\\ \hspace{4em}{\@deliverablestwo}
\ifdefined \deliverablesthree
\\ \hspace{4em}{\@deliverablesthree}
\fi
\fi
\par
\end{singlespace}
\end{flushleft}
\end{changemargin}
\pagebreak
}
% ************ ENVIRONMENTS ************
% ABSTRACT
\renewcommand\abstractname{ABSTRACT}
\def\abstract{
\phantomsection\addcontentsline{toc}{chapter}{\abstractname}
\begin{center}{
{\blocklt{\large \bfseries \abstractname}}\par
}
\end{center}
}
\def\endabstract{\par\vfil\newpage}
% ACKNOWLEDGMENTS
\newcommand\acknowledgename{ACKNOWLEDGMENTS}
\def\acknowledgments{
\phantomsection\addcontentsline{toc}{chapter}{\acknowledgename}
\begin{center}{
{\blocklt{\large \bfseries \acknowledgename}}\par
}
\end{center}
}
\def\endacknowledgments{\par\vfil\newpage}
% FRONTMATTER
% The FRONTMATTER environment makes sure that page numbering is set
% correctly (roman, lower-case, starting at 1) for the front matter
% starting from the abstract. It also resets page-numbering for
% the remainder of the thesis (arabic, starting at 1).
\newenvironment{frontmatter}
{\setcounter{page}{1}\renewcommand{\thepage}{\roman{page}}}
{\newpage\renewcommand{\thepage}{\arabic{page}}\setcounter{page}{1}}
% ************ TABLE OF CONTENTS ************
% Capitalize some frontmatter
\renewcommand{\listtablename}{LIST OF TABLES}
\renewcommand{\listfigurename}{LIST OF FIGURES}
% Capitalize and italicize chapter titles. Prefix chapter number with 'CHAPTER'
\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\protect CHAPTER \numberline{\thechapter}\texorpdfstring{\textit{\MakeUppercase{#1}}}{#1}}%
\else
\addcontentsline{toc}{chapter}{\texorpdfstring{\textit{\MakeUppercase{#1}}}{#1}}%
\fi
\else
\addcontentsline{toc}{chapter}{\texorpdfstring{\textit{\MakeUppercase{#1}}}{#1}}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\makeatother
% Redefinition of ToC command to get single spacing
\makeatletter
\renewcommand\tableofcontents{%
\begin{spacing}{1.5}
\null\hfill\textbf{\Large\MakeUppercase\contentsname}\hfill\null\par
\@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
\@starttoc{toc}%
\end{spacing}
}
\makeatother