% This is an option style (substyle) for writing a dissertation
% in the Rackham required format using reportx.sty.  -- jin ji, 1/88
% Modified on 05/19/88, jj.
% Modified on 12/13/88, for "CHAPTER" in toc and \@makecaption, jj.
% Modified on 01/08/89, for sections in loa (look for \@sect), jj.
% Modified on 89/11/29  by tex
%          Removed the last three lines of file which consisted of
%          <blank line>
%          % Get something else
%          \input indent
% Modified on 07/24/1992 by Roque D. Oliveira.
%          \startappendices was modified to work
%          with the New Font Selection Scheme.
%          Further (similar) changes may be needed for other macros.
% Modified Sep. 2008 by Jason Gilbert: Obsolete code removed or updated to
%          better conform to LaTeX2e, list of abbreviations added,
%          made copyright page cleaner, fixed Appendices, Bibliography,
%          margins, title page, frontispiece, bottom-center page numbers,
%          two-side printing, added in-dissertation abstract and abstract
%          that prints separately at the end.

\typeout{  }
\typeout{Substyle `rac' for Rackham dissertation.}
\typeout{  }

%-- Page styles --

\def\ps@chappage{% The first page of each chapter has bottom-center page numbers -jj.
 \def\@oddhead{}
 \def\@oddfoot{\hfil \rm \thepage \hfil}
 \let\@evenhead\@oddhead
 \let\@evenfoot\@oddfoot
}

\def\ps@plain{%
% \def\@oddhead{\hfil \rm \thepage \hfil} % These two lines of code make top-center page numbers on other pages -jg
% \def\@oddfoot{}
 \def\@oddhead{} % These two lines of code make bottom-center page numbers on other pages -jg
 \def\@oddfoot{\hfil \rm \thepage \hfil}
 \let\@evenhead\@oddhead
 \let\@evenfoot\@oddfoot
}

%-- Margins --
\if@twoside \oddsidemargin -0.25in \evensidemargin 0in \marginparwidth .6in \textheight=9.5in
\else \oddsidemargin -0.25in \marginparwidth .9in \textheight=9.5in\fi% left margin=1in + oddsidemargin, marginparwidth: text box for margin notes
\topmargin -.7in \headheight 0.15in \headsep 0.15in \footskip 0.3in % header and footer margins
\textwidth=7.0in % width of the text body on a page
% The top margin = 1in plus vspace. For some reason, need to subtract 0.35in also. -jg
\def\vertadjust{\vspace{-0.35in}} % Required for proper vertical spacing. -jg
\def\twoinmar{\vertadjust\vspace{0in}} % Two inch top margin -jg
\def\twohalfinmar{\vertadjust\vspace{0in}} % Two and a half inch top margin -jg

%-- Front pages --

% jj: This \ttlpg is the same as \titlepage in report.sty.
\def\ttlpg{\@restonecolfalse \if@twocolumn \@restonecoltrue \onecolumn
 \else \newpage \fi \thispagestyle{empty} \c@page \z@}

\def\titlepage#1#2#3#4#5#6{
 \ttlpg
 \begin{singlespace}
 \hbox{ }
 \twohalfinmar
 \begin{center}
 \begin{onehalfspacing} % For the `Large' font size, this will look single spaced. -jg
  {\Large\bf #1 \mbox{}} \\
 \end{onehalfspacing}
  \vfill
  #2 \\
  \vfill

 \end{center}
 \vfill
  \mbox{ }\hspace{0.6in}
  \parbox{5.3in}{#5}
 \end{singlespace}
}

\def\initializefrontsections{
 \setcounter{page}{1}   % -- begins with "ii"
 \pagestyle{chappage}   % -- numbers at bottom
 \renewcommand{\thepage}{\roman{page}}   % roman numeral
}

\def\frontispiece{
 \ttlpg
 \hbox{ }
 \if@twoside \clearpage\hbox{}\thispagestyle{empty} \fi
 \twoinmar
}

\def\copyrightpage#1{
 \ttlpg
 \hbox{ }
 \vertadjust
 \vfill
 \begin{center}
  \begin{singlespace}
   \underline{\copyright\hspace{0.2in}{#1}\hspace{0.2in}\number\year}\\
   \vspace{0.1in}
  \end{singlespace}
 \end{center}
 \vfill
}

\def\dedicationpage#1{
 \newpage
 \addcontentsline{toc}{chapter}{DEDICATION}
 \hbox{ }
 \vertadjust
 \vfill
 \begin{center}
  #1
 \end{center}
 \vfill
}

\def\startacknowledgementspage{
 \newpage
 \addcontentsline{toc}{chapter}{ACKNOWLEDGEMENTS}
 \hbox{ }
 \twoinmar
 \centerline{\large\bf ACKNOWLEDGEMENTS}
 \vspace{0.7in}
}

\def\startprefacepage{
 \newpage
 \addcontentsline{toc}{chapter}{PREFACE}
 \hbox{ }
 \twoinmar
 \centerline{\large\bf PREFACE}
 \vspace{0.7in}
}

%-- Table of contents and lists --

\def\dotfill{\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill}
\def\producetableofcontents{\tableofcontents}
\def\producelistofmaps{\listofmaps}
\def\producelistofappendices{\listofappendices}
\def\producelistofabbreviations{\listofabbreviations}

% jj: The only difference is \dotfill instead of \hfil.
\def\l@chapter#1#2{\pagebreak[3]
 \vskip 1.0em plus 1pt \@tempdima 1.5em \begingroup % em is the width of capital M for the current font. -jg
 \parindent \z@ \rightskip \@pnumwidth
 \parfillskip -\@pnumwidth
 {\bf \leavevmode #1}\dotfill \hbox to\@pnumwidth{\hss #2}\par
 \endgroup
}

\def\l@chap{\@dottedtocline{1}{0.5em}{3.5em}}
\def\l@section{\@dottedtocline{2}{5.0em}{2.3em}}
\def\l@subsection{\@dottedtocline{3}{8.3em}{3.2em}}
\def\l@subsubsection{\@dottedtocline{4}{12.5em}{4.1em}}

\setcounter{tocdepth}{3} % Number of section layers to show in TOC (i.e. section, subsection, subsubsection)
\setcounter{secnumdepth}{3} % Number of subsection layers to allow in document

\def\l@figure{\@dottedtocline{1}{1.0em}{3.5em}}
\let\l@table\l@figure
\let\l@map\l@figure
\let\l@anything\l@figure
\def\l@appendix{\@dottedtocline{1}{1.0em}{2.5em}}
\let\l@abbreviation\l@figure

\def\tableofcontents{%
 \newpage
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf \greektext{�����������}}
 \vspace{0in}
 \begin{singlespace}
  \@starttoc{toc}\if@restonecol\twocolumn\fi
 \end{singlespace}
}

%-- Start chapters --

\def\thechapter {\arabic{chapter}}
\def\thesection {\@arabic\c@chapter.\@arabic\c@section}
\def\thefigure {\@arabic\c@chapter.\@arabic\c@figure}
\def\thetable {\@arabic\c@chapter.\@arabic\c@table}
\def\theequation {\@arabic\c@chapter.\@arabic\c@equation}

\newcounter{map}[chapter]
\def\themap{\@arabic\c@chapter.\@arabic\c@map}
\def\fps@map{tbp}
\def\ftype@map{1}
\def\ext@map{lom}
\def\fnum@map{Map \themap}
\def\map{\@float{map}}
\let\endmap\end@float
\@namedef{map*}{\@dblfloat{map}}
\@namedef{endmap*}{\end@dblfloat}

\def\startthechapters{%
 \def\@chapapp{}
 \addtocontents{toc}{\protect\mbox{ }}
 \clearpage % This has to be before the rest.  jj
 \if@twoside \ifodd\c@page \else \ttlpg \hbox{ }\fi\fi % For two-sided printing, make sure Chapter I starts on right-hand page. jg
 \clearpage
 \setcounter{chapter}{0}
 \setcounter{page}{1} % -- ...always begin with ii.
 \renewcommand{\thepage}{\arabic{page}}
 \pagestyle{plain}
 \def\tocname{toc}
}

\def\@chapter[#1]#2{%
 \ifnum \c@secnumdepth >\m@ne
  \refstepcounter{chapter}
  \typeout{\@chapapp\space\thechapter.}
  \addcontentsline{toc}{chap}{\protect\numberline{\hbox{ }\hfill\bf\thechapter.}{\bf #1}}
 \else
  \addcontentsline{toc}{chap}{#1}
 \fi
 \if@twocolumn \@topnewpage[\@makechapterhead{#2}]
 \else \@makechapterhead{#2} \@afterheading \fi
}

\def\@makechapterhead#1{%
 \hbox{ }
 \twoinmar
 {\parindent 0pt \raggedright
  \ifnum \c@secnumdepth >\m@ne
  \Large\bf \@chapapp{} \thechapter. \Large\bf #1
  \vspace{ 10pt }
  \nobreak
 }
 \@afterindenttrue
}

\def\section{\@startsection{section}{1}{\z@}{5.5ex plus 1ex minus
 .2ex}{2.0ex plus .2ex}{\large\bf}}
\def\subsection{\@startsection{subsection}{2}{\z@}{3.25ex plus 1ex minus
 .2ex}{1.5ex plus .2ex}{\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{3.25ex plus
 1ex minus .2ex}{1.5ex plus .2ex}{\normalsize\bf}}

\long\def\@caption#1[#2]#3{%
 \addtocontents{\csname ext@#1\endcsname}{\hbox{ }}
 \addcontentsline{\csname ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname}{\ignorespaces\protect\small\protect\normalsize\rm #2}}
 \par
 \begingroup
  \@parboxrestore
  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces\protect\small\normalsize\rm #3}
  \par
 \endgroup
}

\long\def\@makecaption#1#2{
 \vskip 10pt
 \setbox\@tempboxa\hbox{#1: #2}
 \ifdim \wd\@tempboxa >\hsize
  \setbox\@tempboxa\hbox{#1: }
  \def\@tempdimj{\hsize}
  \advance\@tempdimj -\wd\@tempboxa
  \hbox to\hsize{#1: \parbox[t]{\@tempdimj}{#2}}
 \else \hbox to\hsize{\hfill\box\@tempboxa\hfill}
 \fi} 