-
Notifications
You must be signed in to change notification settings - Fork 26
/
ezthesis.cls
250 lines (217 loc) · 6.83 KB
/
ezthesis.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
%% ezthesis class for LaTeX2e.
%%
%% A custom thesis class
%% by Juan Antonio Navarro Perez
%% http://navarroj.com/latex
%% ezlatex@navarroj.com
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ezthesis}[2007/08/08 A custom thesis class]
%% switches
\newif\if@spanish\@spanishfalse
\newif\if@draft\@draftfalse
\newif\if@bibfix\@bibfixtrue
\newif\if@fancyhdr\@fancyhdrtrue
\newif\if@colors\@colorstrue
\newif\if@graphicx\@graphicxtrue
\newif\if@natbib\@natbibtrue
\newif\if@bibnumbers\@bibnumbersfalse
\def\PassLayoutOptions#1{%
\PassOptionsToClass{#1}{report}
\PassOptionsToPackage{#1}{geometry}}
%% class options
\DeclareOption{draft}{%
\@drafttrue\PassOptionsToClass{draft}{report}
\PassOptionsToClass{draft}{graphicx}}
\DeclareOption{draftmarks}{\@drafttrue\PassOptionsToClass{draft}{report}}
\DeclareOption{spanish}{\@spanishtrue}
\DeclareOption{final}{\@draftfalse}
\DeclareOption{letterpaper}{\PassLayoutOptions{letterpaper}}
\DeclareOption{a4paper}{\PassLayoutOptions{a4paper}}
\DeclareOption{twoside}{\PassLayoutOptions{twoside}}
\DeclareOption{oneside}{%
\PassOptionsToClass{oneside}{report}%
\PassOptionsToPackage{twoside=false}{geometry}}
\DeclareOption{singlespace}{\gdef\select@spacing{\singlespacing}}
\DeclareOption{onehalfspace}{\gdef\select@spacing{\onehalfspacing}}
\DeclareOption{doublespace}{\gdef\select@spacing{\doublespacing}}
\DeclareOption{10pt}{\gdef\select@fontsz{\PassOptionsToClass{10pt}{report}}}
\DeclareOption{11pt}{\gdef\select@fontsz{\PassOptionsToClass{11pt}{report}}}
\DeclareOption{12pt}{\gdef\select@fontsz{\PassOptionsToClass{12pt}{report}}}
\DeclareOption{numbers}{\@bibnumberstrue}
\DeclareOption{authoryear}{\@bibnumbersfalse}
\DeclareOption{nobibtoc}{\@bibfixfalse}
\DeclareOption{nofancyhdr}{\@fancyhdrfalse}
\DeclareOption{nocolors}{\@colorsfalse}
\DeclareOption{nographicx}{\@graphicxfalse}
\DeclareOption{nonatbib}{\@natbibfalse}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ExecuteOptions{final,twoside,letterpaper,onehalfspace,12pt,authoryear}
\ProcessOptions\relax
\select@fontsz
\LoadClass{report}
%% spanish
\if@spanish
\RequirePackage[activeacute,spanish]{babel}
\fi
%% fields
\def\author#1{\gdef\insertauthor{#1}\gdef\@author{#1}}
\def\title#1{\gdef\inserttitle{#1}\gdef\@title{#1}}
\def\supervisor#1{\gdef\insertsupervisor{#1}}
\def\institution#1{\gdef\insertinstitution{#1}}
\def\degree#1{\gdef\insertdegree{#1}}
\def\faculty#1{\gdef\insertfaculty{#1}}
\def\department#1{\gdef\insertdepartment{#1}}
\def\submitdate#1{\gdef\insertsubmitdate{#1}}
% some defaults and labels
\if@spanish
\author{Falta nombre de autor}
\title{Falta t\'itulo de la tesis}
\degree{Doctorado}
\supervisor{Falta nombre del supervisor}
\institution{Universidad de Alg\'un Sitio}
\faculty{Facultad de Ingenier\'ia y Ciencias}
\department{Escuela de C\'omputo}
\def\draftlabel{BORRADOR}
\else
\author{Author name missing}
\title{Thesis title missing}
\degree{Doctor of Philosophy}
\supervisor{Supervisor name missing}
\institution{The University of Somewhere}
\faculty{Faculty of Engineering and Physical Sciences}
\department{School of Computer Science}
\def\draftlabel{DRAFT}
\fi
\submitdate{\number\the\year}
%% time and date
\newcount\hours \newcount\minutes
\def\SetTime{\hours=\time
\global\divide\hours by 60
\minutes=\hours
\multiply\minutes by 60
\advance\minutes by-\time
\global\multiply\minutes by-1 }
\SetTime
\def\shortdate{\@arabic\day/\@arabic\month/\@arabic\year}
\def\shorttime{\number\hours:\ifnum\minutes<10 0\fi\number\minutes\ hrs}
\if@draft
\def\draftmark{\draftlabel: \shortdate\ -- \shorttime}
\else
\def\draftmark{}
\fi
%% spacing
\RequirePackage{setspace}
\select@spacing
%% margins
\RequirePackage[
top = 40mm, bottom = 33mm,
outer = 25mm, inner = 40mm,
headsep = 10mm, headheight = 15pt,
marginparwidth = 15mm ]{geometry}
%% page styles
\if@fancyhdr
\RequirePackage{fancyhdr}
\if@twoside
\fancyhf{}
\fancyhead[RE]{\itshape\nouppercase\leftmark}
\fancyhead[LO]{\itshape\nouppercase\rightmark}
\fancyhead[LE,RO]{\itshape\thepage}
\fancyfoot[C]{\draftmark}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[LE,RO]{\itshape\thepage}
\fancyfoot[RE,LO]{\draftmark}}
\else
\fancyhf{}
\fancyhead[L]{\itshape\nouppercase\leftmark}
\fancyhead[R]{\itshape\thepage}
\fancyfoot[C]{\draftmark}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[R]{\itshape\thepage}
\fancyfoot[L]{\draftmark}}
\fi
\fancypagestyle{empty}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[C]{\draftmark}}
% setting page style should be done *after* geometry
\AtBeginDocument{\pagestyle{fancy}}
\else
\AtBeginDocument{\pagestyle{headings}}
\fi
\pagenumbering{arabic}
%% sectioning commands
\def\prefacesection#1{\clearpage\phantomsection
\addcontentsline{toc}{chapter}{#1}\chapter*{#1}\markboth{#1}{}}
%% Bibliography - natbib
\if@natbib
\if@bibnumbers
\RequirePackage[sort&compress,square,numbers]{natbib}
\else
\RequirePackage[sort&compress,round,authoryear]{natbib}
\fi
\if@spanish
\bibliographystyle{ezspanish}
\else
\bibliographystyle{plainnat}
\fi
\let\cite\citep
\fi
%% bibliography fix - makes bibliography appear
%% in table of contents, and makes it work nice
%% with hyperref
\def\bibliographyfix{%
\let\old@bibliography\bibliography
\def\bibliography{%
\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{\bibname}%
\old@bibliography}}
\if@bibfix
\AtBeginDocument{\bibliographyfix}
\fi
%% title page building blocks
\renewenvironment{titlepage}%
{\let\ez@blockfill\relax
\thispagestyle{empty}\centering\null\vskip1in}
{\vskip.5in\newpage}
\newcommand{\TitleBlock}[2][\ez@blockfill]{#1{#2\par}\let\ez@blockfill\vfill}
%% Graphics and colors
\if@graphicx
\RequirePackage{graphicx}
\fi
\if@colors
\RequirePackage{xcolor}
\definecolor{dark-red}{rgb}{0.4,0.15,0.15}
\definecolor{dark-blue}{rgb}{0.15,0.15,0.4}
\definecolor{medium-blue}{rgb}{0,0,0.5}
\fi
% Linking and pdf options
\let\phantomsection\@empty
\def\hyperlinking{%
\providecommand\theHalgorithm{\thealgorithm}
\providecommand\theHdefinition{\thedefinition}
\providecommand\theHexample{\theexample}
\providecommand\theHlemma{\thelemma}
\providecommand\theHproposition{\theproposition}
\providecommand\theHcorollary{\thecorollary}
\RequirePackage[final,breaklinks,bookmarks]{hyperref}
% properties of pdf file
\hypersetup{%
pdftitle={\inserttitle},pdfauthor={\insertauthor},
pdfsubject={\insertdegree\ Thesis, \insertdepartment}}
% color links
\if@colors
\hypersetup{%
colorlinks,linkcolor={dark-red},citecolor={dark-blue},
urlcolor={medium-blue}}
\fi
\renewcommand{\chapterautorefname}{Chapter}
\renewcommand{\sectionautorefname}{Section}
\renewcommand{\subsectionautorefname}{Section}
\renewcommand{\subsubsectionautorefname}{Section}
\RequirePackage[all]{hypcap}
}
\endinput