\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mythesis}[2005/09/05 School of Electrical and Electronic Engineering -- University of Adelaide]
%\RequirePackage[]{ulem}
% DON'T "RequirePackage" caption2.sty here!
%\RequirePackage[]{graphicx}
%\RequirePackage[]{lscape}
\RequirePackage{fancyhdr}
\RequirePackage{dropping}
\RequirePackage{graphics}
\RequirePackage{calc}
%\RequirePackage{setspace}

% Declare new options, initialise to false, gph.
\newif\ifmycolours\mycoloursfalse
\DeclareOption{mycolours}{\mycolourstrue}

\newif\ifmydraft\mydraftfalse
\DeclareOption{mydraft}{\mydrafttrue}


\newcommand\docsize{}  % to allow 10pt or 11pt to be specified as option
\typeout{Modified by Greg Harmer, 2000}
\DeclareOption{10pt}{\renewcommand\docsize{10pt}}
\DeclareOption{11pt}{\renewcommand\docsize{11pt}}
\DeclareOption{12pt}{\renewcommand\docsize{12pt}}
%  Prepare to load the standard report class (12pt):
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}		
%--Changed from report to book class by Withawat 25/03/06
\ExecuteOptions{12pt}         % define 12pt as the default doc size
\ProcessOptions
\LoadClass[\docsize]{book}  % load report.cls
%--Changed from report to book class by Withawat 25/03/06
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand\draftcomment{}

\ifmydraft
\typeout{ *** In draft mode ***}
\setlength\overfullrule{20pt}
\renewcommand\draftcomment{\space--\space{}Draft\space(\today)}
\fi


%  The following sections are revisions or additions to report.cls
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  FOOTNOTES:   make them continuously numbered throughout document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define command that can undo having footnotes reset with each chapter:
% (taken from removefr.sty by Donald Arseneau)
\def\@removefromreset#1#2{\let\@tempb\@elt
   \expandafter\let\expandafter\@tempa\csname c@#1\endcsname
   \def\@elt##1{\expandafter\ifx\csname c@##1\endcsname\@tempa\else
         \noexpand\@elt{##1}\fi}%
   \expandafter\edef\csname cl@#2\endcsname{\csname cl@#2\endcsname}%
   \let\@elt\@tempb}
% use the command \@removefromreset to undo the \@addtoreset in report.cls:
\@removefromreset{footnote}{chapter}
%
% define command to allow people to reset footnote counter at will:
\def\resetfootnote{\setcounter{footnote}{0}}  % definition to reset footnote

%\@removefromreset{section}{chapter}
%\def\resetsection{\setcounter{section}{0}}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PAGE LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength\voffset{-1.0in}
\setlength\hoffset{-1.0in}

\setlength\topmargin{20.0mm-4.0mm}
\setlength\headheight{5.00mm}
\setlength\headsep{7.00mm}

\setlength\footskip{10.00mm}
\setlength\textheight{\paperheight
                       -\topmargin-\headheight-\headsep
                       -\footskip-5.0mm-\topmargin}

% SIDE MARGINS:
\marginparsep 1mm
\if@twoside
   \setlength\oddsidemargin{3cm}
   \setlength\evensidemargin{2cm}
   \setlength\marginparwidth{1.5cm}
   \ifmydraft
      % Make room for marginal notes
      \setlength\oddsidemargin{2.5cm}
      \setlength\evensidemargin{2.5cm}
      \setlength\marginparwidth{2.25cm}
   \fi
\else
   \setlength\oddsidemargin{2.5cm}
   \setlength\evensidemargin{2.5cm}
   \setlength\marginparwidth{2.25cm}
\fi

\setlength\textwidth{\paperwidth-\oddsidemargin-\evensidemargin}


% Line spacing and par seps, gph.
\renewcommand{\baselinestretch}{1.33333}
\newcommand\setmyparsep{\parskip0.4\baselineskip\@plus0ex\@minus 0.5ex}
\newcommand\setmytightparsep{\parskip0.2\baselineskip\@minus0.5ex}
\setlength\parindent{0ex}



\widowpenalty 10000    % completely discourage widow lines
\clubpenalty 10000     % completely discourage club (orphan) lines
\brokenpenalty 10000   % completely discourage hyphenation across pages

