%
% Dalhousie University thesis style
% Dept. of Math. Stats. and Comp. Sci.
%
% Modification of:
%
%-% Stanford University PhD thesis style -- modifications to the report style
%-% For LaTeX version 2.09
%-% Last edit Tue Sep 13 14:40:26 1988
%-% Last edit by Joseph Pallas
%
% Modifications by Steven Matheson, May 1990
%       - Changed baselinestretch to 1.37.
%       - Changed \dept default to MS&CS and other name changes.
%       - Allow user to specify university and faculty
%       - Changed page headings to be page number only, except on
%         the first page of each chapter (page number at bottom).
%       - Redefined title and signature page.
%       - Added optional permission page (formly supplied by
%         Graduate Studies).  Page skipped if omitted.
%       - User can define degree to be recieved.
%         \msc (default), \ma, and \phd provided.
%       - Signature page slightly different for Ph.D.
%       - Two to three readers' signatures for Masters thesis,
%         three to five readers' signatures for Ph.D.
%       - Convocation date is either given or calculated.
%       - Two supervisors supported.
%       - Added dedication page environment.
%       - List of tables and figures recorded in table of
%         contents.
%       - User can omit front material or bibliography for
%         draft printing purposes.
%       - User can specify draft copies, "draft copy" and date
%         printed on title page and headers.
%       Bugs:
%       - TeX complains too much about the front material, ignore
%         under/overfull box messages on pages ii and iii.
%         (Better yet, can somebody fix this?)
%       - Cannot handle department name more than 4-5 characters
%         longer than MS&CS (does one exist?).
%       - Occassional screw ups when adding diferent university,
%         department and faculty names.
%       - Would also have difficultly with very long author names.
%
% Modifications by Steven Matheson, Sept 1992
%       - Added the forgotten `` \\'' after thrid signature on signature page,
%         caused third and fourth signatures to be too close.
%
% Last edit Sept. 11, 1992
%

