%  Princeton University PhD thesis style -- modifications to the report style
\typeout{Princeton University PhD thesis style.  Released 1 June 1990}
%
\long\def\comment#1{}
\newcommand{\outline}{\comment}
\newcommand{\aside}[1]{{\narrower{\noindent\sf#1}\hfil\par}}

% redefine appendix to give appendices for each chapter
% instead of entire document -- jbe
\def\cappendix{\par
	\clearpage
	\setcounter{section}{0}
	\setcounter{subsection}{0}
	\def\appendixsection##1{\section{Appendix: ##1}
		\setcounter{equation}{0}}
	\def\thesection{\thechapter.\Alph{section}}
	\def\theequation{{\rm \thechapter.\Alph{section}.\arabic{equation}}}
	% start of first derivation section of appendix
	\def\apxfsec##1{{\it Equation (\ref{##1}):}}
	% start of other derivation sections of appendix
	\def\apxsec##1{\bigskip \par \noindent {\it Equation (\ref{##1}):}}}
\def\unappendix{\par
	\setcounter{section}{0}
	\setcounter{subsection}{0}
	\def\thesection{\thechapter.\arabic{section}}
	\def\theequation{{\rm \thechapter.\arabic{equation}}}}

%
\comment{

  Example of use:
    \documentstyle[12pt,puthesis]{report}
    \begin{document}
    \title{How to Write Theses\\
 	    With Two Line Titles}
    \author{John Henry Candidate}
    \principaladviser{John Parker}
    \firstreader{John Smallberries}
    \secondreader{John BigBooty\\(Yoyodyne Corporation)}
 
    \beforepreface
    \prefacesection{Preface}
        This thesis tells you all you need to know about...
    \prefacesection{Acknowledgements}
        I would like to thank...
    \afterpreface
 
    \chapter{Introduction}
         ...
    \chapter{Conclusions}
         ...
    \appendix
    \chapter{A Long Proof}
         ...
    \bibliographystyle{cacm}
    \bibliography{mybib}
    \addcontentsline{toc}{chapter}{Bibliography}
  End of example


Documentation:
    This style file modifies the standard report style to follow the
    Graduate School's recommendations.  It sets the margins, interline
    spacing, the figure and table numbering style, and disallows page
    breaks at hyphens.

    The \beforepreface command creates the title page, a copyright page
    (optionally), and a signature page.  Then the user should put
    preface section(s), using the \prefacesection{section title}
    command.  The \afterpreface command then produces the tables of
    contents, tables and figures, and sets things up to start
    the main body (on arabic page 1).
    
    The following commands can control what goes in the front matter
    material:
    
	\title{thesis title}
	\author{author's name}
	\dept{author's department}
		- Electrical Engineering by default
	\principaladviser{the principal advisor's name}
	   (or \principaladvisor, if you prefer advisor spelled with o)
	\firstreader{the first reader's name}
	\secondreader{the second reader's name}
	\submitdate{month year in which submitted to GS}
		- default is date LaTeX'd
	\copyrightyear{year degree conferred (next year if submitted in Dec.)}
		- year LaTeX'd (or next year, in December) by default
	\copyrighttrue or \copyrightfalse
		- produce or don't produce a copyright page (true by default)
	\signaturetrue or \signaturefalse
		- produce or don't produce a signature page (true by default)
	\figurespagetrue or \figurespagefalse
		- produce or don't produce a List of Figures page
		  (true by default)
	\tablespagetrue or \tablespagefalse
		- produce or don't produce a List of Tables page
		  (true by default)

    This style uses interline spacing that is 1.3 times normal, except
    in the figure and table environments where normal spacing is used.
    That can be changed by doing:
	\renewcommand{\baselinestretch}{1.6}
    (or whatever you want instead of 1.6)
    Unfortunately, that command probably won't take effect unless it comes
    before the \begin{document} or after something like \small \normalsize.

    The example above shows the 12pt substyle being used.  This seems to give
    acceptable looking results, but it may be changed to get smaller print.

}
%
\makeatletter
% We need 1" margins except on the binding edge, where it is 1 1/2"
\oddsidemargin 0.55in \evensidemargin 0in
\marginparwidth 40pt \marginparsep 10pt
\topmargin 0pt \headsep .5in
\textheight 8.1in \textwidth 6in

% Disallow page breaks at hyphens (this will give some underfull vbox's,
% so an alternative is to use \brokenpenalty=100 and manually search
% for and fix such page breaks)
\brokenpenalty=10000

% Use 1.3 times the normal baseline-to-baseline skip
\renewcommand{\baselinestretch}{1.5}

% Figures and tables are to be numbered sequentially throughout the
% thesis, rather than within chapters; for style consistency, do
% equations the same.  The following \def of \cl@chapter is a kludge:
% really there should be a \removefromreset, to stop figure numbers, etc.,
% from being reset at chapter beginnings
% CURRENTLY DISABLED
%\def\cl@chapter{\@elt{section}\@elt{footnote}}
%\def\thefigure{\@arabic\c@figure}
%\def\thetable{\@arabic\c@table}
%\def\theequation{\arabic{equation}}

% Redefine the macro used for chapter headings; the report style headings
% are too large and look queer. -- jbe
%\def\@makechapterhead#1{ \vspace*{50pt} { \parindent 0pt \raggedright
 %\ifnum \c@secnumdepth >\m@ne \LARGE \bf \@chapapp{} \thechapter \par
 %\vskip 20pt \fi \LARGE \bf #1\par
 %\nobreak \vskip 40pt } }
%\def\@makeschapterhead#1{ \vspace*{50pt} { \parindent 0pt \raggedright
 %\LARGE \bf #1\par
 %\nobreak \vskip 40pt } }

% Redefined by me---echong
\def\@makechapterhead#1{ \vspace*{20pt} {\parindent 0pt \raggedright
 \ifnum \c@secnumdepth >\m@ne \LARGE \bf \hfill \@chapapp{} \thechapter
 \vskip 10 pt\hrule \par
 \vskip 30pt \fi \Huge \bf\begin{center} #1\end{center}\par
 \nobreak \vskip 40pt } }
\def\@makeschapterhead#1{ \vspace*{30pt} {\parindent 0pt \raggedright
 \Huge \bf #1\par
 \nobreak \vskip 40pt } }