\if@twoside
   \flushbottom
\else
  \raggedbottom
\fi
\if@twocolumn
  \twocolumn
  \sloppy
  \flushbottom
\else
  \onecolumn
\fi


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Headings stuff. Added by gph.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\newcommand\blob{\rule[-0.2\unitlength]{1in}{0.8\unitlength}}
\newcommand\rblob{\begin{picture}(0,0)
                    \setlength{\unitlength}{25mm}
                    %\put(0,-\value{chapter}){\blob}
                    \put(0.127,-\value{chapter}){\blob}
                  \end{picture}}
\newcommand\chaptergraphics{\begin{picture}(0,0)
                    \setlength{\unitlength}{1pt}
                    \put(0,-55){\resizebox{0.5\textwidth}%
                    {50pt}{\includegraphics{gradient}}}
                  \end{picture}}



\fancyhf{} % delete current setting for header and footer
%\fancyhead[LE]{\headerfont\chaptername\space\thechapter}
%\fancyhead[LO]{\headerfont\rightmark}
%\fancyhead[RE]{\headerfont\leftmark}
%\fancyfoot[LE,RO]{\footerfont{Page\space\thepage}}
%\fancyfoot[C]{\footerfont{Fancy}}
%\fancyfoot[LO,RE]{\footerfont\chaptername\space\thechapter}
\fancyhead[LO]{\headerfont\chaptername\space\thechapter}
\fancyhead[LE]{\headerfont\rightmark}
\fancyhead[RO]{\headerfont\leftmark}
\fancyfoot[LE,RO]{\footerfont{Page\space\thepage}}
\ifmydraft\fancyfoot[C]{\footerfont{Fancy\draftcomment}}\fi
\renewcommand{\headrulewidth}{0.5pt}
\addtolength{\headheight}{0.5pt} % make space for the rule
\renewcommand{\footrulewidth}{0.5pt}
\addtolength{\footskip}{0.5pt} % make space for the rule


\fancypagestyle{plain}{%
   \fancyhead{} % get rid of headers
   \fancyfoot{}
   \renewcommand{\headrulewidth}{0pt} % and the line.
   \renewcommand{\footrulewidth}{0.5pt}
   \ifmydraft\fancyfoot[C]{\footerfont{Plain\draftcomment}}\fi
   \fancyfoot[LE,RO]{\footerfont{Page\space\thepage}}
   \addtolength{\footskip}{0.5pt}}

\fancypagestyle{chapterstart}{%
   \fancyhead{} % get rid of headers
   \fancyhead[RO]{\chapterblobcolor\rblob}
   \fancyhead[LO]{\chaptergraphics}
   \fancyfoot{}
   \renewcommand{\headrulewidth}{0pt} % and the line.
   \renewcommand{\footrulewidth}{0.5pt}
   \ifmydraft\fancyfoot[C]{\footerfont{Chapter Start\draftcomment}}\fi
   \fancyfoot[LE,RO]{\footerfont{Page\space\thepage}}
   \addtolength{\footskip}{0.5pt}}


\fancypagestyle{special}{%
   \fancyhead{} % get rid of headers
   \fancyfoot{}
   \fancyhead[LE,RO]{\headerfont\leftmark}
   \fancyfoot[LE,RO]{\footerfont{Page\space\thepage}}
   \ifmydraft\fancyfoot[C]{\footerfont{Special\draftcomment}}\fi
   \renewcommand{\headrulewidth}{0.5pt} % and the line.
   \addtolength{\headheight}{0.5pt}
   \renewcommand{\footrulewidth}{0.5pt}
   \addtolength{\footskip}{0.5pt}}

\fancypagestyle{normal}{%
   \fancyhead{} % get rid of headers
   \fancyfoot{}
   \fancyhead[LO]{\headerfont\chaptername\space\thechapter}
   \fancyhead[LE]{\headerfont\rightmark}
   \fancyhead[RO]{\headerfont\leftmark}
   \renewcommand{\headrulewidth}{0.5pt} % and the line.
   \addtolength{\headheight}{0.5pt}
   \renewcommand{\footrulewidth}{0.5pt}
   \addtolength{\footskip}{0.5pt}
   \fancyfoot[LE,RO]{\footerfont{Page\space\thepage}}
   \ifmydraft\fancyfoot[C]{\footerfont{Normal\draftcomment}}\fi}

