-
Notifications
You must be signed in to change notification settings - Fork 0
/
thesis.sty
executable file
·386 lines (324 loc) · 12.1 KB
/
thesis.sty
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
% MIT License
%
% Copyright (c) 2024 Yue Gao
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in all
% copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.
%=============================================================================
% The dissertation should have double-spacing main text
%=============================================================================
% Notes:
% - Use `\DoubleSpacing` because the `memoir` class ignores `setspace`
% - See https://tex.stackexchange.com/questions/651036/
%=============================================================================
\DoubleSpacing
%=============================================================================
% Make the font and style better
%=============================================================================
% Notes:
% - https://texblog.net/latex-archive/latex-general/pdflatex-microtype/
%=============================================================================
% Avoid bad boxes (only if you are using a large margin)
%\RequirePackage[protrusion=true,expansion=true]{microtype}
% Avoid ugly "Type 3" fonts
\usepackage[LY1]{fontenc}
%=============================================================================
% Headers and Page Numbers
%=============================================================================
% Notes:
% - It is required to NOT use page headers (except for page numbers)
% - It is required that page numbers must be in the upper right-hand corner
%=============================================================================
% Removes all marks in the header defined by the `memoir` class
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}
\renewcommand{\bibmark}{}
\renewcommand{\tocmark}{}
\renewcommand{\lofmark}{}
\renewcommand{\lotmark}{}
% Move page number to top-right in memoir
% See https://tex.stackexchange.com/questions/178792/
\copypagestyle{chapter}{plain}
\makeoddfoot{chapter}{}{}{}
\makeevenfoot{chapter}{}{}{}
\makeoddhead{chapter}{}{}{\thepage} % Odd: top-right
\makeevenhead{chapter}{\thepage}{}{} % Even: top-left
%=============================================================================
% Title Page (User Settings)
%=============================================================================
% Notes:
% - Here creates the commands that let users specify their information
% - The settings will be stored in macro variables
%=============================================================================
% These commands store user settings to be used later
\makeatletter
\newcommand\department[1]{\gdef\@department{#1}}
\newcommand\doctype[1]{\gdef\@doctype{#1}}
\newcommand\degree[1]{\gdef\@degree{#1}}
\newcommand\deposityear[1]{\gdef\@deposityear{#1}}
\newcommand\defensedate[1]{\gdef\@defensedate{#1}}
\newcommand{\@committee}{}
\newcommand{\committeemember}[1]{
\g@addto@macro\@committee{\item[] #1}%
}
\makeatother
% Helper macro to check if a variable is defined
\newcommand{\checkdefined}[2]{
\ifdef{#1}{}{
\PackageError{thesis}%
{Variable \string#2\space not defined.}
{You must define \string#1 using \string#2{value} before \string\begin{document}.}
}
}
% Check if variables are defined
\makeatletter
\AtBeginDocument{
\checkdefined{\@department}{\department}
\checkdefined{\@doctype}{\doctype}
\checkdefined{\@deposityear}{\deposityear}
\checkdefined{\@defensedate}{\defensedate}
}
\makeatother
% Provide common default values
\doctype{A dissertation}
\degree{Doctor of Philosophy}
%=============================================================================
% Title Page (Layout)
%=============================================================================
% Notes:
% - It is required to use a minimum of 1″ margin on all four sides
% - Otherwise, there is no strict format requirements
%=============================================================================
% Use one-half spacing only for the title page to gain some space
\newenvironment{titlepage}{%
\newpage
\thispagestyle{empty}
\OnehalfSpacing
}{
\DoubleSpacing
}
% Define margin variables
\newlength{\titlepagemedskip}
\setlength{\titlepagemedskip}{0.15in}
\newlength{\titlepagebigskip}
\setlength{\titlepagebigskip}{0.55in}
\newlength{\committeeindent}
\setlength{\committeeindent}{2em}
\newlength{\committeetop}
\setlength{\committeetop}{3\titlepagebigskip}
% Define the committee member layout
% We print the committee member list using `enumerate` to better control the margin
\RequirePackage{enumitem}
\makeatletter
\newcommand{\printcommittee}{
\if\relax\detokenize\expandafter{\@committee}\relax
\PackageError{thesis}%
{No committee members defined. Please use \protect\committeemember\space to add members}
{The \protect\printcommittee\space command requires at least one \protect\committeemember\space to be defined}
\else
\begin{enumerate}[noitemsep,topsep=0pt,leftmargin=\committeeindent]
\@committee
\end{enumerate}
\fi
}
\makeatother
% Define the final title page layout
\RequirePackage{geometry}
\makeatletter
\renewcommand{\maketitle}{%
% Use 1-in margin only for the titlepage to gain more space
\newgeometry{left=1in,right=1in,bottom=1in,top=1in}
% Use `titlepage` environment
\begin{titlepage}
\begin{center}
\textbf{\expandafter\expandafter{\@title}} \\[\titlepagebigskip]
by \\[\titlepagemedskip]
\@author \\[\titlepagebigskip]
\@doctype{} submitted in partial fulfillment of \\
the requirements for the degree of \\[\titlepagebigskip]
\@degree \\[\titlepagemedskip]
(\@department) \\[\titlepagebigskip]
at the \\[\titlepagemedskip]
UNIVERSITY OF WISCONSIN--MADISON \\[\titlepagemedskip]
\@deposityear \\[\committeetop]
\end{center}
Date of final oral examination: \@defensedate \\[\titlepagemedskip]
The dissertation is approved by the following members of the Final Oral Committee:
\printcommittee
\end{titlepage}
% Recover normal page layout
\restoregeometry
% The titlepage is always the first page
\setcounter{page}{1}
}
\makeatother
%=============================================================================
% Table of Contents
%=============================================================================
% Notes:
% - The `memior` class uses the `tocloft` package to customize TOC styles
%=============================================================================
\RequirePackage{tocloft}
% Table of Contents (toc)
\newcounter{tocpage}
\renewcommand{\printtoctitle}[1]{\chapter*{#1}}
\renewcommand{\tocheadstart}{}
\renewcommand{\aftertoctitle}{}
% --- Chapter level font
\renewcommand{\cftchapterfont}{\bfseries}
\renewcommand{\cftchapterpagefont}{\bfseries}
\renewcommand{\cftchapterpresnum}{\bfseries}
\renewcommand{\cftchapterleader}{\hfill}
\renewcommand{\cftchapterafterpnum}{}
% --- Section level font
\renewcommand{\cftsectionfont}{\normalfont}
\renewcommand{\cftsectionleader}{\cftdotfill{\cftfiguredotsep}}
\renewcommand{\cftsectionafterpnum}{}
% --- Subsection level font
\renewcommand{\cftsubsectionfont}{\normalfont}
\renewcommand{\cftsubsectionleader}{\hfill}
\renewcommand{\cftsubsectionafterpnum}{}
% List of Figures (lof)
\newcounter{lofpage}
\renewcommand{\printloftitle}[1]{\chapter*{#1}}
\renewcommand{\lofheadstart}{}
\renewcommand{\afterloftitle}{}
% --- Figure level font
\renewcommand{\cftfigurefont}{\normalfont}
\renewcommand{\cftfigureleader}{\cftdotfill{\cftfiguredotsep}}
\renewcommand{\cftfigureafterpnum}{}
% List of Tables (lot)
\newcounter{lotpage}
\renewcommand{\printlottitle}[1]{\chapter*{#1}}
\renewcommand{\lotheadstart}{}
\renewcommand{\afterlottitle}{}
% --- Table level font
\renewcommand{\cfttablefont}{\normalfont}
\renewcommand{\cfttableleader}{\cftdotfill{\cftfiguredotsep}}
\renewcommand{\cfttableafterpnum}{}
%=============================================================================
% Copyright Page
%=============================================================================
% Notes:
% - Start a new page with no page number
% - Place the copyright text centered at the bottom
%=============================================================================
\makeatletter
\newcommand\copyrightpage{
\newpage
\thispagestyle{empty}
\addtocounter{page}{-1}
\null\vfill
\begin{center}
\copyright\ Copyright by \@author\ \@deposityear \\
All Rights Reserved
\end{center}
\clearpage
}
\makeatother
%=============================================================================
% Dedication
%=============================================================================
% Notes:
% - Start a new page
% - Place the dedication text at the center of the page
%=============================================================================
\makeatletter
% This command stores the dedication
\newcommand\dedication[1]{\gdef\@dedication{#1}}
% This command prints out the dedication page
\newcommand\printdedication{
\ifdef{\@dedication}{
\newpage
\null\vfill
\begin{center}
\textit{\@dedication}
\end{center}
\null\vfill
\clearpage
}{}
}
\makeatother
%=============================================================================
% Acknowledgements
%=============================================================================
% Notes:
% - Start a new page with no page number
% - Otherwise, following the normal chapter layout
%=============================================================================
\makeatletter
% This command stores the acknowledgements
\newcommand\acknowledgements[1]{\gdef\@acknowledgements{#1}}
% This command prints out the acknowledgements page
\newcommand\printacknowledgements{
\ifdef{\@acknowledgements}{
\chapter*{Acknowledgements}
\@acknowledgements
}{}
}
\makeatother
%=============================================================================
% Abstract
%=============================================================================
% Notes:
% - Start a chapter for abstract with no chapter number
% - Add the abstract to table of contents
%=============================================================================
\makeatletter
% This command stores the abstract
\renewcommand\abstract[1]{\gdef\@abstract{#1}}
% This command prints out the abstract page
\newcommand\printabstract{
\ifdef{\@abstract}{
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\@abstract
}{}
}
\makeatother
%=============================================================================
% Frontmatter
%=============================================================================
% Notes:
% - Roman page numbers
%=============================================================================
\newcommand\makefrontmatter{
% Convert to roman page number
\pagenumbering{roman}
% Copyright page
\copyrightpage
% Dedication
\printdedication
% Acknowledgements
\printacknowledgements
\clearpage
% Table of Contents
\tableofcontents
\clearpage
% List of Tables
\listoftables
\clearpage
% List of Figures
\listoffigures
\clearpage
% Abstract
\printabstract
\clearpage
% Convert back to arabic page number
\pagenumbering{arabic}
}