forked from idfah/csuthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thesis.cls
605 lines (473 loc) · 17.7 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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colorado State University LaTeX Thesis Document Class
%
% by
% Elliott Forney
% 2017
%
% This is free and unencumbered software released into the public domain.
%
% Anyone is free to copy, modify, publish, use, compile, sell, or
% distribute this software, either in source code form or as a compiled
% binary, for any purpose, commercial or non-commercial, and by any
% means.
%
% In jurisdictions that recognize copyright laws, the author or authors
% of this software dedicate any and all copyright interest in the
% software to the public domain. We make this dedication for the benefit
% of the public at large and to the detriment of our heirs and
% successors. We intend this dedication to be an overt act of
% relinquishment in perpetuity of all present and future rights to this
% software under copyright law.
%
% 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 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document class definition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% provide a new LaTeX2e document class
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{thesis}[2017/06/13 Colorado State University Thesis]
% provide classoption to specify if this is an bachelor, master or
% doctor thesis/dissertation
\newif\ifCLASSOPTIONbachelor
\newif\ifCLASSOPTIONmaster
\newif\ifCLASSOPTIONdoctor
\DeclareOption{bachelor}{\CLASSOPTIONbachelortrue \CLASSOPTIONmasterfalse \CLASSOPTIONdoctorfalse}
\DeclareOption{master}{\CLASSOPTIONbachelorfalse \CLASSOPTIONmastertrue \CLASSOPTIONdoctorfalse}
\DeclareOption{doctor}{\CLASSOPTIONbachelorfalse \CLASSOPTIONmasterfalse \CLASSOPTIONdoctortrue}
% show frame around margins
\newif\ifCLASSOPTIONshowframe \CLASSOPTIONshowframefalse
\DeclareOption{showframe}{\CLASSOPTIONshowframetrue}
% disable features that are specific to pdf output
\newif\ifCLASSOPTIONpdf \CLASSOPTIONpdftrue
\DeclareOption{nopdf}{\CLASSOPTIONpdffalse}
% provide classoption for subfigure compatibility
% note that the subfig package should generally be used instead
% of subfigure, so this option shouldn't be necessary unless you insist
\newif\ifCLASSOPTIONsubfigure \CLASSOPTIONsubfigurefalse
\DeclareOption{subfigure}{\CLASSOPTIONsubfiguretrue}
% some default options for the book class
% note that we assume letter paper and 12pt font
\PassOptionsToClass{oneside,openany,letterpaper,12pt}{book}
% pass remaining options to book class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
% execute default options
\ExecuteOptions{master}
% process options
\ProcessOptions\relax
% book class is used as a base
\LoadClass{book}
% Fonts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use times font by default
\RequirePackage[T1]{fontenc}
\RequirePackage{times}
% Page formatting and layout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% configure page size and margins
\RequirePackage{geometry}
\geometry{verbose, letterpaper, heightrounded,
lmargin=1in, rmargin=1in, % 1in margins
tmargin=1in, bmargin=1in, footskip=0.5in}
% show frame around page margins if requested
\ifCLASSOPTIONshowframe
\geometry{showframe}
\fi
% use double spacing by default
\RequirePackage[doublespacing]{setspace}
% reduce topskip to ensure text is flush with top margin
% assumes 12pt font
\topskip=9pt
% provide an environment for creating landscape pages
% for big tables and figures
% this is kind of a hack for now but gets the job done
% any ideas for a better solution?
\ifCLASSOPTIONpdf
\RequirePackage{pdflscape}
\else
\RequirePackage{lscape}
\fi
\newenvironment{sidewayspage}{%
\newgeometry{lmargin=1in, rmargin=0.45in,
tmargin=1in, bmargin=1in}%
\begin{landscape}%
\thispagestyle{empty}%
}{%
\null%
\vfill%
\centerline{\normalsize\thepage}%
\end{landscape}%
\restoregeometry%
}
% Typesetting rules
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% discourage single lines of a paragraph from landing at the
% bottom or top of page, a.k.a, widows and orphans
% this configuration should prevent orphans and widows in all
% but the most pathological cases
\clubpenalty=10000 % penalty for breaking after first line of a paragraph
\widowpenalty=10000 % penalty for breaking before last line of a paragraph
\predisplaypenalty=500 % discourage single line before equations
\raggedbottom % be flexible with bottom margin
% indent first paragraphs
\let\@afterindentfalse\@afterindenttrue
\@afterindenttrue
% redefine raggedright command so that it doesn't
% break paragraph indentation
% modified from latex.ltx
\renewcommand{\raggedright}{%
\let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip%
\leftskip\z@skip}
% command to suppress indentation
\newcommand{\zeroindent}{\setlength{\parindent}{0in}}
% command to create centered environment with no
% indentation and without extra space above or below
\newenvironment{flatcenter}{\centering \zeroindent}{\par}
% Footnotes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% remove rule above footnote and places further down page
\RequirePackage[bottom]{footmisc}
% space between footnotes if there are multiple on one page
\setlength{\footnotesep}{1.5em}
% setup hrule above footnotes with little space between text
\def\footnoterule{\hrule \@width 2in}
% prevents footnote counter from resetting at new chapter
\RequirePackage{remreset}
\@removefromreset{footnote}{chapter}
% Page numbers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use plain page style with page number at bottom
\pagestyle{plain}
% Float (figures, tables, etc) formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% hook to add \centering to all float environments,
% e.g, tables and figures
\g@addto@macro\@floatboxreset\centering
% adjust spacing above and below floats
\setlength{\intextsep}{2em} % with text above and below
\setlength{\textfloatsep}{2em} % top/bottom of page with text above/below
\setlength{\floatsep}{1em} % between consecutive floats
\setlength{\@fptop}{0pt} % top of float only pages
\setlength{\@fpsep}{1em} % between on float only pages
\setlength{\@fpbot}{0em plus 1fil} % bottom of float only pages
% make captions use small font with bold label
\RequirePackage{caption}
\captionsetup{font=small,labelfont=bf}
% Table of contents formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use tocloft to customize table of contents, list of figures, etc
\ifCLASSOPTIONsubfigure
% needed subfigure for compatibility
% note that subfig should generally be used instead of subfigure
\RequirePackage[subfigure,titles]{tocloft}
\else
\RequirePackage[titles]{tocloft} % use tocloft package to modify toc
\fi
% indentation before chapters or sections
\setlength{\cftchapindent}{0in}
\setlength{\cftsecindent}{0.18in}
\setlength{\cftsubsecindent}{0.36in}
\setlength{\cftsubsubsecindent}{0.54in}
% space between margin and chap/sec titles
\setlength{\cftchapnumwidth}{1in}
\setlength{\cftsecnumwidth}{1in}
\setlength{\cftsubsecnumwidth}{1in}
\setlength{\cftsubsubsecnumwidth}{1in}
% chapter name in toc is "Chapter N"
\renewcommand{\cftchappresnum}{\chaptername\space}
% appendix name in toc is "Appendix A"
\g@addto@macro\appendix{%
\addtocontents{toc}{%
\protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
}%
}
% dots same for chapters and sections
\renewcommand{\cftchapdotsep}{\cftdotsep}
% dots not bold
\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}
% use normal fonts, not bold
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cftchapfont}{\normalfont}
% don't indent list of figures/tables
\setlength{\cftfigindent}{0pt}
\setlength{\cfttabindent}{0pt}
% create a table-of-contents entry for a new preliminary page
% we call it an unnumbered section so they aren't spaced and
% reverse the indent using hspace then make uppercase
\newcommand{\prelimtocentry}[1]{%
\phantomsection%
\addcontentsline{toc}{section}{\hspace{-\cftsecindent}\uppercase{#1}}%
}
% Chapter and section headings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% adjust spacing around chapter/section headings
\def\@abovechap{-36pt} % above chapter headings
\def\@belowchap{12pt} % below chapter headings
\def\@abovesec{12pt} % above section headings
\def\@belowsec{2pt} % below section headings
% note: abovesec does not affect section headings at top of page!
% font sizes for chapter, section and subsection headings
\newcommand{\@chapsize}{\LARGE}
\newcommand{\@secsize}{\Large}
\newcommand{\@subsecsize}{\large}
\newcommand{\@subsubsecsize}{\normalsize}
% remove space above chapter headings
% i would prefer to do this using the titlesec package
% but titlesec is a little loose with the top margins
% this code is modified from book.cls
\def\@makechapterhead#1{%
\vspace*{\@abovechap}
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\@chapsize\bfseries \@chapapp\space \thechapter
\par\nobreak
\else
\@chapsize\bfseries \@chapapp\space \thechapter
\fi
\fi
\interlinepenalty\@M
\@chapsize\bfseries #1\par\nobreak
\vskip \@belowchap
}}
\def\@makeschapterhead#1{%
\vspace*{\@abovechap}
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\@chapsize\bfseries #1 \par\nobreak
\vskip \@belowchap
}}
% end modified from book class
% redefine section commands to change size and spacing
% could be done with titlesec but that would break margins
\renewcommand\section{\@startsection {section}{1}{0pt}%
{\@abovesec}{\@belowsec}{\normalfont\@secsize\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{0pt}%
{\@abovesec}{\@belowsec}{\normalfont\@subsecsize\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{0pt}%
{\@abovesec}{\@belowsec}{\normalfont\@subsubsecsize\bfseries}}
% Title Page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% command to the document title
\def\@title{Colorado State University \LaTeX{} Thesis Template}
\renewcommand{\title}[1]{\protected@edef\@title{#1}}
% command to set author's name
\def\@author{John M. Doe}
\renewcommand{\author}[1]{\protected@edef\@author{#1}}
% command to set author's email
\def\@email{[email protected]}
\newcommand{\email}[1]{\protected@edef\@email{#1}}
% command to set department name
\def\@department{Department of Computer Science}
\newcommand{\department}[1]{\protected@edef\@department{#1}}
% command to set defense semester
\def\@semester{Fall 20\_\_}
\newcommand{\semester}[1]{\protected@edef\@semester{#1}}
% command to set advisor's name
\def\@advisor{Advisor's Name}
\newcommand{\advisor}[1]{\protected@edef\@advisor{#1}}
% command to set (optional) co-advisor's name
\newcommand{\coadvisor}[1]{\protected@edef\@coadvisor{#1}}
% command to add committee members
% this tacks new members onto current value of \@committee
\def\@committee{}
\newcommand{\committee}[1]{\protected@edef\@committee{%
\unexpanded\expandafter{\@committee}{\noexpand\hspace{0.25in} #1 \par}}}
% command to make title page
\renewcommand{\maketitle}{%
\begin{flatcenter}
% doctorate is dissertation, otherwise its a thesis
\ifCLASSOPTIONdoctor
DISSERTATION
\else
THESIS
\fi
\vspace{3em}
% title in all caps
{\MakeUppercase{\@title} \par}
\vspace{\fill}
Submitted by
\@author
\@department
\vspace{\fill}
In partial fulfillment of the requirements
% for bachelor, master or doctor
\ifCLASSOPTIONbachelor
For the Degree of Bachelor of Science
\fi
\ifCLASSOPTIONmaster
For the Degree of Master of Science
\fi
\ifCLASSOPTIONdoctor
For the Degree of Doctor of Philosophy
\fi
Colorado State University
Fort Collins, Colorado
\@semester
\end{flatcenter}
\vspace{\fill}
{\singlespace \zeroindent
\ifCLASSOPTIONbachelor
Committee:
\fi
\ifCLASSOPTIONmaster
Master's Committee:
\fi
\ifCLASSOPTIONdoctor
Doctoral Committee:
\fi
\vspace{1em}
\hspace{0.25in} Advisor: \@advisor \par
% unpack committee members
\ifx\@coadvisor\undefined \else
\hspace{0.25in} Co-Advisor: \@coadvisor \par
\fi
\vspace{1em}
\@committee
}
\thispagestyle{empty} % no page number here
\newpage % start new page
}
% Copyright
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% default copyright
\def\@mycopyright{Copyright by \@author \\ All Rights Reserved}
% command to set copyright
\newcommand{\mycopyright}[1]{\protected@edef\@mycopyright{#1}}
% command to make copyright page
\newcommand{\makemycopyright}{%
\vspace*{\fill}
\begin{flatcenter}
\@mycopyright
\end{flatcenter}
\vspace{\fill}
% copyright page has no page number...
% literally, no page number at all, SMH
\newcounter{@temppage} % store page counter so we can reset it later
\setcounter{@temppage}{\value{page}}
\thispagestyle{empty} % disable page number display
\pagenumbering{gobble} % disable page number counter
\newpage % start next page
\pagenumbering{roman} % reset page numbering to roman
\setcounter{page}{\value{@temppage}} % reset page number counter
}
% Abstract
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% default abstract
\def\@abstract{Abstract goes here.}
% command to set abstract
\newcommand{\abstract}[1]{\protected@edef\@abstract{#1}}
% command to make abstract page
\newcommand{\makeabstract}{%
% add to table of contents
\prelimtocentry{Abstract}
\begin{flatcenter}
ABSTRACT
\vspace{3em}
\MakeUppercase{\@title}
\vspace{3em}
\end{flatcenter}
\@abstract \par
\newpage
}
% Acknowledgements
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% default acknowledgements
\def\@acknowledgements{Acknowledgements go here.}
% command to set acknowledgements
\newcommand{\acknowledgements}[1]{\protected@edef\@acknowledgements{#1}}
% acknowledgements page
\newcommand{\makeacknowledgements}{%
% add to table of contents
\prelimtocentry{Acknowledgements}
\begin{flatcenter}
ACKNOWLEDGEMENTS
\vspace{3em}
\end{flatcenter}
\@acknowledgements \par
\newpage
}
% Table of Contents
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% command to create table of contents
\renewcommand{\tableofcontents}{%
\begin{flatcenter}
TABLE OF CONTENTS
\vspace{3em}
\end{flatcenter}
% insert table of contents
{\singlespace \@starttoc{toc}}
\newpage
}
% List of Tables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% command to make list of tables
\renewcommand{\listoftables}{%
% add to table of contents
\prelimtocentry{List of Tables}
\begin{flatcenter}
LIST OF TABLES
\vspace{3em}
\end{flatcenter}
\vspace{-26pt}
% insert list of tables
{\singlespace \@starttoc{lot}}
\newpage
}
% List of Figures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% command to make list of figures
\renewcommand{\listoffigures}{%
% add to table of contents
\prelimtocentry{List of Figures}
\begin{flatcenter}
LIST OF FIGURES
\vspace{3em}
\end{flatcenter}
\vspace{-26pt}
% insert list of figures
{\singlespace \@starttoc{lof}}
\newpage
}
% Body
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \frontmatter \mainmatter \backmatter and \appendix commands come from the book class
% hack to allow appendix after the bibliography by resetting to mainmatter
% yuck but the guidelines insist the appendix comes after bibliography
\g@addto@macro\appendix\@mainmattertrue
% Bibliography
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% left-align bibliography entries by filling right of the label number
\renewcommand{\@biblabel}[1]{[#1]\hfill}
% bibliography environment with flush left margin,
% appropriate toc entry, and our penalty values
% modified from book.cls
\renewenvironment{thebibliography}[1]{%
% set up unnumbered chapter and add to table of contents
\chapter*{\bibname}%
\phantomsection%
\addcontentsline{toc}{chapter}{\bibname}%
\@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}%
% create list of bibliography entries
\list{\@biblabel{\@arabic\c@enumiv}}%
{\settowidth\labelwidth{\@biblabel{#1}}%
\leftmargin\labelwidth
\advance\leftmargin\labelsep
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty
\renewcommand\theenumiv{\@arabic\c@enumiv}}%
\sloppy % :revents hbox overfull but looks nicer without it
\sfcode`\.\@m%
}
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist}
% end modified from book.cls