%
% dissertation.cls - University of Maryland doctoral dissertation class
%
% AUTHORS
%    - Pablo A. Straub, Department of Computer Science, University of Maryland
%    - stepped-up to LaTeX2e + some fixes by Jason Lohn
%    - some fixes by Gary Flake (added by JL)
%
% COPYRIGHT
%    (c) Copyright 1991 by Pablo A. Straub.  Permission is granted to copy
%    and use this material for any purpose except direct commercial advantage.
%
% VERSION 1.0
%
% HISTORY (dissertation.cls)
%    May 12 00 - Updated the title page wording.  Removed the column labels in
%                the table of contents (Section & Page).  Also removed column
%	         labels in list of figures and list of tables (Number & Page).  
%
%    Aug 31 95 - dissertation.sty version 2.0 stepped-up to LaTeX2e class
%                and renamed dissertation.cls (version 1.0)
%                Various fixes.
%
% HISTORY (dissertation.sty)
%    Aug 19 91 - First version
%
%    Aug 20 91 - Add redefinition of \@options and remove \input{rep12.sty}.
%              - Change \@ifdefined{@abstractfile}{\makeabstract} to
%                \ifx\@empty \abstractfile \else \makeabstract \fi.
%              - Change \input to \@input for abstract and preface (i.e.,
%                if file is absent give a warning instead of asking for
%                another file.)
%
%    Aug 21 91 - Write captions in single space (captiontable, captionfigure)
%
%    Aug 22 91 - Add optional list entry to captiontable and captionfigure
%              - Add externalfigure command
%              - Add definition of \ds@10pt to enable option 10pt in
%                \documentstyle command
%
%    Aug 30 91 - Add definitions of \footskip and \footnotesep
%              - Enlarge margins to allow for printer or copier shifts
%              - Correct spacing in tiltle page according to the Office of
%                Graduate Studies and Research
%
%    Sep  3 91 - Add saving document style option (to use less paper in drafts
%                and make technical reports) and \ifsaving command
%
%    Sep 13 91 - Change name from dissertation.doc to disseration.sty.
%
%    Sep 26 91 - Put \addcontentsline before \listoffigures and \listoftables
%                to have the right page number when the list is one page or
%                longer
%              - Add \page command
%              - Rename \newbaselinestretch to the simpler \spacing
%
%    Nov  2 91 - Add the masters style option and the \masterof command
%
% DOCUMENTATION
%    Pablo A. Straub, ``The {\tt dissertation} \LaTeX\ Style,''
%    UMIACS-TR-91-134, CS-TR-2768, UMIACS and Department of Computer Science,
%    University of Maryland at College Park, 1991.
%
% INSTALLATION
%    Copy dissertation.cls into LaTeX directory (/usr/imports/lib/tex/latex)
%    or in a directory in the TeX path (environment variable TEXINPUTS).
%
% CONTENTS
%
%    1. Option processing and inclusion of report standard file
%    2. Margins and spacing
%    3. Commands to define parameters for the front matter
%    4. Command \makefrontmatter
%    5. Commands to create different parts of the front matter
%    6. Cross references
%    7. Captioned figures and tables
%    8. Other commands

% ----------------------------------------------------------------------
% 1. Option processing and inclusion of report standard file
% ----------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{dissertation}
              [1995/08/31 v1.0
               Univ of Md LaTeX document class]

