-
Notifications
You must be signed in to change notification settings - Fork 0
/
thesis.cls
380 lines (334 loc) · 14.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
% ==================== %
% :: Diploma Thesis :: %
% ==================== %
% LaTeX class for diploma theses designed for the HIT department at TGM Vienna.
% Thanks to @chro and @mborko for the previous templates!
%
% @author Markus Reichl <markus@re1.at>
% @version 2018-03-15
% @url https://github.com/tgm-hit/diploma-thesis
%
% TODO: Set authors using multiple author commands / command options
% TODO: Add some thesis related info to the page headings
\ProvidesClass{thesis}
% ------------- %
% :: Options :: %
% ------------- %
\newif\ifen\enfalse % English language
\DeclareOption{en}{\entrue}
\newif\ifcolor\colortrue % Do not color links
\DeclareOption{nocolor}{\colorfalse}
\newif\iffonts\fontstrue % Default latex fonts
\DeclareOption{nofonts}{\fontsfalse}
\newif\iflogos\logostrue % Do not print logos on titlepage
\DeclareOption{nologos}{\logosfalse}
\newif\ifminted\mintedfalse % Minted
\DeclareOption{minted}{\mintedtrue}
\newif\ifnatbib\natbibfalse % NatBib
\DeclareOption{natbib}{\bibtrue\natbibtrue}
\newif\ifparskip\parskipfalse % Lineskip instead of indent after blank line
\DeclareOption{parskip}{\parskiptrue}
\newif\ifsans\sansfalse % Use sans serif fonts
\DeclareOption{sans}{\sanstrue}
% Pass options
\ProcessOptions \relax
% Load article class
\IfFileExists{crimson.sty}{
\LoadClass[a4paper,11pt]{book} % Crimson
}{ \LoadClass[a4paper,10pt]{book}} % Default
% -------------- %
% :: Packages :: %
% -------------- %
\iffonts
\ifsans \renewcommand*\familydefault{\sfdefault}
\else \IfFileExists{crimson.sty}{\RequirePackage{crimson}}{}\fi
\IfFileExists{inconsolate.sty}{\RequirePackage{inconsolata}}{}
\fi
\RequirePackage{geometry, a4wide}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{ccicons, csquotes, amssymb, mathtools}
\ifen\RequirePackage[ngerman, english]{babel}
\else\RequirePackage[english, ngerman]{babel}\fi
\RequirePackage{fancyhdr, float, multicol, multirow, titling}
\RequirePackage[marginal, norule, perpage]{footmisc}
\RequirePackage[dvipsnames]{xcolor}
\providecommand\phantomsection{}
\RequirePackage{hyperref, url, pageslts, nameref}
\RequirePackage{outlines, enumitem}
\RequirePackage{booktabs, tabularx}
\RequirePackage{listings} % Required by totalcount also without minted
\RequirePackage{graphicx, subcaption, pdfpages}
\RequirePackage[font=small]{caption}
\RequirePackage{accsupp} % [1]
\RequirePackage[acronym, xindy, nohypertypes={acronym,notation}]{glossaries}
\RequirePackage[figure,table,listing]{totalcount}
\RequirePackage{pgffor, xparse} % Easier creation of commands with arguments
\ifnatbib\RequirePackage{natbib} % Bibliography
\else\RequirePackage[backend=bibtex]{biblatex}\fi
\ifminted\RequirePackage[newfloat]{minted} % Listings
\else\RequirePackage{listing} % Already defined by minted itself
\RequirePackage{listingsutf8}\fi % UTF-8 Input support for listings
% ## Skip lines instead of indents after a blank line
\ifparskip\RequirePackage{parskip}\fi
% ---------------
% :: Variables ::
% ---------------
\definecolor{MyLightGray}{RGB}{252,252,252}
\definecolor{MyBlue}{RGB}{5,102,141}
\definecolor{MyGreen}{RGB}{0,168,150}
\definecolor{MyBrown}{RGB}{143,89,3}
\definecolor{MyOrange}{RGB}{213,111,30}
\newcommand\@mysubtitle{}
\newcommand\mysubtitle[1]{\renewcommand\@mysubtitle{#1}}
\newcommand\@myschool{Technologisches Gewerbemuseum}
\newcommand\myschool[1]{\renewcommand\@myschool{#1}}
\newcommand\@mydepartment{Höhere Technische Lehranstalt für Informationstechnologie}
\newcommand\mydepartment[1]{\renewcommand\@mydepartment{#1}}
\newcommand\@mydivision{}
\newcommand\mydivision[1]{\renewcommand\@mydivision{#1}}
\newcommand\@myteacher{}
\newcommand\myteacher[1]{\renewcommand\@myteacher{#1}}
\newcommand\@myyear{2017/2018}
\newcommand\myyear[1]{\renewcommand\@myyear{#1}}
\newcommand\@currentauthor{}
\newcommand\setauthor[1]{\renewcommand\@currentauthor{#1}}
\newcommand\resetauthor{\renewcommand\@currentauthor{\theauthors}}
% -------------------
% :: Configuration ::
% -------------------
% :: Listings ::
\ifminted
\floatplacement{listing}{H} % Override default listing float
\usemintedstyle{tango} % autumn, rainbow_dash, tango, trac
\setminted{ fontsize=\small,
linenos=true,
breakanywhere=true,
breaklines=true,
framesep=2mm,
tabsize=4}
% [1] Avoid copying line numbers on listings
\renewcommand\theFancyVerbLine{
\BeginAccSupp{method=escape,ActualText={}}
{\rmfamily\tiny\arabic{FancyVerbLine}}
\EndAccSupp{}
}
% Change listings name in for german language
\ifen\else\SetupFloatingEnvironment{listing}{
listname=Auflistungsverzeichnis,name=Auflistung
}\fi
\else % Lstlistings
\IfFileExists{.lst.tex}{\input{.lst}}{} % Load config if exists
\fi
% :: Hyperlinks ::
\ifcolor\hypersetup{breaklinks=true, colorlinks=true, % Color hyperlinks
linkcolor=MyBlue, urlcolor=MyBlue, citecolor=MyBlue}
\else\hypersetup{breaklinks=true, colorlinks=false, % Do not color hyperlinks
linkcolor=Black, urlcolor=Black, citecolor=Black, hidelinks=true}\fi
% :: Headers ::
\pagestyle{fancy}\fancyhf{}
\makeatletter
\fancyhead[L]{\small \thetitle}
\fancyhead[R]{\small \nouppercase{\leftmark}}
\fancyfoot[L]{\small \if\relax\@currentauthor\relax\theauthors\else\@currentauthor\fi}
\fancyfoot[R]{\small \thepage~/~{\lastpageref*{VeryLastPage}}}
\makeatother
\renewcommand{\footrulewidth}{\headrulewidth}
% Add glossary / bibliography entries if they exist
\IfFileExists{glossaries.tex}{\input{glossaries}\makeglossaries}{}
% CUSTOM: Adding different source files from all teammembers
\IfFileExists{sources/rfoster.bib}{\addbibresource{sources/rfoster}}{}
\IfFileExists{sources/mbeier.bib}{\addbibresource{sources/mbeier}}{}
\IfFileExists{sources/ldehner.bib}{\addbibresource{sources/ldehner}}{}
% Make empty book pages lose their headers and footers
% http://mirror.kumi.systems/ctan/macros/latex/contrib/fancyhdr/fancyhdr.pdf
\makeatletter
\def\cleardoublepage{
\clearpage\if@twoside\ifodd\c@page\else
\thispagestyle{empty}\hbox{}\newpage
\if@twocolumn\hbox{}\newpage\fi
\fi\fi
}
\makeatother
% :: Hacks ::
\raggedbottom % Stop book documentclass from fucking with paragraph spacing..
\setcounter{secnumdepth}{3} % Make \subsubsections have numbers too
\def\arraystretch{1.5} % Adjust table cell spacing
\floatplacement{table}{H} % Adjust default table float
\floatplacement{figure}{H} % Adjust default figure float
\renewcommand\thefootnote{\Roman{footnote}} % Roman footnotes
\newcolumntype{Y}{p{.5\textwidth}} % cell with 50% of text width for TabularX
% ------------
% :: Macros ::
% ------------
% :: Authors ::
% Save authors and author names to variables
\def\authors{}
\def\theauthors{}
% Check for any author
\newif\ifauthor\authorfalse
% Renew the \author command, usage is now \author{name}{class}{subject}
\renewcommand\author[3]{
\edef\authors{\authors #1;#2;#3*}
\edef\theauthors{\theauthors\ifauthor,~\fi#1}
\authortrue
}
% Provide commands for author display on the titlepage
\NewDocumentCommand\printauthor{mmm}{
\IfNoValueTF{#2}{}{ % TODO: Remove quickcheck #2 with xparse
\parbox[l]{\textwidth}{#3}\vspace{.25em}
\makebox[.4\textwidth][l]{#1\hfill#2}~\\\\
}
}
\NewDocumentCommand\splitauthor{>{\SplitArgument{2}{;}}m}{\printauthor#1}
\NewDocumentCommand\splitauthors{>{\SplitList{*}}m}{\ProcessList{#1}{\splitauthor}}
\NewDocumentCommand\makeauthors{}{\expandafter\splitauthors\expandafter{\authors}}
% :: Title ::
\makeatletter
\renewcommand\maketitle{
~\\ % Line fix
\begin{minipage}{3cm}
\iflogos\IfFileExists{images/logo-left.png}{
\includegraphics[width=3cm]{images/logo-left.png}}{}\fi
\end{minipage}
\hfill
\begin{minipage}{.58\textwidth}
~\\\centering
\if\relax\@myschool\relax\else {\Large\@myschool}\fi
\if\relax\@mydepartment\relax\else ~\\\vspace{.5em}{\@mydepartment} \fi
\if\relax\@mydivision\relax\else
~\\{Schwerpunkt~\@mydivision}\fi
\end{minipage}
\hfill
\begin{minipage}{3cm}
\iflogos\IfFileExists{images/logo-right.png}{
\includegraphics[width=3cm]{images/logo-right.png}}{}\fi
\end{minipage}
\begin{center}\rule{\textwidth}{.1mm}\end{center}
\vfill % Fill space between title header and project logo and headings
\begin{center}
\IfFileExists{images/logo.png}{
\includegraphics[height=5cm]{images/logo.png}
\vskip 2em}{} % Space between logo and headings if logo exists
{\Large\textbf{
\ifen Diploma Thesis \else Diplomarbeit \fi
}}~\\\vspace{2em}
{\Huge\textbf\thetitle}~\\\vspace{1.5em}
\if\relax\@mysubtitle\relax\else{\Large\@mysubtitle}\fi
\end{center}
\vfill % Fill space between headings and authors
~\\\makeauthors{}~\\ % Create list of authors
\makebox[\textwidth][l]{\if\relax\@myteacher\relax\else \textbf{Betreuer:}~\@myteacher\fi}
\makebox[\textwidth][l]{\if\relax\@myyear\relax\else Ausgeführt im Schuljahr~\@myyear\fi}
\begin{center}\rule{\textwidth}{.1mm}\end{center}
\makebox[\textwidth][l]{Abgabevermerk:}
\makebox[\textwidth][l]{\@date\hfill Übernommen von: \hspace{3cm}}
}\makeatother
% :: Statutory declaration ::
\newcommand\makedeclaration{
\ifen % Prints english version
\chapter*{Statutory declaration}
I declare that I have authored this thesis independently, that I have not used other than the declared sources and that I have explicitly marked all material which has been quoted either literally or by content from the used sources.
\else
\chapter*{Eidesstattliche Erklärung}
Ich erkläre an Eides statt, dass ich die vorliegende Arbeit selbstständig verfasst, andere als die angegebenen Quellen/Hilfsmittel nicht benutzt und die den benutzten Quellen wörtlich und inhaltlich entnommenen Stellen als solche kenntlich gemacht habe.
\fi % Print german version
\vspace{3em}~\\
\ifauthor\foreach \n in \theauthors{
\makebox[.4\textwidth][c]{\rule{.3\textwidth}{.1mm}}
\makebox[.6\textwidth][c]{\rule{.5\textwidth}{.1mm}}\vspace{.25em}~\\
\makebox[.4\textwidth][c]{\small \ifen{Location, Date}\else{Ort, Datum}\fi}
\makebox[.6\textwidth][c]{\small\n}\vspace{1em}\vspace{1em}~\\
}\fi
}
% :: Basic centered figure ::
% - usage: \makefig{path}{width}{caption}{label}
% TODO: Use options instead of parameters
\newcommand\makefig[4]{
\begin{figure}[H]
\centering
\includegraphics[#2]{#1}
\ifx\relax#3\relax\else\caption{#3}\fi
\ifx\relax#4\relax\else\label{#4}\fi
\end{figure}
}
% :: Math variable declaration
% - usage: \vardef{variable}{definition}
\newenvironment{vardef}{
\center\small % Make variables centered and small
\begin{tabular}{l l l}
}{\end{tabular} \normalsize \endcenter}
% Add variables to the vardef environment
\newcommand\addvardef[2]{{#1}&\dots&{#2}\\}
% :: Abstract ::
\newenvironment{abstract}[1][]{
\ifthenelse{\equal{#1}{english}}{
\selectlanguage{english}
\chapter*{Abstract}
}{ % German abstract by default
\selectlanguage{ngerman}
% Nomenklatur nach https://www.htl.at/htlat/diplom-und-abschlussarbeiten/diplomarbeiten
\chapter*{Kurzfassung}
}
}{ \ifen\selectlanguage{english}\else\selectlanguage{ngerman}\fi}
% :: Code environments ::
% Extra % is used as a linefix for the code interpreter
\ifminted % Minted goes here
\newcommand\setcode[1]{\setminted{#1}} % Code settings
\newenvironment{code}[2][]{ % Code environment
\VerbatimEnvironment%
\begin{minted}[#1]{#2}%
}{ \end{minted}}
\newcommand\codein{\mintinline} % Inline code (alias)
\newcommand\codeinline{\codein} % Alias for @kevsoft
\newcommand\inputcode{\inputminted} % Input code (alias)
\newcommand\codeline[3][]{\mint[#1]{#2}\relax#3\relax} % Single line of code
\else % Listings goes here
\newcommand\setcode[1]{\lstset{#1}} % Code settings
\lstnewenvironment{code}[2][]{\lstset{language={#2},#1}}{} % Code environment
\newcommand\codein[3][]{\lstinline[language=#2,#1]\relax#3\relax} % Inline code
\newcommand\codeinline{\codein} % Alias for @kevsoft
\newcommand\inputcode[3][]{\lstinputlisting[language=#2,#1]{\detokenize{#3}}} % Input code
\newcommand\codeline[3][]{\begin{flushleft}
\lstinline[language=#2,#1]\relax#3\relax % Single line of code
\end{flushleft}}
\fi
% :: Begin Document ::
% Add common commands at the beginning of the document
% TODO: Add options for title and declaration
\AtBeginDocument{
% Adjust geometry for the first page
\newgeometry{left=1in, right=1in, top=.75in, bottom=.75in}
\pagestyle{empty} % Do not show headers for the first few pages
\pagenumbering{arabic} % Required by pageslts
\maketitle % Titlepage
\restoregeometry % Restore geometry to default settings
\makedeclaration % Statutory declaration
}
% :: End Document ::
% Add common commands at the end of the document
\AtEndDocument{
% \printglossaries % doesnt work
% List used glossary entries
\renewcommand{\glossarysection}[2][]{}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Glossar}
\chapter*{Glossar}
\rhead{Glossar}
\printglossary
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Akronyme}
\chapter*{Akronyme}
\rhead{Akronyme}
\printacronyms
\rhead{Literaturverzeichnis}
\ifnatbib\bibliography{bibliography} % List bibliography entries with natbib
\else \ifen\printbibliography[heading=bibintoc]
\else\printbibliography[heading=bibintoc, title=Literaturverzeichnis]\fi\fi
\iftotalfigures\cleardoublepage\phantomsection\addcontentsline{toc}{chapter}{Abbildungsverzeichnis}\rhead{Abbildungsverzeichnis}\listoffigures\fi % Figures
\iftotaltables\cleardoublepage\phantomsection\addcontentsline{toc}{chapter}{Tabellenverzeichnis}\rhead{Tabellenverzeichnis}\listoftables\fi % Tables
\iftotallistings\cleardoublepage\phantomsection\addcontentsline{toc}{chapter}{Auflistungsverzeichnis}\rhead{Auflistungsverzeichnis}\listoflistings\fi % Listings
\IfFileExists{chapters/appendix.tex}{\include{chapters/appendix}}{}
}