summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/uowthesis/UoWthesis.cls
blob: e2d779ca02320340956ed9cf8e88127d64f0f876 (plain)
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
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
%% UoWthesis.cls
%%   Document class to use with LaTeX 2e.
%% Copyright (C) 2007 Lei Ye
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `author-maintained'.
% 
% This work consists of the file UoWthesis.cls
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% This document class to use with LaTeX2e is built on the standard 
%%   report class for preparation of PhD and other higher degree 
%%   research theses in compliance with the specifications of UoW 
%%   theses in the "Guidelines for Preparation and Submission of  
%%   Higher Degree Research Theses" (March 2006), by Research Student 
%%   Centre, Research & Innovation Division, UoW (the "Guidelines"). 
%%   However, this work is of no official status. It is created and 
%%   made available in the hope that it would be useful.
%%
%%   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% REVISION HISTORY:
%%   
%% v1.0: 30/03/2007 (Lei Ye)
%%     - Initial version
%% v1.0a: 26/05/2007 (Lei Ye)
%%     - Bug fix: added space "\ " to avoid "no line here to end"
%%                error caused by the absence of \degreeHeld in
%%                \maketitle
%% 
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% USAGE:  \documentclass{UoWthesis}
%%         \documentclass[...options...]{UoWthesis}
%%
%%                       (Only to be used in this LaTeX2e native mode)
%%
%% The default settings produce a PhD dissertation (12pt font, 
%%   single-sided, double-spaced, hyper-linked)
%%
%% Thesis Class Options:
%%   * Degrees
%% 		   phd/master/other       (Default: phd)
%%         (master and other in fact are the same)
%%   * Filfulment requirement
%% 		   full/partial           (Default: full for phd            )
%%                              (         partial for master/other)
%%   * Line spacing for body text: 
%%       doublespacing/onehalfspacing 
%%                              (Default: doublespacing)
%%   * Hypertext in PDF
%%       nohyper/hyper          (Default: hyper)
%%   * Copyright Page
%%       copyright              (Default: null for no copyright page)
%%
%% LaTeX2e Document Class Options:
%%    Acceptable options pertaining to the 
%%      requirements of the "Guidelines"
%%
%%   * Font Size: 
%%      12/11/10 pt            (Default: 12pt - altered from report)
%%   * Printing Sides:
%%      oneside/twoside        (Default: oneside)
%%   * Page Openning:
%%      openany/openright      (Default: openany for oneside 
%%                                              - altered from report)
%%                             (         openright for twoside 
%%                                              - altered from report)
%%
%% Thesis Class Micros and Commands (Preamble only):
%%    \degree{...}             (Required for master/other. Default: 
%%                              Master of Computer Science - Research)
%%                             (Not used for phd)
%%       Specify the name of the degree
%%    \unit{...}               (Required. Default: School of Computer
%%                                   Science and Software Engineering)
%%       Specify the name of the academic unit.
%%    \faculty{...}            (Required. Default: Faculty of 
%%                                                        Informatics)
%%       Specify the name of the faculty.
%%    \degreeHeld{...}         (Optional. Default: null)
%%       Specify the degrees held, that will appear under your name 
%%         on the title page
%%    \submissionDate{...}{...}{...}
%%                             (Required. Default: The 1st Fools' Day)
%%       Specify the date of graduation
%%    \keywords{...}           (Required. Default: null)
%%       Keywords to appear on the Abstract page
%%    \dedication{...}         (Optional. Default: null)
%%       Recipients to appear on the Dedication page
%% 
%%    \dedicationtrue          (Optional)
%%       Turn on the dedication page
%%    \noListOfTables          (Optional)
%%       Turn off the List of Tables
%%    \noListOfFigures         (Optional)
%%       Turn off the List of Fifures
%%
%% Thesis Class Environments
%%    \begin{abstract} ... end{abstract}
%%                             (Required)
%%       Produce the abstract page
%%    \begin{acknowledgements} ... end{acknowledgements}
%%                             (Everybody has one)
%%       Produce the acknowledgements page
%%
%% The following class and packages are loaded:
%%
%%   Any customisation should be done through them if possible, 
%%     direct access to TeX is discouraged to maintain compatibility.
%%     
%%   Class users can use options and commands from these packages  
%%     to alter the document design to suit specific needs.
%%
%%     graphicx                         %   Manaul: http://www.ctan.org/tex-archive/macros/latex/required/graphics/grfguide.pdf
%%     fancyhdr                         % Required instalation with MikTeX basic installation
%%                                      %   Manual: http://www.tex.ac.uk/tex-archive/macros/latex/contrib/fancyhdr/fancyhdr.pdf
%%     hyperref (if hyper)              %   Manual: ftp://tug.ctan.org/pub/tex-archive/macros/latex/contrib/hyperref/doc/manual.pdf
%%
%%   Classes for internal use:
%%
%%     setspace                         % Required instalation with MikTeX basic installation
%%     nextpage (if twoside/openright)  % Required instalation with MikTeX basic installation
%%     geometry                         %   Manual: ftp://tug.ctan.org/pub/tex-archive/macros/latex/contrib/geometry/manual.pdf
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% INFORMATION for potential authors who may  contribute to bugfixes 
%%                                   or further feature developments
%%                       and hackers who may adapt it for other uses
%%
%% In order to maintain compatibility with other packages and
%%   accessability through LaTeX2e and future versions' interfaces, 
%%   LaTeX2e package and classs programming guidelines are followed
%%   to create a robust and protable class, which provents it from 
%%   clashing with the kernel, other packages or future updates.
%% 
%% Info on LaTeX2e classs and package programming can be found:
%%
%%   * "LaTeX2e for Class and Package Writers" by The LaTeX3 
%%     Project, http://www.latex-project.org/guides/clsguide.pdf.
%%   * "LaTeX Programming", Appendix D, "Guide to LaTeX", 4th Ed, 
%%     by H Kopka and P. Daly, Addison-Wesley, 2004
%%   * "A LaTeX Overview for Preamble, Package, and Class Writers", 
%%     Appendix A, "The LaTeX Companion", 2nd Ed, Addison-Wesley, 2004
%%     
%% Notes:
%%
%%   * Do not cut-n-paste from other thesis classes and packages. 
%%     Most of them were created before LaTeX2e time and took very
%%     different designs and approaches from this class, most of which  
%%     have programmed at the TeX level or used obsolete commands or 
%%     converted from legacy code with mixed commands, which makes 
%%     it unreliable to work with LaTeX2e packages. Please make 
%%     an effort to find the way to implement it with LaTeX2e if you 
%%     like some features in other pre-LaTeX2e codes.
%%
%%     Most relevent to this class is the way to set headers and page 
%%     layout. DO NOT directly set them from TeX commands. Use 
%%     commands provided by LaTeX2e packages and allow compatibility.
%%
%%  *  Programming at LaTeX2e level: As designed for LaTeX2e, various  
%%     packages available to LaTeX2e have been employed to accomplish  
%%     various taskes. Avoid programming at the TeX level. Take 
%%     advantages of LaTeX2e packages to create robust user-defined 
%%     micros and commands at high-level whenever possible and do not
%%     reinvent the wheel. Do not use undocumented commands not found 
%%     in Lamport official books, "LaTeX: A Document Preparation System"
%%
%%     In LaTeX 2.09, package developers had to resort to using 
%%     low-level commands since there was very little support for 
%%     writing .sty files. LaTeX2e provides high-level commands for 
%%     structuring packages and makes it much easier to build classes 
%%     and packages on top of each other. One of the largest differences 
%%     between LaTeX 2.09 and LaTeX2e is in the commands used to write 
%%     packages and classes.
%%
%%  *  EXCLUSIVELY use LaTeX constructs to take advantage of LaTeX's
%%     consistency cheking and portability to future versions of LaTeX.
%%     Primitive TeX commands do not test for possible conflicts with 
%%     other packages. 
%%
%%
%%  *  The following information is found in "LaTeX Programming", 
%%     Appendix D, "Guide to LaTeX", 4th Ed, by H Kopka and P. Daly, 
%%     Addison-Wesley, 2004
%%
%%     - Rule of Thumb: a command with @ IS NOT part of supported LaTeX 
%%       language and its behaviour may change in future releases. 
%%       Use them with care if you can not avoid. 
%%
%%         Use:                   Do Not Use:
%%            \newcommand           \def
%%            \renewcommand
%%            \newenvironment       \myenv...\endmyenv
%%            \renewenvironment
%%            \setlength
%%            \newlength
%%            \sbox,\mbox,\parbox   \setbox,\hbox,\vbox
%%            \Package(Class)Error(Warning)
%%                                  \@latexerr, \@warning 
%%         
%%     - Use current LaTeX2e commands: Avoid using obsolete commands
%%
%%         Use:                   Do Not Use:
%%            NFSS, eg. \textbf     TeX 2 letter declaration 
%                                     eg. \bf
%%                     
%%     - Useful Safe Commands
%%
%%       LaTeX Internal:
%%         \@namedef{cmd}{def}
%%         \@nameuse{cmd}
%%         \@ifdefined{cmd}{true}{false}
%%         \@ifnextcharchar{true}{false}
%%         \@ifstar{true}{false}
%%         \@for \obj := \list \do {cmds}
%%     
%%       TeX:                      LaTeX:
%%         \newif\ifflag         =  \newboolean{flag}
%%         \flagtrue             =  \setboolean{flag}{true}
%%         \flagfalse            =  \setboolean{flag}{false}
%%         \ifflag.. \else..\fi  =  \ifthenelse{\boolean{flag}{..}{..}
%%         \ifcase num text_0 \or text_1 \or ... \fi
%%         \endfile
%%                 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%% IDENTIFICATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesClass{UoWthesis}[2007/03/30 v1.0a,  
University of Wollongong Thesis Class, by Lei Ye]
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%% INITIAL CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%
%%%%% General (configurable) parameters for a thesis
%%
%%     Default values are provided
%%
%
%% Degree/academic unit{department,school}(unit)/faculty
\newcommand{\@degree}{Master of Computer Science - Research}
\newcommand{\degree}[1]{\renewcommand{\@degree}{#1}}
%
\newcommand{\@unit}{School of Computer Science and Software Engineering}
\newcommand{\unit}[1]{\renewcommand{\@unit}{#1}}
%
\newcommand{\@faculty}{Faculty of Informatics}
\newcommand{\faculty}[1]{\renewcommand{\@faculty}{#1}}
%
%% Degrees held
\newcommand{\@degreeHeld}{}
\newcommand{\degreeHeld}[1]{\renewcommand{\@degreeHeld}{#1}}
%
%% Univeristy name and logo
%%   Not supposed to be changed. 
%%   The presence of uni logo (***.png) is used as 
%%     the condition to include the logo,
%%     otherwise a thick rule will be printed in the place of the logo.
%%   The logo graphics will be stretched to \textlength  
%%   To produce output file with uni logo in DVI/PS, the logo in 
%%     eps format (***.eps) is to be provided along with png verison. 
%%     Do not remove the PNG file that is used as the condition test
%%   Hackers can change these values for other universities
%%     Please DO NOT forget save-as-ing the file with a new filename
%%     if you change the university name !!!
\newcommand{\@uni}{University of Wollongong}
\newcommand{\@unilogo}{UoWlogo}  %(filename without ext)
%
%%
%% Certificaiton text
%%   Not supposed to be changed
%%
%%   Dear hackers, this may need to be changed for your university
%%
\newcommand{\@certificatetext}{\noindent I, \@author, declare that this thesis, submitted in \ifpartial partial \fi fulfilment of the requirements for the award of \ifphd Doctor of Philosophy\else \@degree \fi , in the \@unit, \@faculty, \@uni, is wholly my own work unless otherwise referenced or acknowledged. The document has not been submitted for qualifications at any other academic institution. \par}
%
%%
%%%%% Layout parameters
%%
%%   Not supposed to be changed
%%
%%	 To meet the margin requirements, pp.7-8, Section 2.2, Guidelines
%%    
%%     left-hand > 40mm (1.57in)
%%     right-hand> 20mm (0.79in)
%%     top       > 30mm (1.18in)
%%     bottom    > 20mm (0.79in)
%%
%%   The following values for geometry are carefully selected for a4paper
%%     They are tricky for top and bottom sides:
%%         top    includes \headheight + headsep
%%         bottom includes \footskip
%%  
\newcommand{\@leftside}{36mm}   % there is a offset at the lefthand
\newcommand{\@rightside}{20mm}
\newcommand{\@topside}{1.65in}
\newcommand{\@bottomside}{1.25in}
%
%
%%%%%%%%%% DO NOT ALTER BELOW THIS LINE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%      unless you know what you are doing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%
%%%%% Micros 
%%
%
%% Submission Date, appears on title page and certification
\newcommand{\@submissionDay}{1}        % the default is the April Fools' Day, 1392,
\newcommand{\@submissionMonth}{April}  % considered as its origin
\newcommand{\@submissionYear}{1392}
\newcommand{\submissionDate}[3]{%    
  \renewcommand{\@submissionDay}{#1}%
  \renewcommand{\@submissionMonth}{#2}%
  \renewcommand{\@submissionYear}{#3}%
}
%
%% keywords
\newcommand{\@keywords}{}
\newcommand{\keywords}[1]{\renewcommand{\@keywords}{#1}}
%
%% dedication
\newcommand{\@dedication}{}
\newcommand{\dedication}[1]{\renewcommand{\@dedication}{#1}}
%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%% DECLARATION OF OPTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Invalid options - normally used in report.cls and others, but not here:
%%
%% page title
\DeclareOption{titlepage}{\ClassWarning{Thesis Class}{Option 'titlepage': Title page always generated. Option ignored.}}
\DeclareOption{notitlepage}{\ClassWarning{Thesis Class}{Option 'notitlepage': Not available for thesis.}}
%% paper size
\DeclareOption{a4paper}{\ClassWarning{Thesis Class}{Option 'a4paper': Mandatory requirement. Option ignored.}}
\DeclareOption{legalpaper}{\ClassWarning{Thesis Class}{Option 'legalpaper': Not available for thesis.}}
\DeclareOption{a5paper}{\ClassWarning{Thesis Class}{Option 'a5paper': Not available for thesis.}}
\DeclareOption{executivepaper}{\ClassWarning{Thesis Class}{Option 'executivepaper': Not available for thesis.}}
\DeclareOption{b5paper}{\ClassWarning{Thesis Class}{Option 'b5paper': Not available for thesis.}}
\DeclareOption{letterpaper}{\ClassWarning{Thesis Class}{Option 'letterpaper': Not available for thesis.}}
\DeclareOption{landscape}{\ClassWarning{Thesis Class}{Option 'landscape': Not available for thesis.}}
%
%% Determine the degree program: PhD or Masters by Research or others
\newif\ifphd
\DeclareOption{phd}{\phdtrue}
\DeclareOption{master}{\phdfalse \partialtrue}
\DeclareOption{other}{\phdfalse \partialtrue}
\ExecuteOptions{phd}               %Default: phd
%
%% Set condition for "partial" fulfilment on title
%%   page and certification
%%   "full" does nothing but omits the word "partial"
\newif\ifpartial
\DeclareOption{partial}{\partialtrue}
\DeclareOption{full}{\partialfalse}
\ExecuteOptions{full}               %Default: full
%
%% Define a parameter for fontsize to set default to 12pt
%%   report default was 10pt
%%   using \PassOptionsToClass and \ExecuteOptions{12pt} did not work
\newcommand\@fontSize{}
\DeclareOption{10pt}{\renewcommand\@fontSize{10pt}}
\DeclareOption{11pt}{\renewcommand\@fontSize{11pt}}
\DeclareOption{12pt}{\renewcommand\@fontSize{12pt}}
\ExecuteOptions{12pt}
%
%% Set line spacing
\newif\ifdouble
\DeclareOption{doublespacing}{\doubletrue}
\DeclareOption{onehalfspacing}{\doublefalse}
\ExecuteOptions{doublespacing}     %Default: doublespacing
%
%% Determine whether hyperlinks would be created in PDF
\newif\ifhyper
\DeclareOption{hyper}{\hypertrue}
\DeclareOption{nohyper}{\hyperfalse}
\ExecuteOptions{hyper}             %Default: hyper
%
%% Determine whether the copyright page would be created
%%   copyright page is not required by the "Guidelines"
%%
\newif\ifcopyright
\DeclareOption{copyright}{\copyrighttrue}
%
%% Determine whether openright for twosided priting
%%   defualt: openright for twoside
%%            openany   for oneside
%%   defaults different from report class defaults
\newif\ifopentwosideright
%% Use openright when two side printed
\DeclareOption{twoside}{%
  \opentwosiderighttrue \PassOptionsToClass{twoside, openright}{report}%
}
\DeclareOption{openany}{%
	 \opentwosiderightfalse \PassOptionsToClass{openany}{report}%
}
%
%%
%%%%% Switches 
%%
%
%% Dedication page is not required by the "Guidelines"
%%
\newif\ifdedication
\dedicationfalse      %Default: no dedication page
%
%% List of Figures/Tables are required by the "Guidelines"
%%   turn them off if no figures/tables in the thesis
\newif\ifListOfFigures
\ListOfFigurestrue    %Default: create List of Figures
\newif\ifListOfTables
\ListOfTablestrue     %Default: create List of Tables
%
%% Generate List of Figures/Tablles by default
%%
\newcommand{\noListOfTables}{\ListOfTablesfalse}
\newcommand{\noListOfFigures}{\ListOfFiguresfalse}
%
%% Pass the rest of options (not captured by \DeclareOption{})
%%   to report class
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{report}%
}
%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%% EXECUTION OF OPTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%
%% Golobal options from \docoumentclass[...] will be automatically 
%%   passed to all required packages
\ProcessOptions
%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%% PACKAGE LOADING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%
%%%%% Loading standard document report class
%%
%%    a4paper - The paper size has been forced to ISO A4 
%%              to meet the requirement, p.7, Section 2.2, the Guidelines
%
%% The papersize option will be overwritten by the option passed down  
%%   from the current class, otheroptions (eg. fontsize) will not. 
%% Specifying a letterpaper in \documentclass turned out to be fine, 
%%   thanks to the way the layout is set in this class
\LoadClass[a4paper, \@fontSize]{report}[2004/02/16]
%
%%
%%%%% Loading required packages
%%
%
%% To set the page layout
%%
%%     in goemetry:
%%       paperwidth  = left + width  + right
%%       paperheight = top  + height + bottom
%%         top    includes \headheight + headsep
%%         bottom includes \footskip
%%
%% The headheight must not < 14.49998pt for fancyhdr
%% marginparwidth=-1pt Please do not use margin notes
%%
\RequirePackage[left=\@leftside, right=\@rightside, top=\@topside, bottom=\@bottomside, headheight=14.5pt, marginparwidth=-1pt]{geometry}[2002/07/08] 
%
\newcommand{\@setLongPage}{%
	%\geometry{top=.75in}   %doesnt work here
	\setlength\topmargin{-.3in}    % move the top of text to the top of the head roughly 
	                               %                      = remove the headheight
	\enlargethispage{1.8cm}%
}%
\newcommand{\@setNormalPage}{%
  \setlength\topmargin{0in}      % set it back to top=\@topside 
}
%
%% To produce fancy headers
%%   See \frontmatter
\RequirePackage{fancyhdr}
%
%% For setting line space
\RequirePackage{setspace}[2000/12/01]
%
% required for loading the University logo
\RequirePackage{graphicx}[1999/02/16]      
%
%% To create a blank verso page for recto-verso (twoside/openright) printing
\ifopentwosideright%
  \RequirePackage{nextpage}[2000/02/20]%
  \renewcommand\cleardoublepage{\cleartooddpage[%
       \thispagestyle{empty}%
       \vfill%
       \begin{center}%
         (INTENTIONALLY BLANK)%
       \end{center}%
       \vfill]}%
\else%
  \renewcommand\cleardoublepage{\clearpage}      % if not twoside open right, clear one page only
\fi
%
%% To produce hypertext version of PDF;
%%
%%   loaded as the last package
%%   "plainpages" option false is used to avoid duplicate page identifiers
%%
%% "colorlinks" will be grayed when printed
%\ifhyper\RequirePackage[plainpages=false, colorlinks, bookmarks, bookmarksnumbered, breaklinks, linkcolor={blue}]{hyperref}\fi 
\ifhyper\RequirePackage[plainpages=false, pdfpagelabels, bookmarks, bookmarksnumbered, breaklinks]{hyperref}[2003/11/30]\fi
%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%% MAIN CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%
%%%%% Configuratons
%%
%
%% setting section numbering depth, 10 should be sufficient
\setcounter{secnumdepth}{10}
%%
%% Remove page number at the footer of \chapter pages, if you like
%\let\ps@plain=\ps@empty  
%
%%
%%
%%%%% Renew command: maketitle
%%
%%      Formated to meet the requirements
%%        Appendix I, Guidelines
\renewcommand{\maketitle}{%
  \thispagestyle{empty}%
  \@setLongPage%
  \IfFileExists{\@unilogo .png}{%
    \noindent\includegraphics[width=\textwidth]{\@unilogo}}%
    {\ClassWarning{Thesis Class}{The University logo file: \@unilogo .png is not present. %
      A rule is printed in the place of the logo.}%
     \rule{\linewidth}{2.5pt}}%
  \vspace{1.5cm}%
  \begin{center}%
     \Large \MakeUppercase{\textbf{\@title}}%
  \end{center}%
  \vfill%
  \begin{center}%
    A \ifphd Dissertation \else Thesis \fi Submitted in \ifpartial Partial \fi Fulfilment of \\%
    the Requirements for the Award of the Degree of \\%
    \vfill%
    \Large \ifphd Doctor of Philosophy \else \@degree \fi \\%
    \vfill%
    \normalsize%
    from\\%
    \vfill%
    \large \MakeUppercase{\@uni}%
  \end{center}%
  \vfill%
  \begin{center}%
    by\\%
    \vfill%
    \large \@author \\[0.2cm]%
    %%v1.0a A space "\ " added to handle empty \@degreeHeld that caused "no line here to end" error
    %\normalsize {\itshape\@degreeHeld}\\%
    \normalsize {\itshape\@degreeHeld}\ \\%
    \vfill%
    \@unit \\%
    \@faculty \\[0.5cm]%
    \@submissionYear%  
  \end{center}%     
  \rule\linewidth{1.5pt}% 
	\clearpage%
	\@setNormalPage%
}
%
%%
%%%%% New command: makecertificationpage 
%%
%%      Formatted to meet the requirements
%%        Appendix J, Guidelines
\newcommand{\@makecertificationpage}{%
  \thispagestyle{empty}%
  \begin{center}%
    \null\vspace{3cm}%
    \Large \textbf{CERTIFICATION}%
    \vspace{1cm}%
  \end{center}%
        
	\@certificatetext%
	
  \vspace{2.5cm}%
  \noindent\underline{~(Signature~~Required)~}\\[0.2cm]%
  \noindent\@author\\%
  \noindent\@submissionDay\ \@submissionMonth\ \@submissionYear %
  %\today%
  \cleardoublepage%
}
%
%%
%%%%% Renew abstract environment
%%
%%      Abstract is formated to meet the requriements
%%        
%%        p.18, Section 3.8, Guidelines
%%
\renewenvironment{abstract}{%
  \newpage%
  \@setLongPage%
  \pagestyle{empty}%
  \begin{center}%
      \large \textsc{\@title} \\%
      \vspace{0.3cm} %
      \normalsize \@author\\%
      \vspace{0.3cm}%
      A Thesis for \@degree \\%
      \vspace{0.2cm}%  
      \@unit \\%
      %\@faculty \\%
      \@uni \\%
      %\vspace{0.5cm}%
      \section*{ABSTRACT}    % placeholder for hypertext bookmark to work
      \addtocontents{toc}{\vspace{10pt}}  % add space after the LOT/LOF
 	    \addcontentsline{toc}{section}{ABSTRACT}% 
  \end{center}%
}{%
	\vfill%
	\begin{flushleft}%
    \textbf{KEYWORDS:}\ \ \@keywords%
  \end{flushleft}%
  \@setNormalPage%
  \cleardoublepage%
}
%
%%
%%%%% New command: makecopyrightpage
%%
%%      The IP right does not depend on whether this page is present
%%      See University policy on IP
\newcommand\@makecopyrightpage{%
	\newpage%
	\begin{doublespace}   % use pagacke setspace
	  \begin{center}%
	    \null\vfill%
	    \copyright\ Copyright\ \@submissionYear \\%
	    by\\%
	    \@author \\%
	    ALL RIGHTS RESERVED\\%
	    \vfill\null%
	  \end{center}%
	\end{doublespace}%
	\cleardoublepage%
}
%
%%
%%%%% New command: makededicationpage
%%
\newcommand\@makededicationpage{%
  \thispagestyle{empty}%
  \null\vfill%
  \begin{flushright}%
    \Large \itshape \textbf{Dedicated to}\hspace{2cm} \null\\[1cm]%
    \large \@dedication%
  \end{flushright}%
  \vfill\null%
  \cleardoublepage%
}
%
%%
%%%%% New envoronment: acknowledgements
%%
\newenvironment{acknowledgements}{%
  \pagestyle{plain}%
  \chapter*{Acknowledgements}  % To have the advantage of chapter headings
  \section*{}                  % placeholder for hypertext bookmark to work
	\addcontentsline{toc}{section}{Acknowledgements}%
  \vspace{-1cm}%
}{%
  \cleardoublepage%
}
%
%%
%%%%% Change the predefined heading text 
%%
%
%% Set the new title for \tableofcontents
%%    default was Contents
\renewcommand{\contentsname}{Table of Contents}
%
%% Set the new title for \bibliography
%%    default was Bibliography
\renewcommand{\bibname}{References}
%
%% Add a reference into TOC
\let\@ldbibliography\bibliography
\renewcommand{\bibliography}[1]{\@ldbibliography{#1} \addcontentsline{toc}{chapter}{\bibname}}
%
%% Good news for hackers
%%   To produce a thesis in a language other than English,
%%     the following preprogrammed heading text must be redefined, 
%%     plus other English words on title, copyright, certifiction, 
%%     dedication and blank pages
%% 
%%   eg.
%%     \providecomamnd*{\chaptername}{}
%%     \renewcommand*{\chapteranme}{Chpitre}
%% 
%%  \tableofcontents     -> \contentsname{Contents}
%%  \listoffigures       -> \listfigurename{List of Figures}
%%  \listoftables        -> \listtablename{List of Tables}
%%  \thebibliography     -> \bibname{Bibliography}
%%  \theindex            -> \indexname{Index}
%%
%%  \part                -> \partname{Part}
%%  \chapter             -> \chaptername{Chapter}
%%  \appendix            -> \appendixname{Appendix}
%%
%%  \begin{abstract}     -> \abstractname{Abstract}
%%  \begin{acknowledge}  -> \acknowledgename{Acknowledgments}
%%  \begin{figure}       -> \figurename{Figure}
%%  \begin{table}        -> \tablename{Table}
%
%%
%%%%% New command: frontmatter 
%%
%%      to create frontmatter
%%      CAUTION: the command frontmatter is also defined by the book class
%%               but not by the report class
%%
\newcommand\frontmatter{%
	%
	%% Setup PDF description
	%% This can not be put after maketitle, or the \@author etc 
	%%   will be blank, affected by clear{double}page
	\ifhyper\hypersetup{%
  	pdfauthor={\@author},%
  	pdftitle={\@title},%
  	pdfkeywords={\@keywords}}%
	\fi%
	%
	\pagestyle{empty}%
	\singlespacing%
	%% Use different page numbering to avoid warnings 
	%%   for duplicated page idnetifier from hyperref package
	\pagenumbering{alph}%  
	%
	\maketitle                 % Requried: Title Page
	%
	\ifcopyright \@makecopyrightpage \fi%
	\cleardoublepage%
	%
	\@makecertificationpage    % Required: Certification
	%
	\ifdedication \@makededicationpage \fi%  			
	%
	\pagestyle{headings}%
	\pagenumbering{roman}%
	\tableofcontents           % Required: Table of Contents
  %% if no \noListOfTables
	\ifListOfTables{%
  	\listoftables            % Required: List of Tables
  	\addcontentsline{toc}{section}{List of Tables}%
	}\fi%
  %% if no \noListOfFugures
	\ifListOfFigures{%
  	\listoffigures           % Required: List of Figures, Illustrations
  	\addcontentsline{toc}{section}{List of Figures/Illustrations}%
	}\fi%
	\cleardoublepage%
	%
	% not implemented: List of Special Names or Abbreviations                       
	                           % Required: List of Special Names or Abbreviations
 	                           %           Not everybody has it
} % end of frontmatter
%
%%
%%%%% New command: mainmatter
%%
%%      to set up style etc for the body text
%% 
\newcommand\mainmatter{%
  %
  \ifdouble\doublespacing \else\onehalfspacing\fi%
  \pagenumbering{arabic}%
  %
	%% Set fancy header for body pages
	\pagestyle{fancy}%
	%% Configure the header fields
  %%
  %% Stop changing all chapter and section in header to uppercase
  %%
  %% the following are suggested by Piet van Oostrum, the author of 
  %%   fancyhdr, in the doc "Page layout in LaTeX", March 2, 2004,  
  %%   found at http://www.tex.ac.uk/tex-archive/macros/latex/contrib/fancyhdr/.
  %%   But they didn't work. They caused errors.
	%%
	%% 1. p.9 
	%%    \renewcommand{\sectionmark}[1]{\markright{\thesection. \ #1}}
	%% 2. p.10 
  %%    \renewcommand{\chaptermark}[1]{%
  %%      \markboth{\chaptername
  %%      \ \thechapter.\ #1}{}}
  %%
  %% the following, no errors but no effect either
  %% 3. p.6
  %%    \lhead{\nouppercase{\leftmark}}
  %% I found the following working
	\let\@lmk\leftmark
	\renewcommand{\leftmark}{\textsl{\nouppercase\@lmk}}
	\let\@rmk\rightmark
	\renewcommand{\rightmark}{\textsl{\nouppercase\@rmk}}
  %% great!
	%
	\fancyfoot{}  % clear footer
	%
	\if@twoside{    % No panic! @twoside is a LaTeX switch, not TeX one as it appears to be
  	%%
  	%% \markboth{main-mark}{sub-mark}
  	%%   \leftmark <- main-mark
  	%%   \rightmark <- sub-mark
  	%% if main-mark <- \chapter or sub-mark <- \section
  	%% hence the following
  	%%
  	\fancyhead[RO,LE]{\thepage}%
  	\fancyhead[RE]{\leftmark}  % Chapter title
  	\fancyhead[LO]{\rightmark} % Section title  
	}\else{%
		\fancyhead[R]{\thepage}%
  	%\fancyhead[L]{\leftmark}  % Chapter title
  	\fancyhead[L]{\rightmark}  % Section title
	}\fi%
} % end of mainmatter
%
%%
\endinput  %Job done! Holiday time!!
%
%%%%% End of Class Code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%