-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtudelft-report.cls
211 lines (175 loc) · 8.96 KB
/
tudelft-report.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
% This template aims to simplify and improve the (Xe)LaTeX template provided
% by the TU Delft. Original template by TU Delft. Rewritten template by Daan
% Zwaneveld (https://dzwaneveld.github.io)
%
% This template by Daan Zwaneveld is licensed under CC BY-NC 4.0. To view a
% copy of this license, visit https://creativecommons.org/licenses/by-nc/4.0/.
% No attribution is required in PDF outputs created using this template.
%% ----------------------------------------------------------------------
%% Setting up the class, main packages and basic definitions
%% ----------------------------------------------------------------------
%% Class is based on the default book class and options will be passed
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tudelft-report}[05-09-2024 v1.7.1 TU Delft Report Class]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions\relax
\LoadClass[10pt,oneside]{book}
%% Main packages in the document --- Some are imported later in the class file
\RequirePackage{mathtools} % Mathematical tools to use with amsmath
\RequirePackage{amssymb} % Extended symbol collection
\RequirePackage{siunitx} % Comprehensive (SI) units package
\RequirePackage{tabularx} % Tabulars with adjustable-width columns
\RequirePackage{booktabs} % Publication quality tables
\RequirePackage{longtable} % Allow tables to flow over page boundaries
\RequirePackage{multirow} % Create tabular cells spanning multiple rows
\RequirePackage{graphicx} % Enhanced support for images
\RequirePackage{float} % Improved interface for floating objects
\RequirePackage[labelfont=bf,justification=centering,footnotesize]{caption} % Captions
\RequirePackage{subcaption} % Support for sub-captions
\RequirePackage{pdfpages} % Include PDF documents
\RequirePackage[pdfusetitle,hidelinks]{hyperref} % Extensive support for hypertext
\RequirePackage[noabbrev]{cleveref} % Intelligent cross-referencing
\RequirePackage{xcolor} % Driver-independent color extensions
\RequirePackage{tikz} % Create PostScript and PDF graphics
\RequirePackage{xspace} % Define commands that appear not to eat spaces
\RequirePackage{microtype} % Refinements towards typographical perfection
\RequirePackage{geometry} % Customize document dimensions
\RequirePackage{titlesec} % Select alternative section titles
\RequirePackage{titletoc} % Alternative headings for toc
\RequirePackage{fancyhdr} % Control of page headers and footers
\RequirePackage{enumitem} % Control layout of itemize, enumerate, description
\RequirePackage{etoolbox} % Toolbox of programming facilities
\RequirePackage{iftex} % Adds if-else statements to support multiple compilers
\RequirePackage{datetime} % Change format of \today
%% Establish commands for the subtitle, subject, affiliation, cover image and table of authors
\newcommand*{\subtitle}[1]{\def\@subtitle{#1}}
\newcommand*{\subject}[1]{\def\@subject{#1}}
\newcommand*{\affiliation}[1]{\def\@affiliation{#1}}
\newcommand*{\coverimage}[1]{\def\@coverimage{#1}}
\newcommand*{\covertable}[1]{\def\@covertable{#1}}
%% Scale the margins to be slightly smaller than default (.7)
\geometry{a4paper,hscale=0.75,vscale=0.8}
%% ----------------------------------------------------------------------
%% Setting up the fonts
%% ----------------------------------------------------------------------
\ifPDFTeX
%% With pdfLaTeX, use Paletino as the main font and Roboto Slab as title fonts
\RequirePackage[T1]{fontenc} % Select T1 font encoding
\RequirePackage{newpxtext} % Palatino-like font...
\RequirePackage{newpxmath} % ...with support for mathematics
\newcommand{\titlestyle}{\fontfamily{RobotoSlab-TLF}\fontseries{light}\selectfont}
\newcommand{\largetitlestyle}{\fontfamily{RobotoSlab-TLF}\fontseries{thin}\selectfont}
\else
%% If XeLaTeX or LuaLaTeX is set as the compiler, the TU Delft house style fonts are used (see https://www.tudelft.nl/huisstijl/bouwstenen/typografie).
\RequirePackage[no-math]{fontspec} % Advanced font selection
%% Use Arial as the main font and Roboto Slab as title fonts
\setmainfont{Arial}
\setmathsf{Arial}
\setmathtt{Arial}
\newfontfamily\titlestyle{Roboto Slab Light}
\newfontfamily\largetitlestyle{Roboto Slab Thin}
\fi
%% ----------------------------------------------------------------------
%% Formatting the titles and table of contents
%% ----------------------------------------------------------------------
%% Format the chapter titles and spacing
\titleformat{\chapter}[display]
{\flushright}
{\fontsize{96}{96}\selectfont\largetitlestyle\thechapter}
{0pt}
{\Huge\titlestyle}
\titlespacing*{\chapter}{0pt}{0pt}{2\baselineskip}
%% Format the section titles and spacing
\titleformat{\section}
{\Large\titlestyle\bfseries}
{\thesection.}
{5pt}
{}
\titlespacing*{\section}{0pt}{\baselineskip}{0pt}
%% Format the subsections titles and spacing
\titleformat{\subsection}
{\large\titlestyle\bfseries}
{\thesubsection.}
{5pt}
{}
\titlespacing*{\subsection}{0pt}{\baselineskip}{0pt}
%% Format the subsubsections titles and spacing
\titleformat{\subsubsection}
{\titlestyle\bfseries}
{\thesubsubsection.}
{5pt}
{}
\titlespacing*{\subsubsection}{0pt}{\bigskipamount}{0pt}
%% Reduce the vertical white space between chapters in the table of contents
\dottedcontents{chapter}[1.5em]{\vspace{0.5\baselineskip}\bfseries}{1.5em}{0pt}
%% ----------------------------------------------------------------------
%% Formatting the header and footer
%% ----------------------------------------------------------------------
%% Format the header and footer of 'plain' pages
\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[C]{\titlestyle\thepage}}
%% Format the header and footer of 'fancy' pages (based on twoside option)
\if@twoside
\fancyhf{}
\fancyhead[LE,RO]{\titlestyle\thepage}
\fancyhead[RE]{\titlestyle\nouppercase{\leftmark}}
\fancyhead[LO]{\titlestyle\nouppercase{\rightmark}}
\RequirePackage{emptypage} % Remove header and footer on empty pages
\else
\fancyhf{}
\fancyhead[R]{\titlestyle\thepage}
\fancyhead[L]{\titlestyle\nouppercase{\rightmark}}
\fi
\pagestyle{fancy} % Set the package defaults and the additional changes as the style
%% ----------------------------------------------------------------------
%% Setting up the \makecover command for the cover page
%% ----------------------------------------------------------------------
\newcommand*{\makecover}{
%% Use the Tikz library positioning and clear the page header and footer
\usetikzlibrary{positioning}
\thispagestyle{empty}
%% Construct the cover page with Tikz
\begin{tikzpicture}[overlay,remember picture]
%% Add the cover image
\node[above=0,inner sep=0] at (current page.south) {%
\includegraphics[width=\paperwidth]{\@coverimage}};
%% Add the affiliation on the left
\node[rotate=90,below right=40mm and 3mm] at (current page.west) {%
\ifdefvoid{\@affiliation}{}{\color{white}\titlestyle\@affiliation}};
%% Add the logo in the bottom left
\node[above right=10mm] at (current page.south west) {%
\includegraphics[width=0.35\linewidth]{figures/logo-white.pdf}};
%% Add the banner with the title, subtitle, subject and author(s)
\node[below=2cm,fill=black!85,minimum width={\paperwidth},inner ysep=25pt,opacity=0.6,text opacity=1] at (current page.north) {%
\begin{minipage}{0.9\paperwidth}
%% Format and add the title
\color{title}\raggedright\largetitlestyle\fontsize{50}{50}\selectfont%
\@title \\[0.5ex]
%% Format and add (optional) subtitle and subject
\color{white}\titlestyle\fontsize{22}{22}\selectfont%
\ifdefvoid{\@subtitle}{}{\@subtitle \\[2.5ex]}%
\ifdefvoid{\@subject}{}{\@subject \\[0.5ex]}
%% Format and add author or table of authors
\largetitlestyle\fontsize{24}{24}\selectfont%
\ifdefvoid{\@covertable}{\@author}{\@covertable}
\end{minipage}};
\end{tikzpicture}
\newpage
}
%% ----------------------------------------------------------------------
%% Setting up listings
%% ----------------------------------------------------------------------
\RequirePackage{listings} % Typeset source code listings
\lstset{
basicstyle=\ttfamily\footnotesize, % Style of the font that is used for the code
backgroundcolor=\color{gray!10}, % Background color
keywordstyle=\color{red!75!black}, % Keyword style
stringstyle=\color{green!40!black}, % String style
commentstyle=\color{blue!30!black}, % Comment style
numbers=left, % Add line numbers on the left side
numbersep=5pt, % Decrease distance between line numbers and code
numberstyle=\tiny, % Line number style
breaklines=true, % Line break automatically
}