-
Notifications
You must be signed in to change notification settings - Fork 4
/
thesis.cls
499 lines (435 loc) · 15.4 KB
/
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
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
% !TEX encoding = UTF-8 Unicode
% vim: tw=78:ts=2:sw=2:et:fdm=marker:wrap
%%
%% This is file `thesis.cls',
%%
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}[2000/06/01]
\ProvidesClass{thesis}
[2012/06/12 Document class for Arcada thesis]
%% Preamble {{{
%% Load packages
\LoadClass[a4paper,12pt]{article}
\RequirePackage{latexsym}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage{pslatex} % Use Times
\RequirePackage[swedish,finnish,english]{babel}
\RequirePackage{geometry}
\RequirePackage{graphicx}
\RequirePackage{eso-pic}
\RequirePackage{color}
\RequirePackage{tabularx}
\RequirePackage{booktabs}
\RequirePackage{array}
\RequirePackage{xifthen}
\RequirePackage{caption} % Position captions
\RequirePackage{changepage} % As we cant rely on latest geometry package.
\RequirePackage{lastpage} % Get page count
\RequirePackage{setspace} % Line spacing
\RequirePackage{titlesec} % Customize section titles
\RequirePackage{subfigure} % @TODO deprecate
\RequirePackage[titles,subfigure]{tocloft} % Customize ToC
\RequirePackage[parfill]{parskip} %
\RequirePackage[]{natbib} % Bibliography
\RequirePackage{hyperref} % Hyperlinks
\RequirePackage{ulem} % Underlined, remember to reset emph back to normal
% As we need to calculate the width of the localized word `table` as this is
% used as an offset in the LoT. Same issue for the LoF.
\newlength{\figurelength}
\newlength{\tablelength}
\ifx\template\undefined
\newcommand{\template}{template}
\PackageWarning{thesis}{Using default thesis path, you should define it.}
\fi
\DeclareOption{finnish}{%
\def\LANGUAGE{\sFinnish}
\setlength{\figurelength}{\widthof{Figuuri~99.~}}
\setlength{\tablelength}{\widthof{Taulukko~99.~}}
% This gets called at begin{document} by bibtex
\main@language{finnish}%
}
\DeclareOption{swedish}{%
\def\LANGUAGE{\sSwedish}%
\setlength{\figurelength}{\widthof{Figur~99.~}}%
\setlength{\tablelength}{\widthof{Tabell~99.~}}%
\main@language{swedish}%
}
\DeclareOption{english}{%
\def\LANGUAGE{\sEnglish}%
\setlength{\figurelength}{\widthof{Figuuri~99.~}}%
\setlength{\tablelength}{\widthof{Taulukko~99.~}}%
\main@language{english}%
}
\newif\ifisListing
\DeclareOption{listing}{\isListingtrue}
\newif\ifisSyntax
\DeclareOption{syntax}{\isSyntaxtrue}
% Pass stuff through to article but remember if we did so we can use arcadas
% defaults otherwise.
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ExecuteOptions{swedish}
\ProcessOptions\relax
% Look for images in a couple of places
\graphicspath{{\template/}{./images/}}
% Define a pagecount command which will be used in the bibtex bst to determine
% the order of p. and the pagecount (i.e., s. 123 in Swedish, 123 p. in
% English)
\newcommand{\pagecount}[2]{#1 #2}
% }}}
%% Listings & Syntax etc. {{{
\ifisListing
\input{\template/helpers/lststyles}
\fi
\ifisSyntax
\input{\template/helpers/syntax}
\fi
%% }}}
%% Hyperlinks {{{
\hypersetup{
colorlinks=true,
urlcolor=black,
filecolor=black,
citecolor=black,
linkcolor=black,
linktoc=all
}
% Reset emph back to normal due to ulem package.
\normalem
% Underline URLs
\useunder{\uline}{\ulined}{}
\makeatletter
\def\url@ulstyle{\def\UrlFont{\ulined}}
\makeatother
\urlstyle{ul}
%% }}}
%% Layout and Typography {{{
\geometry{%
% Top and bottom margin uses 2.5cm.
top=2.5cm,
bottom=5.4cm, % 2.5cm + 0.9cm.
% Left and right margin used 3cm.
left=3cm,
right=3cm,
% The footer has a height of 0.9cm.
nohead,
footskip=0.1cm}
% No paragraph indentation.
\setlength{\parindent}{0pt}
% One empty.
\setlength{\parskip}{\baselineskip}
% Line height 1.5.
\setstretch{1.5}
% Use plain page numbers in the footer.
\pagestyle{plain}
% Use arabic numerals for page numbers.
\pagenumbering{arabic}
% Level 1 titles use uppercased 17pt bold instead pf 14pt as the specification
% states.
\titleformat{\section}{%
\Large\bf\fontfamily{phv}\selectfont}{\thesection}{1em}{\MakeUppercase}
% Level 2 titles use 17pt bold instead pf 14pt as the specification states.
\titleformat{\subsection}{%
\Large\bf\fontfamily{phv}\selectfont}{\thesubsection}{1em}{}
% Level 3 titles use 14pt bold instead pf 12pt as the specification states.
\titleformat{\subsubsection}{%
\large\bf\fontfamily{phv}\selectfont}{\thesubsubsection}{1em}{}
% Titles has 24pt spacing above and 12pt spacing beneath. However as
% paragraphs should use a \blanklineskip beneath and 0pt above, we need to
% tailor this a bit by looking at the example provided.
\titlespacing*{\section}{0pt}{10pt}{0pt}
\titlespacing*{\subsection}{0pt}{10pt}{0pt}
\titlespacing*{\subsubsection}{0pt}{10pt}{0pt}
% Caption styles arent specified further than that they should be italic.
% We define our own style which is aligned to the left with a size of 10pt
% ftp://ctan.tug.org/ctan/macros/latex2e/contrib/caption/caption-eng.pdf
\captionsetup[table]{%
position=top, labelsep=period,%
singlelinecheck=false, justification=justified,% align left
textfont=it, labelfont=it, font=footnotesize}
\captionsetup[figure]{%
position=bottom, labelsep=period,%
singlelinecheck=false, justification=justified,% align left
textfont=it, labelfont=it, font=footnotesize}
% Citations
% Use 10pt and a 1.5 lineheight even though the specification tells us to use
% 1.
\renewenvironment{quote}{%
\list{}{%
\onehalfspacing\footnotesize\leftmargin0.5cm}
\item\relax}{%
\endlist}
% Remove comma from inline citations.
\bibpunct[ ]{(}{)}{,}{a}{}{,}
%% }}}
%% Colors {{{
% Used for the background
%Cover pre autumn 2014
%\definecolor{orange}{RGB} {247,149,70}
%\definecolor{orangeSaturated}{RGB} {202,162,130}
%\definecolor{gray}{RGB} {241,241,241}
%\definecolor{white}{RGB} {255,255,255}
% Cover post autumn 2014
\definecolor{coverBlack}{RGB} {0,0,0}
%% }}}
%% Localization {{{
\addto\captionsenglish{%
\def\sDegreeThesis {Degree Thesis}%
\def\sDegreeProgramme {Degree Programme:}%
\def\sIdentification {Identification number:}%
\def\sAuthor {Author:}%
\def\sTitle {Title:}%
\def\sSupervisor {Supervisor (Arcada):}%
\def\sCommissionedBy {Commissioned by:}%
\def\sAbstract {Abstract:}%
\def\sKeywords {Keywords:}%
\def\sPageCount {Number of pages:}%
\def\sLanguage {Language:}%
\def\sDateAcceptance {Date of acceptance:}%
\def\sFinnish {Finnish}%
\def\sEnglish {English}%
\def\sSwedish {Swedish}%
\def\sFigure {Figure}%
\def\sTable {Table}%
\renewcommand\listfigurename {Figures}%
\renewcommand\listtablename {Tables}%
% Swap order of p. and the number in english.
\renewcommand{\pagecount}[2] {#2 #1}%
}
\addto\captionsswedish{%
\def\sDegreeThesis {Examensarbete}%
\def\sDegreeProgramme {Utbildningsprogram:}%
\def\sIdentification {Identifikationsnummer:}%
\def\sAuthor {F\"orfattare:}%
\def\sTitle {Arbetets namn:}%
\def\sSupervisor {Handledare (Arcada):}%
\def\sCommissionedBy {Uppdragsgivare:}%
\def\sAbstract {Sammandrag:}%
\def\sKeywords {Nyckelord:}%
\def\sPageCount {Sidantal:}%
\def\sLanguage {Spr\aa k:}%
\def\sDateAcceptance {Datum f\"or godk\"annande:}%
\def\sFinnish {Finska}%
\def\sEnglish {Engelska}%
\def\sSwedish {Svenska}%
\def\sFigure {Figur}%
\def\sTable {Tabell}%
\renewcommand\listfigurename {Figurer}%
\renewcommand\listtablename {Tabeller}%
\renewcommand\refname {K\"allor}%
\renewcommand{\pagecount}[2] {#2 #1}%
}
\addto\captionsfinnish{%
\def\sDegreeThesis {Opinn\"ayte}%
\def\sDegreeProgramme {Koulutusohjelma:}%
\def\sIdentification {Tunnistenumero:}%
\def\sAuthor {Tekij\"a:}%
\def\sTitle {Ty\"on nimi:}%
\def\sSupervisor {Ty\"on ohjaaja (Arcada):}%
\def\sCommissionedBy {Toimeksiantaja:}%
\def\sAbstract {Tiivistelm\"a:}%
\def\sKeywords {Avainsanat:}%
\def\sPageCount {Sivum\"a\"ar\"a:}%
\def\sLanguage {Kieli:}%
\def\sDateAcceptance {Hyv\"aksymisp\"aiv\"am\"a\"ar\"a:}%
\def\sFinnish {Suomi}%
\def\sEnglish {Englanti}%
\def\sSwedish {Ruotsi}%
\def\sFigure {Figuuri}%
\def\sTable {Taulukko}%
\renewcommand\listfigurename {Figuurit}%
\renewcommand\listtablename {Taulukkot}%
\renewcommand{\pagecount}[2] {#1 #2}%
}
%% }}}
%% Background bar {{{
\newcommand\cbox[2]{%
\colorbox{#1}{\parbox[b][\paperheight]{#2}{\vfill\hfill}}%
}
\newcommand\backgroundbar{
\put(0,0){%
\cbox{coverBlack}{1.3cm}%
%Pre autumn 2014
% \cbox{orange}{1.3cm}%
% \cbox{gray}{1pt}%
% \hspace{-4pt}%
% \cbox{orangeSaturated}{1pt}%
% \hspace{-6pt}%
% \cbox{white}{5pt}%
}
}
% }}}
%% Title {{{
% As the ubuntu repository doesn't contain the latest version of geometry which
% has the command \newgeometry, we need to do an ugly hack which requires the
% title page to be printed first
\addtolength\textheight{3cm}
\renewcommand{\maketitle}{%
\AddToShipoutPicture*{\backgroundbar}
\begin{adjustwidth}{-0.5cm}{}\begin{spacing}{2.0}
\vspace*{-1.75cm}
\includegraphics[width=4.72cm]{logo.pdf}
\vspace*{6.35cm}
% Title of the document is 20pt bold
{\LARGE\bf\fontfamily{phv}\selectfont \TITLE}
% Subheading of the document is 17pt
{\Large \SUBHEADING}
\vspace{1.7cm}
\begin{large} % 14pt
\AUTHOR
\vspace*{\fill}
\begin{adjustwidth}{}{-2.5cm}
\begin{flushright}
\onehalfspacing
\LEVEL\\
\PROGRAMME\\
\DATE\\
\end{flushright}%
\end{adjustwidth}%
\end{large}
\end{spacing}\end{adjustwidth}
\addtolength\textheight{-3cm} % Reset to original textheight
}
%% }}}
%% Tables (tocloft) {{{
% Don't show page numbering on the table pages
\addtocontents{toc}{\protect\thispagestyle{empty}}
\addtocontents{lof}{\protect\thispagestyle{empty}}
\addtocontents{lot}{\protect\thispagestyle{empty}}
% LoF entries are numbered with `Figure ~Number.`
\setlength{\cftfigindent}{0cm} % Remove indentation
\setlength{\cftfignumwidth}{\figurelength}
\renewcommand*\cftfigpresnum{\sFigure~}
\renewcommand{\cftfigaftersnum}{.~}
% LoF entries are numbered with `Table ~Number.`
\setlength{\cfttabindent}{0cm} % Remove indentation
\setlength{\cfttabnumwidth}{\tablelength}
\renewcommand*\cfttabpresnum{\sTable~}
\renewcommand{\cfttabaftersnum}{.~}
% Change space between numbering and ToC titles
\makeatletter
\renewcommand*\l@section{\@dottedtocline{3}{0cm}{1cm}}
\renewcommand*\l@subsection{\@dottedtocline{3}{0.39cm}{1.2cm}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{0.78cm}{1.5cm}}
\makeatother
% Style section titles
\makeatletter
\let\stdl@section\l@section
\renewcommand*{\l@section}[2]{%
\doublespacing%
\stdl@section{%
\bf\fontsize{12pt}{6pt}\fontfamily{phv}\selectfont{#1}}{%
\bf\fontsize{12pt}{6pt}\fontfamily{phv}\selectfont{#2}}%
}
% Style subsection titles
\let\stdl@subsection\l@subsection
\renewcommand*{\l@subsection}[2]{%
\singlespace%
\stdl@subsection{%
\fontsize{11pt}{0pt}\fontfamily{phv}\selectfont{#1}}{%
\fontsize{11pt}{0pt}\fontfamily{phv}\selectfont{#2}}%
}
\let\stdl@subsubsection\l@subsubsection
\renewcommand*{\l@subsubsection}[2]{%
\stdl@subsubsection{%
\it\fontsize{11pt}{0pt}\fontfamily{phv}\selectfont{#1}}{%
\it\fontsize{11pt}{0pt}\fontfamily{phv}\selectfont{#2}}%
}
\makeatother
% Append section titles with dots
\renewcommand{\cftsecdotsep}{\cftdotsep}
% Override main commands
\makeatletter
\let\stdtableofcontents\tableofcontents
\renewcommand*{\tableofcontents}{
\stdtableofcontents
\newpage
}
\makeatother
%% }}}
%% Abstract {{{
\newcommand{\coljoin}[1]{\multicolumn{2}{ !{\VRule[2pt]} l !{\VRule[2pt]} }{#1}}
\newcommand{\thickrule}{\specialrule{2pt}{0pt}{0pt}}
\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}
\newcommand{\vthickrule}{\vrule width 2pt}
\renewenvironment{abstract}[1]{%
\expandafter\otherlanguage\expandafter{#1}%
\pagestyle{empty}
\newpage
\normalsize
\singlespacing
\renewcommand{\arraystretch}{1.1}
\begin{tabularx}{\textwidth}{ !{\vthickrule} p{5cm} | X !{\vthickrule} }
\thickrule
\coljoin{\MakeUppercase\LEVEL} \\ \hline
\coljoin{\UNIVERSITY} \\ \hline
\coljoin{} \\ \hline
\sDegreeProgramme & \PROGRAMME \\ \hline
\coljoin{} \\ \hline
\sIdentification & \IDENTIFICATION \\ \hline
\sAuthor & \AUTHOR \\ \hline
\sTitle & \TITLE \\ \hline
\sSupervisor & \SUPERVISOR \\ \hline
\coljoin{} \\ \hline
\sCommissionedBy & \COMMISSIONEDBY \\ \hline
\coljoin{} \\ \thickrule
\coljoin{\sAbstract} \\ %todo do this in a nicer way
\end{tabularx}%
\vskip -16pt%
\tabularx{\textwidth}{ !{\vthickrule} X !{\vthickrule} }%
}{%
\endtabularx
\vskip -16pt%
\begin{tabularx}{\textwidth}{ !{\vthickrule} p{5cm} | X !{\vthickrule} }
\thickrule
\sKeywords & \KEYWORDS \\ \hline
\sPageCount & \PAGECOUNT \\ \hline
\sLanguage & \LANGUAGE \\ \hline
\sDateAcceptance & \DATEACCEPTANCE \\ \thickrule
\end{tabularx}
\endotherlanguage
\pagestyle{empty}
\newpage
}
%% }}}
%% Bibliography {{{
% Because of a compatability issue between natbib and older versions of makebst
% we need to renew these commands not to trigger the following error:
% ! Extra }, or forgotten \endgroup.
% \par ...m \@noitemerr {\@@par }\fi \else {\@@par }
% @see http://www.latex-community.org/forum/viewtopic.php?f=19&t=10955
% \renewcommand{\bibAnnoteFile}[1]{%
% \IfFileExists{#1}{\begin{quotation}\noindent\texts c{Key:} #1\\
% \textsc{Annotation:}\ \input{#1}\end{quotation}}{}}
%
% \renewcommand{\bibAnnote}[2]{%
% \begin{quotation}\noindent\textsc{Key:} #1\\
% \textsc{Annotation:}\ #2\end{quotation}}
\bibliographystyle{\template/bibliography/bibliography}
\setlength{\bibsep}{\baselineskip}
\let\stdbibliography\bibliography
\renewcommand*{\bibliography}[1]{
\newpage
\begingroup
\singlespacing
\raggedright
\stdbibliography{#1}
\endgroup
\addcontentsline{toc}{section}{\refname}
}
\makeatother
%% }}}