\typeout{Document Style Option `dalthesis'.}

\long\def\comment#1{}
\comment{

  Example of use:
    \documentstyle[12pt,dalthesis]{report}
    \begin{document}
    \title{How to Write Theses\\
        With Two Line Titles}
    \author{John Henry Candidate}
    \supervisor{John Parker}
    \firstreader{John Green}
    \secondreader{John BigBooty}

    \dedicate{
    This is the optional\\
    dedication page.\\
    Break lines up\\
    like this.
    }

    \beforepreface

    \prefacesection{Abstract}
    An abstract is required in all theses.  Make sure that it fits
    on one page!

    \afterpreface

    \chapter{Introduction}
     ...
    \chapter{Conclusions}
     ...
    \appendix
    \chapter{A Long Proof}
     ...
    \bibliographystyle{plain}
    \bibliography{mybib}
    \end{document}

Documentation:
    This style file modifies the standard report style to follow the
    Dalhousie University Faculty of Graduate Studies' "Regulations for
    Submission of Theses".  It sets the margins and required interline
    spacing and disallows page breaks at hyphens.

    The \beforepreface command creates the title page, a signature page,
    and a permission page (optionally).  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 (optionally), and sets things up to
    start the main body (on arabic page 1).

    The following commands control the typesetting of your thesis:

   Basic Information:

    \title{thesis title}
        - Will appear in large print on page i.  If it is too
          long it will automatically be split into separate
          lines.  If you wish to specify line breaks, use the
          \\ command inside the title.
          \title{Very Long\\Title\\Split Over\\Several Lines}
          Make sure that there is no space before \\.

    \author{author's name}
        - Your name as you wish it to appear in the thesis.

   Graduation and Submission Information:

    \submitdate{month year in which submitted to Graduate Studies}
        - date LaTeX'd if omitted

    \copyrightyear{year thesis}
        - year LaTeX'd if omitted

    \convocation{month}{year}
        - Date set to next May or Oct. after \submitdate if omitted

   Degree Specification:

    \msc
        - Degree to obtain is Master of Science, M.Sc. (default)
    \ma
        - Degree to obtain is Master of Arts, M.A.
    \phd
        - Degree to obtain is Doctor of Philosophy, Ph.D.

   Signatures:

    \examiner{the external examiner's name}
        - Use only for Ph.D.
    \supervisor{the supervisor's name}
        - Include research supervisor's name.
    \firstreader{the first reader's name}
        - Include the first reader's name.
    \secondreader{the second reader's name}
        - Include the second reader's name.
    \thirdreader{the third reader's name}
        - Omit this command if only two readers (typical M.Sc. case)
        - Ph.D. cases usually have at least three readers
    \fourthreader{the third reader's name}
        - Omit this command if not required (typical Ph.D. case)
    \fifthreader{the third reader's name}
        - Omit this command if not required (typical Ph.D. case)

    Sorry, provisions has been made to allow only seven signatures.


   Sectioning commands::

    \dedicate{
      First line\\
      second line\\
      last line.
    }
        - Produces the optional dedication page.  Must be placed
          before the \beforepreface command.

    \prefacesection{Whatever}
    Blah, blah, blah...
        - Produces a preface section, such as abstract,
          acknowledgments, etc.  This must appear between
          \beforepreface and \afterpreface commands.
          Typeset similar to chapters, not numbered.

    \chapter{Whatever}
    Blah, blah, blah...
        - Produce a numbered chapter section.

    \section{Section name}
        - Place prior to a section of a given chapter.

    \subsection{Subsection name}
        - Place prior to a subsection of a given section.

    \appendix
        - Place this command before your first appendix chapter.
          Use the \chapter command thereafter.  These will be
          lettered, not numbered.

    \nonumchapter{Whatever}
    Blah, blah, blah...
        - Produces a chapter section that is not to be numbered,
          such as an introduction chapter.  This is used in the
          same way as the \chapter command.

   Printing draft copies:

    \draft
        - For printing draft copies of the thesis.  Specifies
          on page headers that the copy is draft and specifies
          the date printed.  Also specifies draft and date on
          the title page.
    \nofront
        - Specifies not to print the signature and permission
          pages, table of contents, and the lists of figures and
          tables.  Useful for draft copies to cut done on printing.
    \nobib
        - Suppresses the printing of the bibliiography.
          Useful for draft copies to cut done on printing.

   Specialized commands:

    \nolistoffigures
        - don't produce a List of Figures
    \nolistoftables
        - don't produce a List of Tables
    \twosupervisors
        - Use if you have two cosupervisors instead of one supervisor.
          Name given by \supervisor{} will go first, \firstreader{}
          will be second.  Can be used with Ph.D. format.
    \univerity{name of university}
        - ``Dalhousie University'' default.  Can specify line breaks
          for larger names.
    \address{university address}
        - ``Halifax, Nova Scotia'' default.
    \dept{author's department}
        - ``Mathematics Statistics and Computing Science'' default
    \faculty{degree granting faculty}
        - [Faculty of] ``Graduate Studies'' default
    \degree{Full Degree Title}
    \degreeinitial{F.D.T.}
        - Specify degree name and initials
          \degree{Master of Business Administration}
          \degreeinitial{M.B.A.}
    \permissionfalse
        - don't produce a permission page (true by default)

This style uses interline spacing that is 1.37 times normal, except
in the figure and table environments where normal spacing is used.
That can be changed by doing:

    \renewcommand{\baselinestretch}{1.5}
(or whatever you want instead of 1.5)

Unfortunately, that command probably won't take effect unless it comes
before the \begin{document} or after a type size changing command like
\small or \normalsize.

The example above shows the 12pt substyle being used.  This is required
for submission copy, but it may be omitted to get smaller draft print.
Note that the front material may not look good in smaller print.

}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{2}

% Define the page heading to be page number only.
\newcommand{\properpagestyle}{
       \pagestyle{myheadings}\markboth{}{}\markright{}}

% First thing we do is make sure that report has been loaded.  A
% common error is to try to use suthesis as a documentstyle.
\@ifundefined{chapter}{\@latexerr{The `dalthesis' option should be used
with the `report' document style}{You should probably read the
dalthesis documentation.}}{}

% We need 1" margins except on the binding edge, where it is 1 1/2"
% Theses are single-sided, so we don't care about \evensidemargin
\oddsidemargin 0.5in \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.37 times the normal baseline-to-baseline skip
\renewcommand{\baselinestretch}{1.37}

% 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\university#1{\gdef\@university{#1}}
\def\address#1{\gdef\@address{#1}}
\def\dept#1{\gdef\@dept{#1}}
\def\faculty#1{\gdef\@faculty{#1}}
\def\supervisor#1{\gdef\@supervisor{#1}}
\def\superviser#1{\gdef\@supervisor{#1}}
\def\firstreader#1{\gdef\@firstreader{#1}}
\def\secondreader#1{\gdef\@secondreader{#1}}
\def\thirdreader#1{\gdef\@thirdreader{#1}\third@readertrue}
\def\fourthreader#1{\gdef\@fourthreader{#1}\fourth@readertrue}
\def\fifthreader#1{\gdef\@fifthreader{#1}\fifth@readertrue}
\def\examiner#1{\gdef\@examiner{#1}}
\def\twosupervisors{\two@supervisorstrue}
\def\submitdate#1{\gdef\@submitdate{#1}}
\def\copyrightyear#1{\gdef\@copyrightyear{#1}} % \author, \title in report
\def\degree#1{\gdef\@degree{#1}}
\def\degreeinitial#1{\gdef\@degreeinitial{#1}}
\def\msc{\degree{Master of Science}\degreeinitial{M.Sc.}}
\msc % default degree
\def\phd{\degree{Doctor of Philosophy}\degreeinitial{Ph.D.}\ph@dtrue}
\def\ma{\degree{Master of Arts}\degreeinitial{M.A.}}
\def\@title{}
\def\@author{}
\def\@university{Dalhousie University}
\def\@address{Halifax, Nova Scotia}
\def\@dept{Mathematics Statistics and Computing Science}
\def\@faculty{Graduate Studies}
\def\@supervisor{}\def\@firstreader{}\def\@secondreader{}
\def\@thirdreader{}\def\@fourthreader{}\def\@fifthreader{}
\def\@examiner{}
\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}
\def\@copyrightyear{\number\the\year}

\def\convocation#1#2{\gdef\@convocationmonth{#1}\gdef\@convocationyear{#2}}
\def\@convwarn{\typeout{Warning!  Convocation date may be incorrect!}}
\ifnum\month<5
   \def\@convocationmonth{May}
   \def\@convocationyear{\number\the\year\@convwarn}
\else\ifnum\month<10
   \def\@convocationmonth{October}
   \def\@convocationyear{\number\the\year\@convwarn}
\else
   \def\@convocationmonth{February}
   \@tempcnta=\year  \advance\@tempcnta by 1
   \def\@convocationyear{\number\the\@tempcnta\@convwarn}
\fi\fi

\def\dedicate#1{\dedic@tiontrue\gdef\dedication@text{#1}}

\def\draft{\renewcommand{\properpagestyle}{\pagestyle{myheadings}
\markright{{\rm Draft Version -- \today}}}\draft@modetrue\properpagestyle}
\def\nobib{\print@bibfalse}
\def\nolistoffigures{\figurespagefalse}
\def\nolistoftables{\tablespagefalse}
\def\nofront{\front@pagesfalse\permissionfalse\figurespagefalse\tablespagefalse}

% New if constructs:    Default conditions:
\newif\ifpermission     \permissiontrue
\newif\iffigurespage    \figurespagetrue
\newif\iftablespage     \tablespagetrue
\newif\iffront@pages    \front@pagestrue
\newif\ifthird@reader   \third@readerfalse
\newif\iffourth@reader  \fourth@readerfalse
\newif\iffifth@reader   \fifth@readerfalse
\newif\ifph@d           \ph@dfalse
\newif\iftwo@supervisors \two@supervisorsfalse
\newif\ifdraft@mode     \draft@modefalse
\newif\ifprint@bib      \print@bibtrue
\newif\ifdedic@tion     \dedic@tionfalse

\def\no@breaks#1{{\def\\{ \ignorespaces}#1}}    % disallow explicit line breaks

\def\titlep{%
    \thispagestyle{empty}%
    \ifdraft@mode
      \begin{center} \Large DRAFT COPY\\ \large Printed \today \end{center}
    \fi
    \null\vskip0.5in
    \begin{center}
        \hyphenpenalty=10000\Large\uppercase\expandafter{\@title}
    \end{center}
    \vfill
    \begin{center}
        \large {Research Proposal for Ph.D. Qualification}\\
     \end{center}
     \vfill
     \vskip+0.35in
     \begin{center}
        \rm Submitted by:\\
        {\large\@author}\\
%        Department of Computer Science\\
%        \vskip-0.1in
%        University of Southern California\\
        \vskip+1.0in
%        Los Angeles, CA 90089\\
%        \vskip-0.1in
%        banaeika@usc.edu\\
         \vfill
        April 2008
    \end{center}
    \begin{center}
    \vfill
    \end{center}
    \begin{center}
    \vskip+0.65in        %\footnotesize
        Guidance Committee: \\
    \end{center}
        {Dr. Cyrus Shahabi} ({\it{Advisor \& Chairperson}}) \dotfill\ Dept. of Computer Science\\
        {Dr. Guarav Sukhatme} \dotfill\ Dept. of Computer Science\\
        {Dr. Aiichiro Nakano} \dotfill\ Dept. of Computer Science\\
        {Dr. Yolanda Gil} \dotfill\ Dept. of Computer Science\\
        {Dr. Carolee J. Winstein} ({\it{Outside Member}}) \dotfill\ Div. of Biokinesiology and Physical Therapy
\\
%    \end{center}
%   \vskip0.75in
    \begin{center}
        %\rm \copyright\ Copyright by \@author, \@copyrightyear
    \end{center}\newpage}

\def\signature#1#2{\parbox[b]{1in}{\smash{#1}\vskip12pt}
\hfill \parbox[t]{3in}{\shortstack{\vrule width 3in height 0.4pt\\\small#2}}}

\def\signaturepage{%
 }

\def\permissionpage{%
}

\def\beforepreface{
\typeout{Most over/underfulls in first few pages are the fault of dalthesis.}
\typeout{Ignore all them.  If uncorrectable errors occur, notify staff.}
    \pagenumbering{roman}
    \pagestyle{plain}
    \titlep
    \iffront@pages\signaturepage\else\addtocounter{page}{1}\fi
    \ifpermission\permissionpage\else\addtocounter{page}{1}\fi
    \iffront@pages\ifdedic@tion
        \newpage\begin{center}\Large\em\null\vskip1in
        \dedication@text
        \vfill\end{center}
    \fi\fi
    \iffront@pages\tableofcontents\else\addtocounter{page}{1}\fi
    \newpage
    \iftablespage
        \addcontentsline{toc}{chapter}{List of Tables}\listoftables
        \newpage
    \fi
    \iffigurespage
        \addcontentsline{toc}{chapter}{List of Figures}\listoffigures
        \newpage
    \fi
    }

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

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

\newenvironment{dedication}{\newpage\begin{center}\Large\em\null\vskip1in}%
{\vfill\end{center}}


\def\afterpreface{\newpage
    \pagenumbering{arabic}
    \typeout{Dalthesis preface pages completed.}
    \properpagestyle}

% Redefine \thebibliography to go to a new page and put an entry in the
% table of contents
\let\@ldthebibliography\thebibliography
\renewcommand{\thebibliography}[1]{%
    \newpage
    \addcontentsline{toc}{chapter}{Bibliography}
    \@ldthebibliography{#1}
}

\let\@ldbibliography\bibliography
\renewcommand{\bibliography}[1]{\ifprint@bib\@ldbibliography{#1}\fi}

% Start out normal
\properpagestyle
