%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  			UWTHESIS.TEX	
%%	            Style file for PhD theses 
%%		 for the University of Wisconsin	
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{pifont}

\input{page_layout}

\makeatletter
\font\Bold=cmbx10 scaled \magstep3

\def\@makechapterhead#1{             % Heading for \chapter command
  %\vspace*{50pt}                     % Space at top of text page.
  { \parindent 0pt \raggedright 
    \ifnum \c@secnumdepth >\m@ne     % IF secnumdepth > -1 THEN
      \huge\bf \@chapapp{} \thechapter % Print 'Chapter' and number.
      \par 
      \vskip 20pt \fi                  % Space between number and title.
    \Huge \bf                        % Title.
    #1\par 
    \nobreak                         % TeX penalty to prevent page break.
    \vskip 40pt                      % Space between title and text.
  } }

\def\@makeschapterhead#1{             % Heading for \chapter* command
  %\vspace*{50pt}                     % Space at top of page.
  { \parindent 0pt \raggedright 
    \Huge \bf                        % Title.
    #1\par 
    \nobreak                         % TeX penalty to prevent page break.
    \vskip 40pt                      % Space between title and text.
  } }

\def\chapter{\clearpage      % Starts new page.
   %\thispagestyle{plain}    % Default Page style of chapter page is 'plain'
   \thispagestyle{myheadings}  % We change it to top right hand corner
			     % Don't use headings here to avoid running head	
   \global\@topnum\z@        % Prevents figures from going at top of page.
   \@afterindentfalse        % Suppresses indent in first paragraph.  Change
   \secdef\@chapter\@schapter}   % to \@afterindenttrue to have indent.
%% End of CHAPTER modifications

\def\cl@chapter{\@elt{section}\@elt{footnote}}
\def\thefigure{\@arabic\c@figure}
\def\thetable{\@arabic\c@table}
\def\theequation{\arabic{equation}}
%\def\theequation{\thechapter.\arabic{equation}}

\def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
   \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner
      \@parmoderr\@floatpenalty\z@
    \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
       \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
       \@tfor \@tempa :=#2\do
                        {\if\@tempa h\advance\@tempcnta \@ne\fi
                         \if\@tempa t\advance\@tempcnta \tw@\fi
                         \if\@tempa b\advance\@tempcnta 4\relax\fi
                         \if\@tempa p\advance\@tempcnta 8\relax\fi
         }\global\count\@currbox\@tempcnta}\@fltovf\fi
    \global\setbox\@currbox\vbox\bgroup 
    \def\baselinestretch{1}\@normalsize
    \boxmaxdepth\z@
    \hsize\columnwidth \@parboxrestore}
\long\def\@footnotetext#1{\insert\footins{\def\baselinestretch{1}\footnotesize
    \interlinepenalty\interfootnotelinepenalty 
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext
    {\rule{\z@}{\footnotesep}\ignorespaces
      #1\strut}}}


\def\dept#1{\gdef\@dept{#1}}
\def\degree#1{\gdef\@degree{#1}}
\def\thesistype#1{\gdef\@thesistype{#1}}
\def\submitdate#1{\gdef\@submitdate{#1}}
\def\copyrightyear#1{\gdef\@copyrightyear{#1}} % \author, \title in report
\def\@title{}\def\@author{}\def\@dept{}\def\@degree{}\def\@thesistype{}
\def\@submitdate{\ifcase\the\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space \number\the\year}
\ifnum\month=12
    \@tempcnta=\year \advance\@tempcnta by 1
    \edef\@copyrightyear{\number\the\@tempcnta}
\else
    \def\@copyrightyear{\number\the\year}
\fi
\newif\ifcopyright \newif\iffigurespage \newif\iftablespage

\def\titlepage{%
	\setcounter{page}{0}
	\thispagestyle{empty}%
	% Cleo wants the title page to start higher 
	%\null\vskip1in%
	\begin{center}
		{\Bold\uppercase\expandafter{\@title}}
	\end{center}
	\vfill
	\begin{center}
		\rm By\\
		{\bf \@author}\\
	\end{center}
	\vfill
	\begin{center}
		{\sc A \expandafter{\@thesistype} submitted in partial 
		fulfillment of the \\
		requirements for the degree of}
	\end{center}
	\vfill
	\begin{center}
		{\sc \@degree \\
		(\expandafter{\@dept})}
        \end{center}
	\vfill
	\begin{center}
		at the \\
		{\bf UNIVERSITY OF WISCONSIN -- MADISON }\\
		%\@submitdate\\
		\expandafter{\@copyrightyear}
	\end{center}\vskip.5in\newpage}

\def\copyrightpage{%
	\newpage\strut\phantom{Copyrightpage}
	\setcounter{page}{0}
	\thispagestyle{empty}%
	\vspace{6.5in}
	\begin{center}
		\Pisymbol{psy}{227} Copyright by \@author\
		\@copyrightyear\\
		All Rights Reserved
	\end{center}
	\vfill\newpage}

\long\def\signature#1{%
\begin{center}
\begin{minipage}{4in}
\parindent=0pt
I certify that I have read this thesis and certify that in my opinion
it is fully adequate, in scope and in quality, as a dissertation for the degree
of Doctor of Philosophy.
\par
\vspace{.5in}
\hbox to 4in{\hfil\shortstack{\vrule width 3in height 0.4pt\\#1}}
\end{minipage}
\end{center}}

\def\beforepreface{
	\pagenumbering{roman}
	\pagestyle{myheadings}
	\titlepage
	\ifcopyright\copyrightpage\fi
	%\signaturepage
	}

\def\prefacesection#1{%
	\chapter*{#1}
	\addcontentsline{toc}{chapter}{#1}}

\def\afterpreface{\newpage
	\tableofcontents
	\newpage
	\iftablespage
		{\addvspace{10pt}
		\let\saveaddvspace=\addvspace
		\def\addvspace##1{}
		\listoftables
		\let\addvspace=\saveaddvspace}
		\newpage
	\fi
	\iffigurespage
		{\addvspace{10pt}
		\let\saveaddvspace=\addvspace
		\def\addvspace##1{}
		\listoffigures
		\let\addvspace=\saveaddvspace}
		\newpage
	\fi

	\pagenumbering{arabic}
	\pagestyle{myheadings}}

\renewenvironment{thebibliography}[1]
     {\chapter*{Bibliography
        \@mkboth{BIBLIOGRAPHY}{BIBLIOGRAPHY}}%
	\addcontentsline{toc}{chapter}{Bibliography}%
	\renewcommand{\baselinestretch}{1.25}
	\normalsize
      \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}}%
	    \setlength{\itemsep}{1.5mm}
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}

\pagestyle{myheadings}
\makeatother