% Redefine the macro used for floats (including figures and tables)
% so that single spacing is used.
% (Note \def\figure{\@float{figure}set single spacing} doesn't work
%  because figure has an optional argument)
\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}

% Redefine the macro used for footnotes to use single spacing
\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}}}

% \author, \title are defined in report; here are the rest of the
% front matter defining macros
\def\dept#1{\gdef\@dept{#1}}
\def\principaladviser#1{\gdef\@principaladviser{#1}}
\def\advis@r{Adviser} % default spelling
\def\principaladvisor#1{\gdef\@principaladviser{#1}\gdef\advis@r{Advisor}}
\def\firstreader#1{\gdef\@firstreader{#1}}
\def\secondreader#1{\gdef\@secondreader{#1}}
% Princeton says that theses should have the date set to the date the
% Trustee's grant the degree
\def\submitdate#1{\gdef\@submitdate{#1}}
\def\copyrightyear#1{\gdef\@copyrightyear{#1}} % \author, \title in report
\def\@title{}\def\@author{}\def\@dept{electrical engineering}
\def\@principaladviser{}\def\@firstreader{}\def\@secondreader{}
\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}
% Stanford says that December theses should have the next year as the
% copyright year (I don't know about Princeton)
\ifnum\month=12
    \@tempcnta=\year \advance\@tempcnta by 1
    \edef\@copyrightyear{\number\the\@tempcnta}
\else
    \def\@copyrightyear{\number\the\year}
\fi

% conditional page checks
\newif\ifcopyright \newif\ifsignature
\newif\iftablespage \newif\iffigurespage
% default page additions
\copyrighttrue \signaturetrue


\def\titlep{
	\thispagestyle{empty}
	\null\vskip0.4in
	\begin{center}
		\baselineskip 40pt
		{\protect\Huge\uppercase\expandafter{\@title}}
		\null\vskip0.5in
		\Large\expandafter{\@author}
		\null\vskip0.9in
	\end{center}
	\vfill
	\begin{center}
		\sc a dissertation\\
		presented to the faculty \\
		of princeton university\\
		in candidacy for the degree\\
		of doctor of philosophy\\
		\vskip0.5in
		recommended for acceptance\\
		by the department of\\
			\lowercase\expandafter{\@dept}\\
	\end{center}
	%\vfill
	\begin{center}
		\vskip0.4in
		\@submitdate\\
	\end{center}%\vskip.5in
	\newpage}

\def\copyrightpage{
	\vspace*{3in}
	\null\vfill
	\begin{center}
		\large\copyright\ Copyright \@copyrightyear\ 
		by
		\@author.\\
		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 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\signaturepage{
	\signature{\@principaladviser\\(Principal \advis@r)}
	\vfill
	\signature\@firstreader
	\vfill
	\signature\@secondreader
	\vfill
	\begin{center}
	\begin{minipage}{4in}
	Approved for the Princeton University Graduate School:\par
	\vspace{.5in}
	\hbox to 4in{\hfil\shortstack{\vrule width 3in height 0.4pt\\
			Dean of the Graduate School}}
	\end{minipage}
	\end{center}}

\def\beforepreface{
	\pagenumbering{roman}
	\pagestyle{plain}
	\titlep
	\ifcopyright\copyrightpage\fi
	\ifsignature\signaturepage\fi
	}

\def\prefacesection#1{
%\chapter*{#1}
\clearpage \thispagestyle{plain} \global\@topnum\z@
\@afterindentfalse
%\vspace*{50pt} 
\vspace*{20pt} 
{ \parindent 0pt \raggedright
\centering \Huge \bf #1\par
\nobreak \vskip 40pt } 
\@afterheading
	\addcontentsline{toc}{chapter}{#1}}

% Redefine "headings" so that not uppercased.---echong
\def\ps@headings{\let\@mkboth\markboth
\def\@oddfoot{}\def\@evenfoot{}\def\@oddhead{\hbox {}\sl \rightmark
\hfil
\rm\thepage}\def\chaptermark##1{\markright {\ifnum
\c@secnumdepth
>\m@ne
 \@chapapp\ \thechapter: \ \fi ##1}}}

% Redefine "newtheorem" to put a colon after the number. E.Chong
\def\@begintheorem#1#2{\it \trivlist \item[\hskip \labelsep{\bf #1\ #2:}]}
\def\@opargbegintheorem#1#2#3{\it \trivlist 
      \item[\hskip \labelsep{\bf #1\ #2\ (#3):}]} 

% Set counter for theorems to be Chapter.Number
\def\@thmcounter#1{\noexpand\arabic{#1}}

% The \addvspace business below is to avoid the extra space that gets put
% in the tables of figures and tables between chapters (it makes no sense
% now that the numbering is continuous)
\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{headings}}

\pagestyle{headings}