\pagestyle{fancy} % this must be called before the next 2 lines.
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\space#1}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                            SECTION HEADINGS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\chaptersize{\normalsize}
\newcommand\sectionsize{\normalsize}
\newcommand\subsectionsize{\normalsize}
\newcommand\subsubsectionsize{\normalsize}
\newcounter{firstchapter}
\setcounter{firstchapter}{0}

\newif\ifwasonecol\wasonecolfalse

% What to do for the last chapter page if blank.
\def\cleardoublepage{%
\if@twocolumn\wasonecolfalse
\else\wasonecoltrue
\fi
\onecolumn
\clearpage
\if@twoside
   \ifodd\c@page\else
      \if@twocolumn % shouldn't need to be used any more, gph.
         \hbox{}\newpage\fi
      \hbox{}
      \ifmydraft
         \vspace*{\fill}
         \begin{center}
            {\normalfont\Large\bfseries\sffamily%
            This is the last page of\space\leftmark\par%
            Next chapter is
            \ifwasonecol{one}\else{two}\fi\space
            column\par\space
            (Draft -- Page will be blank)\par}
         \end{center}
         \vspace{\fill}
      \fi
      \thispagestyle{plain}
      \newpage
   \fi
\fi
\ifwasonecol\onecolumn\else\twocolumn\fi}



%\renewcommand{\thesection}{\arabic{section}.}
%\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}
%\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}.}
%\renewcommand{\theparagraph}{\thesubsubsection\arabic{paragraph}.}
%\@addtoreset{figure}{section}
%\@addtoreset{table}{section}
%\@addtoreset{equation}{section}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  CHAPTER HEADING STUFF  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                    \global\@topnum\z@
                    \@afterindentfalse
                    \pagestyle{normal}
                    \setmyparsep
                    \secdef\@chapter\@schapter}