\def\diss@temp#1{\@ifundefined{if#1}%
  {\def\@tempa{\csname newif\endcsname}
  \expandafter\@tempa\csname if#1\endcsname}{}}
\diss@temp{saving}{}
\diss@temp{masters}{}
\newcommand{\@repsize}{12pt}     %default font size
\newcommand{\@flakespace}{321pt} %default for 12pt text
\DeclareOption{10pt}{\renewcommand{\@repsize}{10pt}%
                     \renewcommand{\@flakespace}{334pt}}
\DeclareOption{11pt}{\renewcommand{\@repsize}{11pt}%
                     \renewcommand{\@flakespace}{328pt}}
\DeclareOption{12pt}{\renewcommand{\@flakespace}{321pt}}
\DeclareOption{saving}{\savingtrue}
\DeclareOption{masters}{\masterstrue}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions
\LoadClass[\@repsize]{report}

% ----------------------------------------------------------------------
% 2. Margins and spacing
%
% Rules taken from pages 10-12 of the Style and Policy Manual.
% ----------------------------------------------------------------------
\ifsaving
  \setlength {\topmargin}{0in}		% top margin    1.0 inch
  \setlength {\textheight}{8.5in}	% bottom margin 1.5 inch
  \setlength {\oddsidemargin}{0in}	% left margin   1.0 inch
  \setlength {\textwidth}{6.5in}	% right margin  1.0 inch
\else
  \setlength {\topmargin}{0.1in}	% top margin    1.10 inch
  \setlength {\textheight}{8.4in}	% bottom margin 1.50 inch
  \setlength {\oddsidemargin}{0.6in}	% left margin   1.60 inch
  \setlength {\textwidth}{5.65in}	% right margin  1.25 inch
  \setlength {\footskip}{0.8in}		% two blank lines before page number
\fi

\setlength {\footnotesep}{14pt}		% baseline skip for footnotes' 1st line
\setlength {\headheight}{0in}		% no header
\setlength {\headsep}{0in}		% no header separation


% \spacing - redefine \baselinestretch and recompute \baselineskip
%            lateral effect: set typeface to normalize roman

\def\spacing#1{\renewcommand{\baselinestretch}{#1}\large\normalsize}

\ifsaving
  \spacing{1}				% single spacing for drafts
\else
  \spacing{1.667}			% double spacing for final
\fi

% ----------------------------------------------------------------------
% 3. Commands to define parameters for the front matter
% 
% There are two kinds of commands that define parametters for the  front
% matter:  those  that  provide info (like \author or \abstractfile) and
% those that set flages (like \hascopyright).
% 
% All commands that provide info redefine an internal command named  the
% same but with an initial at sign (e.g., \advisor redefined \@advisor).
% This  idea is standard in LaTeX, so \author, \title, and \date are not
% defined here (the standards are used).
%  
% All commands that set  flags  are  used  to  set  the  status  of  the
% corresponding if command. The parameter must be true or false, or else
% a `Undefined control sequence command' will be issued by TeX.

% ----------------------------------------------------------------------
% The following are the definitions of the commands  that  provide  info
% (standard  LaTeX  commands  like  \author are omitted because they are
% already defined).
% ----------------------------------------------------------------------

\def\advisor#1{\gdef\@advisor{#1}}
\def\chairtitle#1{\gdef\@chairtitle{#1}}
\def\committee#1{\gdef\@committee{#1}}
\def\department#1{\gdef\@department{#1}}
\def\abstractfile#1{\gdef\@abstractfile{#1}}
\def\masterof#1{\gdef\@masterof{#1}}
\def\prefacefile#1{\gdef\@prefacefile{#1}}
\long\def\dedication#1{\long\gdef\@dedication{#1}}
\long\def\acknowledgements#1{\long\gdef\@acknowledgements{#1}}
\long\def\comment#1{\long\gdef\@comment{#1}}

% ----------------------------------------------------------------------
% The following are the initial values for some commands that provide info.
% ----------------------------------------------------------------------

\gdef\@author{{\it Your Full Name}}
\gdef\@title{{\it Your Dissertation Title}}
\gdef\@date{\number\year}
\gdef\@advisor{{\it Academic title and name of advisor}}
\gdef\@chairtitle{Chairman/Advisor}
\gdef\@committee{{\it Academic title and name of members}}
\gdef\@department{Department of Computer Science}
\def\@abstractfile{abstract}
\gdef\@masterof{Science}


% The following are all switch setting commands along with their initial
% values and corresponding \newif definitions.

\newif\ifhascopyright
\hascopyrighttrue
\def\hascopyright#1{\csname hascopyright#1\endcsname}

\newif\ifhasfigures
\hasfigurestrue
\def\hasfigures#1{\csname hasfigures#1\endcsname}

\newif\ifhastables
\hastablestrue
\def\hastables#1{\csname hastables#1\endcsname}

% ----------------------------------------------------------------------
% 4. Command \makefrontmatter
%        
% The \makefrontmatter command creates the front matter by conditionally
% invoking other commands:
%  
%       \makeabstract, \maketitlepage, \makecopyrightpage, \makepreface,
%       \makededication, \makeacknowledgements, \tableofcontents,
%       \makelistoftables, \makelistoffigures, \makecommentpage.
%
% \makefrontmatter takes care of numbering in lowercase roman, arabic or
% none.
% ----------------------------------------------------------------------
\def\makefrontmatter{
 \pagestyle {empty}
 \ifx\@empty \@abstractfile \else \makeabstract \fi
 \maketitlepage
 \makecopyrightpage
 \pagestyle {plain}
 \pagenumbering {roman}
 \setcounter {page}{2}
 \@ifdefined {@prefacefile}{\makepreface}
 \@ifdefined {@dedication}{\makededication}
 \@ifdefined {@acknowledgements}{\makeacknowledgements}
 \tableofcontents\newpage
 \ifhastables \makelistoftables \fi
 \ifhasfigures \makelistoffigures \fi
 \pagenumbering {arabic}
 \setcounter {page}{0}
 \makecommentpage
}

% ----------------------------------------------------------------------
% 5. Commands to create different parts of the front matter
% ----------------------------------------------------------------------

% first, set masters flag
  \ifmasters 
    \gdef\@thesis{Thesis}}
  \else
    \def\@thesis{Dissertation}
  \fi 

% \makeabstract - create the abstract page(s) including title, author, etc.

% Abstract text may be included inside \abstract{ ... } or in an
% external file. Either \abstractfile{...} or \abstract will be used
  \def\@abshere{none}
  \long\def\abstract#1{\long\gdef\@abstract{#1}}
  \gdef\@abstract{none}

\def\makeabstract{
 \newpage
 \vspace*{.8in}
 {\spacing{1.1}
 \begin{center}\Large\bf Abstract \end{center}
 \bigskip\par\noindent
 Title of \@thesis: \hspace{0.25in}{\large \begin{tabular}[t]{l} \@title \end{tabular}}
 \bigskip\par\noindent
 \ifmasters
  \Name of degree candidate: \@author
  \bigskip\par\noindent
  Degree and year: Master of \@masterof, \@date
 \else
  %\begin{center}
 \hspace{1.9in}\@author, Doctor of Philosophy, \@date
  % \end{center}
 \fi
 \bigskip\par\noindent
 \@thesis\ directed by:
 \begin{tabular}[t]{l}\@advisor \\ \@department\end{tabular}
 \hugeskip\par\mbox{}\hugeskip\par}
 %%%---insert proper abstract text---
   \ifx\@abstract \@abshere
     \@input{\@abstractfile}
   \else
     \@abstract
   \fi
 \newpage}


% \maketitlepage - create the title page according to a complex format

\def\maketitlepage{
 \newpage
 \vspace*{.85in}
 \begin{center}
 \spacing{1.3}
 {\Large\bf \begin{tabular}[t]{c}\@title\end{tabular}}
 \\ \hugeskip
 {\large by \\ \bigskip \@author}
 \end{center}
 \hugeskip
 {\spacing{1}
 \begin{center}
 \ifmasters Thesis \else Dissertation \fi
          submitted to the Faculty of the Graduate School of the \\
 University of Maryland at College Park in partial fulfillment \\
 of the requirements for the degree of \\
 \ifmasters Master of \@masterof \else Doctor of Philosophy \fi \\
 \@date
 \end{center}
 \hugeskip\par\mbox{}\hugeskip\par\hspace*{15pt}
 Advisory Committee:
 \medskip\par\hspace*{60pt}
 \begin{tabular}[t]{l}\@advisor, \@chairtitle \\ \@committee \end{tabular}}
 \newpage}


% \makecopyrightpage - create a copyright page or an empty page

\def\makecopyrightpage{
 \newpage
 \mbox{}\par\vfill
 \ifhascopyright
  {\large
  \begin{center}
  \boldmath $\copyright$ Copyright by \\
  \@author \\
  \@date
  \end{center}}
  \vfill
 \fi
 \newpage}


% \makepreface - create a preface from file \@prefacefile

\def\makepreface{
 \newpage
 \chapter*{Preface}
 \@input{\@prefacefile}
 \newpage}


% \makededication - create a dedication page

\def\makededication{
 \newpage
 \vspace*{2in}
 \begin{center}\LARGE\bf Dedication \end{center}
 \hugeskip\par\noindent
 \begin{quote} \@dedication \end{quote}
 \newpage}


% \makeacknowledgements - create an acknowledgements page

\def\makeacknowledgements{
 \newpage
 \vspace*{2in}
 \begin{center}\LARGE\bf Acknowledgements \end{center}
 \hugeskip\par\noindent
 \begin{quote} \@acknowledgements \end{quote}
 \newpage}


% \makelistoftables - create the list of tables

\def\makelistoftables{
 \newpage
 \addcontentsline {toc}{chapter}{List of Tables}
 \listoftables
 \newpage}


% \makelistoffigures  - create the list of figures

\def\makelistoffigures{
 \newpage
 \addcontentsline {toc}{chapter}{List of Figures}
 \listoffigures
 \newpage}


% \makecommentpage - create a (possibly empty) comment page

\def\makecommentpage{
 {\spacing{1}
 \begin{center}\@title \\[1ex]  \@author \\[1ex] \today \end{center}
 \par\vfill
 \@ifdefined{@comment}{\@comment}
 \par\vfill}
 \begin{center} \large\bf This comment page is not part of the dissertation.
 \\[3ex]
 \footnotesize Typeset by \LaTeX\ using the {\tt dissertation} class by
               Pablo A. Straub, University of Maryland.
 \end{center}
 \newpage}

% ----------------------------------------------------------------------
% 6. Cross references
%
% The following commands facilitate cross references, by using the \ref
% or \pageref command in context.
% ----------------------------------------------------------------------

\newcommand{\Chapter}[1]{Chapter~\ref{#1}}

\newcommand{\Section}[1]{Section~\ref{#1}}

\newcommand{\Figure}[1]{Figure~\ref{#1}}

\newcommand{\Table}[1]{Table~\ref{#1}}

\newcommand{\page}[1]{page~\pageref{#1}}

% ----------------------------------------------------------------------
% 7. Captioned figures and tables
%
% captionfigure - a figure environment with a label, an optional List of
%                 Figures entry and a caption
% ----------------------------------------------------------------------

\def\captionfigure#1{
 \@ifnextchar [{\@captionfigure{#1}}{\@dblarg{\@captionfigure{#1}}}}

\def\@captionfigure#1[#2]#3{
 \def\@captionlabel{#1}
 \def\@captionlistentry{#2}
 \def\@captionheading{#3}
 \begin{figure}}

\def\endcaptionfigure{
 \spacing{1}
 \caption [\@captionlistentry]{\@captionheading}
 \label {\@captionlabel}
 \end{figure}}


% \externalfigure - a captionfigure from an external file (filename = label)

\def\externalfigure#1{
 \@ifnextchar [{\@externalfigure{#1}}{\@dblarg{\@externalfigure{#1}}}}

\def\@externalfigure#1[#2]#3{
 \begin{captionfigure}{#1}[#2]{#3}\centering\@input{#1}\end{captionfigure}}


% captiontable - a tabular environment nested within a table environment with
%                a label, an optional List of Tables entry and a caption

\def\captiontable#1{
 \@ifnextchar [{\@captiontable{#1}}{\@dblarg{\@captiontable{#1}}}}

\def\@captiontable#1[#2]#3{
 \def\@captionlabel{#1}
 \def\@captionlistentry{#2}
 \def\@captionheading{#3}
 \begin{table}
 \centering
 \begin{tabular}}

\def\endcaptiontable{
 \end{tabular}
 \spacing{1}
 \caption [\@captionlistentry]{\@captionheading}
 \label {\@captionlabel}
 \end{table}}

% ----------------------------------------------------------------------
% 8. Other commands
% ----------------------------------------------------------------------

% \hugeskip - skip twice as much as the TeX command \bigskip

\def\hugeskip{\vskip 24pt plus 8pt minus 8pt}


% \@ifdefined - expand #2 if command #1 is not defined

\def\@ifdefined#1#2{\@ifundefined{#1}{}{#2}}


% \@makechapterhead \@makeschapterhead - create a chapter head
%
% These standard LaTeX commands are redefined here to use not-so-huge type

\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 } }

%%% -------------------------------------------------------------------------
%%% Gary Flake fixes below.  First, his explanation.
%%%
%%% The code below redefines LaTeX's TOC, LOT, and LOF commands to do the
%%% right stuff.  One problem with my kluge is that the command
%%% \contentsline{}{} is too smart; if you you use it for a TOC it will
%%% not use doted lines if it is on the chapter level; yet, for all LOF
%%% and LOT entries it uses dotted lines.  To get around this problem (we
%%% obviously don't want dotted lines between the "Number" and "Page"
%%% entries) I had to force the issue with \hspace*{\@flakespace}.
%%%
\def\tableofcontents{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
 \fi\chapter*{\begin{center}Table of Contents\end{center}
 \@mkboth{TABLE OF CONTENTS}{TABLE OF CONTENTS}}
% \contentsline{chapter}{\underline{Section}}{\underline{Page}}
 \@starttoc{toc}\if@restonecol\twocolumn\fi}

\def\listoffigures{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
 \fi\chapter*{\begin{center}List of Figures\end{center}\@mkboth
 {LIST OF FIGURES}{LIST OF FIGURES}}
% \contentsline{figure}{\ignorespaces\underline{Number}
% \hspace*{\@flakespace}\underline{Page}}{}
 \addvspace{10pt}\@starttoc{lof}\if@restonecol \twocolumn\fi}

\def\listoftables{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
 \fi\chapter*{\begin{center}List of Tables\end{center}\@mkboth
 {LIST OF TABLES}{LIST OF TABLES}}
% \contentsline{table}{\ignorespaces\underline{Number}
% \hspace*{\@flakespace}\underline{Page}}{}
 \addvspace {10pt}\@starttoc{lot}\if@restonecol \twocolumn\fi}
%%% -------------------------------------------------------------------------


\endinput
%% 
%% End of file `dissertation.cls'.