\def\@chapter[#1]#2{\thispagestyle{chapterstart}
                    \ifnum\c@firstchapter=0
                      \pagenumbering{arabic}
                      \setcounter{firstchapter}{1}
                    \fi
                    \ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\space}
                         \typeout{Processing\space\@chapapp\space\thechapter.\space#2}%
                         \addcontentsline{toc}{chapter}%
                                   {\@chapapp\space\protect\numberline{\thechapter.}#1}%
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    %\markboth{#1}{}%gph
                    \chaptermark{#1}%
                    %\addtocontents{lof}{\@chapapp\space\protect\numberline{\thechapter}\par}%
                    %\addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \ifnum\c@chapter>1
                      \addtocontents{lof}{\hfill\hrulefill\hspace*{\fill}\par%
                      \protect\addvspace{10\p@}}\fi
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}

\def\@makechapterhead#1{%
  %\vspace*{40\p@}%
  {\parindent\z@\raggedright
    \ifnum \c@secnumdepth >\m@ne
        \chapterlabelfont\@chapapp\space\thechapter\par\nobreak
        \vskip 30\p@
    \fi
    \interlinepenalty\@M
    \raggedleft\chapterfont#1\par\nobreak
    \vskip 40\p@
  }}

\def\vertbar{\vspace*{-50\p@}
             \vertbarcolor\rule{20mm}{100\p@}}

\def\@schapter#1{\pagestyle{special}
                 \thispagestyle{plain}
                 \addcontentsline{toc}{chapter}{\TOCchapterscolor#1}%%
                 \chaptermark{#1}
                 \typeout{\space}
                 \typeout{Processing\space#1}
                 \if@twocolumn
                   \@topnewpage[\@makeschapterhead{#1}]%
                 \else
                   \@makeschapterhead{#1}%
                   \@afterheading
                 \fi}


\def\@makeschapterhead#1{%
  %\vspace*{50\p@}%
  {\parindent \z@ \raggedright %\normalfont
    \interlinepenalty\@M
    \chapterfont#1\par\nobreak
    \vskip 40\p@
  }}

\font\afont=eurb8 at \docsize
\newlength\letterwidth
\newcommand\PARstart[2]{\settowidth\letterwidth{m}%
\dropcolor\bigdrop{0pt}{3}{eurb8}{#1\hspace{\letterwidth}}%
\black\uppercase{{\afont{#2}}}}

%\newcommand\PARstart[2]{\bigdrop{0pt}{3}{eurb8}{#1}\uppercase{{\afont{#2}}}}

% Chapter summary environment, gph.
\newlength{\chapsumwidth}
\setlength{\chapsumwidth}{\textwidth-2\leftmargin}
\newenvironment{chaptersummmary}
               {\vfill\noindent\hfill
                \minipage{\chapsumwidth}
                \setlength{\parskip}{0.3\baselineskip}
                \hrulefill\par}
               {\par\vspace{-0.3\baselineskip}\hrulefill
                \endminipage
                \hspace*{\fill}
                \vskip 50\p@
                \vspace*{\fill}
                \newpage}




%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  SECTIONS  STUFF        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\newcommand\section{\@startsection {section}{1}{\z@}%
%                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
%                                   {2.3ex \@plus.2ex}%
%                                   {\normalfont\Large\bfseries}}

% Use this to do all section stuff manually, gph.

%\renewcommand\section{\@afterindentfalse\secdef\@section\@ssection}
%
%\def\@section[#1]#2{%\setcounter{subsection}{0}%
%                    \ifnum \c@secnumdepth >\m@ne
%                      \refstepcounter{section}%
%                       \addcontentsline{toc}{section}%
%                       {\protect\numberline{\thesection}#1}%
%                    \fi
%                    \sectionmark{#1}%
%                    \@makesectionhead{#1}}
%
%\def\@ssection#1{\@makessectionhead{#1}}
%
%\newlength{\gnat}
%\def\@makesectionhead#1{\vspace{4.5ex \@plus 1ex \@minus .2ex}
%                       %\vspace*{\baselineskip}%
%            {\parindent\z@\raggedright
%            \ifnum \c@secnumdepth >\m@ne
%              \sectionlabelfont\thesection\space
%            \fi
%            \sectionfont{#1}}%
%            \settowidth{\gnat}{\sectionfont\thesection\space#1}%
%            \hspace{-\gnat}%\vskip -\docsize %-10\p@
%            {\sectionunderlinecolor\sectionrule}
%            %\par
%            \vspace{1.8ex \@plus .2ex \@minus .2ex}%
%            \par\noindent%
%             %\@afterindentfalse%
%           %\nobreak
%           }

%\def\@makessectionhead#1{\vspace*{\baselineskip}%
%            {\parindent \z@ \raggedright
%            \sectionfont{#1}
%            \@afterindentfalse\nobreak
%             }}

\def\sectionrule{\sectionunderlinecolor\rule[-1ex]{\textwidth}{1pt}}

% Use a graphic, or
%\newcommand\sectrule{\parindent\z@\begin{picture}(0,0)
%                    \setlength{\unitlength}{1ex}
%                    \put(0,-1){\resizebox{\textwidth}%
%                    {1.5pt}{\includegraphics{underline}}}
%                  \end{picture}}

% just a line, gph.
\newcommand\sectrule{\parindent\z@%
                     \picture(0,0)
                     \put(0,0){\sectionrule}
                     \endpicture}

\renewcommand\section{\@startsection{section}{1}{\z@}%
                             {-3.5ex \@plus -1ex \@minus -1.0ex}%preskip
                             {1.0ex \@plus .7ex}%postskip
                             {\sectrule\sectionfont}}%style


\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.2ex\@plus -1ex \@minus -.2ex}%
                                     {1.0ex \@plus .1ex}%
                                     {\subsectionfont}}



\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-2.2ex\@plus -1ex \@minus -.5ex}%
                                     {.5ex \@plus .2ex}%
                                     {\subsubsectionfont}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  APPENDIX  STUFF        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand\appendix{\par
  \setcounter{chapter}{0}%
  \setcounter{section}{0}%
  \renewcommand\@chapapp{\appendixname}%
  \renewcommand\thechapter{\@Alph\c@chapter}
  \renewcommand\chaptername{\appendixname}}

\renewenvironment{quote}
                 {\list{}{\rightmargin\leftmargin}%
                  \item\relax\quotefont}
                 {\endlist}


\renewenvironment{table}
               {\@float{table}[bt]\tablefont}
               {\end@float}

\newenvironment{code}
               {\list{}{\rightmargin\leftmargin%
                        \setlength\topsep{0ex}%
                        \setlength\partopsep{0ex}%
                        \setlength\parsep{1.5ex\@plus0.2ex\@minus0.2ex}%
                        \renewcommand{\baselinestretch}{1.2}}%
                \item\relax\codefont}
               {\endlist}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  TABLE of CONTENTS,  LIST OF TABLES,  LIST OF FIGURES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname}
%        \@mkboth{%
%           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
    \setmytightparsep
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }

\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \TOCchapterfont
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{10em}{5em}}
\renewcommand*\l@subparagraph{\@dottedtocline{5}{12em}{6em}}


\renewcommand\listoffigures{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename}
%      \@mkboth{\MakeUppercase\listfigurename}%
%              {\MakeUppercase\listfigurename}%
    \setmytightparsep
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }
\renewcommand*\l@figure{\@dottedtocline{1}{0em}{3.8em}}


\renewcommand\listoftables{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listtablename}
%      \@mkboth{%
%          \MakeUppercase\listtablename}{\MakeUppercase\listtablename}%
    \setmytightparsep
    \@starttoc{lot}%
    \if@restonecol\twocolumn\fi
    }
\let\l@table\l@figure

%\newcommand\glossaryentry[2]{#1\hfil#2}

\newcommand\listofglossary{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listglossaryname}
%      \@mkboth{%
%          \MakeUppercase\listtablename}{\MakeUppercase\listtablename}%
    %\@starttoc{lot}%
    %\begin{description}
    \InputIfFileExists{mythesis.glo}{xxx}{yyy}
    %\end{description}
    \if@restonecol\twocolumn\fi
    }

\renewenvironment{thebibliography}[1]
     {\chapter*{\bibname}
%			{\chapter*{References}		% Change from Bibliography to References by Withawat
%        \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
\bibandidxfont%
      \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
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}

\newcommand{\includemypubs}[1]{%
\let\tempfont\bibandidxfont%
\renewcommand\bibandidxfont{\normalfont\normalsize}
\IfFileExists{#1.tex}{\immediate\write18{latex #1.tex}\immediate\write18{bibtex #1}}{Warning. Can't find Publications!}
\renewcommand\bibname{\pubsname}
\InputIfFileExists{#1.bbl}%
{\typeout{Adding #1.bbl to \jobname}}%
{\typeout{******* There was no #1.bbl file to add to \jobname\space*******}}%
\renewcommand\bibname{\mybibname}
\renewcommand\bibandidxfont{\tempfont}}


\renewenvironment{theindex}
               {\if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                  \twocolumn
                \fi
                \columnseprule \z@%0.5\p@
                \columnsep 35\p@
                \chapter*{\indexname}
                %\twocolumn[\@makeschapterhead{\indexname}]%
                %\@mkboth{\MakeUppercase\indexname}%
                %        {\MakeUppercase\indexname}%
                %\thispagestyle{plain}
                \bibandidxfont%
                \parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\if@restonecol\onecolumn\else\clearpage\fi}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  FOR FLOAT PLACEMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setcounter{topnumber}{2}
\renewcommand\topfraction{.8}
\setcounter{bottomnumber}{1}
\renewcommand\bottomfraction{.8}
\setcounter{totalnumber}{3}
\renewcommand\textfraction{0.25}
\renewcommand\floatpagefraction{.75}

\setcounter{dbltopnumber}{2}
\renewcommand\dbltopfraction{.7}
\renewcommand\dblfloatpagefraction{.5}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  FOR RPI TITLEPAGE, ABSTR. TITLEPAGE & COPYRIGHT PAGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 \def\thesistitle#1{\gdef\@thesistitle{#1}}
 \def\author#1{\gdef\@author{#1}}
 \def\qualifications#1{\gdef\@qualifications{#1}}
 \def\degree#1{\gdef\@degree{#1}}
 \def\department#1{\gdef\@department{#1}}
 \def\university#1{\gdef\@university{#1}}
 \def\thadviser#1{\gdef\@thadviser{#1}}
 \def\projadviser#1{\gdef\@projadviser{#1}} \projadviser{*}
 \def\cothadviser#1{\gdef\@cothadviser{#1}} \cothadviser{*}
 \def\coprojadviser#1{\gdef\@coprojadviser{#1}} \coprojadviser{*}
 \def\doctype{\if \@projadviser *Thesis \else Project \fi}
 \def\adviser{\if \@projadviser *\@thadviser \else \@projadviser\fi}
 \def\coadviser{\if \@coprojadviser *\@cothadviser\else \@coprojadviser\fi}
 \def\copyrightyear#1{\gdef\@copyrightyear{#1}} \copyrightyear{\the\year}
 \def\graddate#1{\gdef\@graddate{#1}}

\newcount\numcount


\newcommand\updateme[1]{\renewcommand{\baselinestretch}{#1}}
\def\titlepage{%
\typeout{---------------Doctoral Thesis----------}
\thispagestyle{empty}
\pagestyle{empty}
   \vspace*{\fill}
   {\centering\titlepagefont
   \updateme{2}
   \begin{center}
      \updateme{1.5}\titlefont\@thesistitle
   \end{center}
   \updateme{2}\titlepagefont
    by\par
   {\authorfont\@author}\par
   \begin{center}
      \updateme{1}\qualsfont\@qualifications
   \end{center}
   \vspace{1cm}
   \updateme{2}\titlepagefont
    Thesis submitted for the degree of\par
   {\bfseries\@degree}\par
    in\par
   \begin{center}
      \updateme{1}\titlepagefont
      \@department\par
      \@university
   \end{center}
   \@graddate\par}
  \vspace*{\fill}
  \newpage
  \pagenumbering{roman}
  \setcounter{page}{2}}

%%%%

\def\copyrightpage{
    \hbox{ }
    \thispagestyle{empty}
    \vfill
    %\minipage[b][2cm][b]{4cm}
    %Typeset in \LaTeXe\\
    %\@author
    %\endminipage
    %\newlength{\temp}
    %\settowidth{\temp}{\unilogo}
    \noindent\hfill
    \minipage[b][2cm][b]{5.4cm}\hfill\cbmelogo\hspace*{\fill}\endminipage
    \parbox[b][2cm][c]{5cm}{%
    \centering\copyright\sffamily\space\@copyrightyear\\
    \@author \\
    All Rights Reserved}
    \minipage[b][2cm][b]{5.4cm}\hfill\unilogo\hspace*{\fill}\endminipage\hspace*{\fill}
    \clearpage}

\def\signoff{%       gph
    %\hbox{ }
    \vspace*{2in}
    %\emph{\@disclaim} \\[1in]
    {\parindent \z@%
    \makebox[2.75in]{\hrulefill}\hfill\makebox[2.75in]{\hrulefill}\\[-1ex]
    \makebox[2.75in][l]{\signofffont{Signed}}\hfill\makebox[2.75in][l]{\signofffont{Date}}}\par
    \thispagestyle{plain}
    \newpage}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SOME INITIALIZATIONS:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make the following names uppercase:
\renewcommand\contentsname{TABLE OF CONTENTS}
\renewcommand\listfigurename{LIST OF ILLUSTRATIONS}
\renewcommand\listtablename{LIST OF TABLES}
\newcommand\listglossaryname{MY GLOSSARY}
\renewcommand\bibname{BIBLIOGRAPHY}
%\renewcommand\bibname{REFERENCES}
\renewcommand\indexname{INDEX}
\renewcommand\partname{PART}
\renewcommand\chaptername{SECTION}
\renewcommand\appendixname{APPENDIX}
%\renewcommand\abstractname{ABSTRACT}  %---Commented out by Withawat 25/03/06

\newcommand\black{\color{black}}
\newcommand\white{\color{white}}
\ifmycolours
   \typeout{ **** Using My Colours ****}
   \newcommand\chaptercolor{\color[named]{BrickRed}}
   \newcommand\chapterlabelcolor{\color{black}}
   \newcommand\chapterblobcolor{\color[named]{Fuchsia}}

   \newcommand\sectioncolor{\color[named]{NavyBlue}}
   \newcommand\sectionlabelcolor{\color[named]{Purple}}
   \newcommand\sectionunderlinecolor{\color[named]{YellowOrange}}

   \newcommand\subsectioncolor{\color[named]{NavyBlue}}
   \newcommand\subsectionlabelcolor{\color[named]{Purple}}
   \newcommand\subsubsectioncolor{\color[named]{NavyBlue}}

   \newcommand\footercolor{\frame{\hspace{-1pt}}\color[named]{PineGreen}}
   \newcommand\headercolor{\color[named]{PineGreen}}
   \newcommand\vertbarcolor{\color[named]{Apricot}}

   \newcommand\titlecolor{\color[named]{NavyBlue}}
   \newcommand\titlepagecolor{\color[named]{Black}}

   \newcommand\captioncolor{\color[named]{BlueViolet}}
   \newcommand\captionlabelcolor{\color[named]{PineGreen}}
   \newcommand\captionlinecolor{\color[named]{PineGreen}}
   \newcommand\figlabcolor{\color[named]{PineGreen}} %0 132 115
   \newcommand\tablecolor{\color[named]{BlueViolet}}

   \newcommand\marginnotecolor{\color{red}}
   \newcommand\margintodocolor{\color{green}}
   \newcommand\dropcolor{\color[named]{NavyBlue}}

   \newcommand\TOCchaptercolor{\color[named]{NavyBlue}}
   \newcommand\TOCchapterscolor{\color{black}}

\else % Just leave it black
   \newcommand\chaptercolor{}
   \newcommand\chapterlabelcolor{}
   \newcommand\chapterblobcolor{}
   \newcommand\sectionunderlinecolor{}
   \newcommand\sectioncolor{}
   \newcommand\sectionlabelcolor{}
   \newcommand\subsectioncolor{}
   \newcommand\subsectionlabelcolor{}
   \newcommand\subsubsectioncolor{}
   \newcommand\footercolor{}
   \newcommand\headercolor{}
   \newcommand\vertbarcolor{}
   \newcommand\titlecolor{}
   \newcommand\titlepagecolor{}
   \newcommand\captioncolor{\black}
   \newcommand\captionlabelcolor{}
   \newcommand\captionlinecolor{}
   \newcommand\figlabcolor{}
   \newcommand\tablecolor{}
   \newcommand\marginnotecolor{}
   \newcommand\margintodocolor{}
   \newcommand\dropcolor{}
   \newcommand\TOCchaptercolor{}
   \newcommand\TOCchapterscolor{}

\fi

% Now make the font types, gph.
\font\clfont=eurb10 at 28pt
%\font\chfont=cmssbx10 at 36pt

\DeclareFontShape{OT1}{cmss}{m}{n}
     {%
      <5><6><7><8>cmss8%
      <9>cmss9%
      <10><10.95>cmss10%
      <12><14.4>cmss12%
      <17.28><20.74><24.88><25->cmss17%
      }{}

%%%%%%%%% bold extended series
\DeclareFontShape{OT1}{cmss}{bx}{n}
     {%
      <5><6><7><8><9>cmssbx10%
      <10><10.95><12><14.4><17.28><20.74><24.88><25->cmssbx10%
      }{}

\newcommand\chapterfont{\fontsize{36}{30}\bfseries\sffamily\chaptercolor}

\newcommand\chapterlabelfont{\normalfont\clfont\chapterlabelcolor}

\newcommand\sectionfont{\normalfont\Large\bfseries\sffamily\sectioncolor}
\newcommand\sectionlabelfont{\normalfont\Large\bfseries\sffamily\sectionlabelcolor}
\newcommand\subsectionfont{\normalfont\large\bfseries\sffamily\subsectioncolor}
\newcommand\subsubsectionfont{\normalfont\normalsize\bfseries\sffamily\subsubsectioncolor}

\newcommand\tablefont{\normalfont\small\sffamily\tablecolor}

\newcommand\footerfont{\normalfont\bfseries\sffamily\footercolor}
\newcommand\headerfont{\normalfont\bfseries\sffamily\headercolor}

\newcommand\summaryfont{\normalfont\sffamily}
\newcommand\quotefont{\normalfont\slshape\small}
\newcommand\codefont{\normalfont\ttfamily\small}

\newcommand\titlepagefont{\normalfont\sffamily\Large\titlepagecolor}
\newcommand\titlefont{\normalfont\sffamily\bfseries\Huge\titlecolor}
\newcommand\qualsfont{\normalfont\sffamily\normalsize\titlepagecolor}
\newcommand\authorfont{\normalfont\sffamily\bfseries\Large\titlecolor}

\newcommand\signofffont{\normalfont\footnotesize\sffamily}

\newcommand\marginnotefont{\normalfont\scriptsize\sffamily\marginnotecolor}
\newcommand\margintodofont{\normalfont\scriptsize\sffamily\margintodocolor}

\newcommand\xxsmallfigfont{\normalfont\tiny\sffamily}
\newcommand\xsmallfigfont{\normalfont\scriptsize\sffamily}
\newcommand\smallfigfont{\normalfont\footnotesize\sffamily}
\newcommand\figfont{\normalfont\small\sffamily}
\newcommand\bigfigfont{\normalfont\normalsize\sffamily}
\newcommand\xbigfigfont{\normalfont\large\sffamily}
\newcommand\xxbigfigfont{\normalfont\Large\sffamily}
\newcommand\xxxbigfigfont{\normalfont\LARGE\sffamily}

\newcommand\figlabelfont{\normalfont\small\bfseries\sffamily\figlabcolor}

\newcommand\captionlinefont{\bfseries\captionlinecolor}
\newcommand\tcaptionfont{\normalfont\small\sffamily\captioncolor}
\newcommand\tcaptionlabelfont{\normalfont\bfseries\small\sffamily\captionlabelcolor}

\newcommand\bibandidxfont{\normalfont\normalsize\footnotesize}
\newcommand\mypubsfont{\normalfont\normalsize}

\newcommand\TOCchapterfont{\normalfont\normalsize\bfseries\sffamily\TOCchaptercolor}
\newcommand\TOCchaptersfont{\normalfont\normalsize\bfseries\sffamily\TOCchapterscolor}

%\renewcommand{\thechapter}{\arabic{chapter}}
%\renewcommand\theequation
%  {\thesection\@arabic\c@equation}
%\renewcommand\thefigure
%     {\thesection\@arabic\c@figure}
%\renewcommand\thetable
%     {\thesection\@arabic\c@table}

%\setlength{\parskip}{0.5\baselineskip}



\newcommand\mycaption[2][]{\caption[{#1}]{{\captionlinefont{{#1}.}}\space{#2}}}




\newcommand{\unilogo}{\resizebox{!}{2cm}{\includegraphics{ualogo_cmyk}}}
\newcommand{\cbmelogo}{\resizebox{!}{2cm}{\includegraphics{cbme_logo}}}

\newcommand{\todoin}[1]{\begin{list}{}%
{\leftmargin\parindent\rightmargin0pt\listparindent0pt\parsep1ex%
\labelwidth0pt\labelsep0pt}\item[]\normalfont\small\sffamily$\spadesuit$~#1 \end{list}}


% Marginal comments
\newenvironment{myspace}[1]{%
\renewcommand{\baselinestretch}{#1}}{}
\ifmydraft
\newcommand{\Q}[1]{\begin{myspace}{0.6}%
\marginpar%
[\vspace*{-4mm}\flushright%
{\rule[0mm]{\marginparwidth}{0.75pt}}\\ %
{\marginnotefont{#1}}\\ %
{\rule[2mm]{\marginparwidth}{0.75pt}}]%
%
{\vspace*{-4mm}\flushleft%
{\rule[0mm]{\marginparwidth}{0.75pt}}\\ %
{\marginnotefont{#1}}\\ %
{\rule[2mm]{\marginparwidth}{0.75pt}}}%
\end{myspace}}
\else
\newcommand{\Q}[1]{}
\fi

\ifmydraft
\newcommand{\todo}[1]{\begin{myspace}{0.6}%
\marginpar%
[\vspace*{-4mm}\flushright%
{\rule[0mm]{\marginparwidth}{0.75pt}}\\ %
{\margintodofont{#1}}\\ %
{\rule[2mm]{\marginparwidth}{0.75pt}}]%
%
{\vspace*{-4mm}\flushleft%
{\rule[0mm]{\marginparwidth}{0.75pt}}\\ %
{\margintodofont{#1}}\\ %
{\rule[2mm]{\marginparwidth}{0.75pt}}}%
\end{myspace}}
\else
\newcommand{\todo}[1]{}
\fi

\newcommand\what{Test of font \f@encoding/\f@family/\f@series/\f@shape.}


\endinput
)
