
\usepackage{parskip,fancyheadings}

\setcounter{secnumdepth}{10}
\setcounter{tocdepth}{2}

\usepackage{sabon}
\def\textos#1{#1}

%
% From PRB: Use FancyPlain style -- set up to produce draft
% information and disable rules and section headings in headers and
% footers.
%

% \filename

\def\filename{thesis.tex}
\let\savedinclude\include
\def\include#1{\def\filename{#1.tex}\savedinclude{#1}}

% \prtinttime

\newcounter{hours}\newcounter{mins}
\newcommand{\printtime}{%
  \setcounter{hours}{\time/60}%
  \setcounter{mins}{\time-\value{hours}*60}%
  \ifthenelse{\value{hours}<10}{0}{}\thehours:%
  \ifthenelse{\value{mins}<10}{0}{}\themins}


% Final tweaks to the layout -- PRB/SMH/TLH

\newcommand{\verylongpage}{\enlargethispage{2.5\baselineskip}}
\newcommand{\longpage}{\enlargethispage{2\baselineskip}}
\newcommand{\shortpage}{\enlargethispage{-2\baselineskip}}
\newcommand{\quitelongpage}{\enlargethispage{1\baselineskip}}
\newcommand{\quiteshortpage}{\enlargethispage{-1\baselineskip}}

% Use instead of / to allow hyphenation -- PRB/SMH

\def\slash{/\penalty 0\hskip 0pt\relax}

%
% Header/Footer
%

\pagestyle{fancyplain}
\headrulewidth=0pt
\footrulewidth=0pt
\plainheadrulewidth=0pt
\plainfootrulewidth=0pt

\lhead[]{}
\chead[]{}
\rhead[]{}

\lfoot[\sl\thepage]{}
\cfoot[]{}
\rfoot[]{\sl\thepage}

%
% Captions (from RF: make captions hang properly)
%

\makeatletter
\long\def\@makecaption#1#2{%
   \vskip 10\p@
   \setbox\@tempboxa\hbox{\small #1: #2}%
   \ifdim \wd\@tempboxa >\hsize
       \@hangfrom{\small #1: }{\small #2}\par
     \else
       \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
   \fi}
\makeatother

\makeatletter

%
% Keep mpars on the same side (we use them for hanging section
% numbers).
%

\@mparswitchfalse
\marginparsep=1ex

%
% Abandon ugly vertical justification
%

\raggedbottom

%
% Poor-mans small caps
%

%\font \psc = ptmr8t scaled 800
%\renewcommand{\scdefault}{psc}

\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}

%
% Let footnotes fall right to the bottom of the page
%

\renewcommand\footnoterule{\vfill\hrule\vspace{6pt}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Headings

%
% Fonts
%

% \font\sectionfont = phvr8t scaled 1400
% \font\subsectionfont = phvr8t scaled 1200
% \font\subsubsectionfont = phvr8t scaled 1000

%
% Chapter/Section names
%

\def\chaptermark#1{%
        \markboth {{\ifnum \c@secnumdepth >\m@ne
            \@chapapp\ \thechapter. \ \fi
            #1}}{}
        }

\def\sectionmark#1{%
        \markright {{\ifnum \c@secnumdepth >\z@
            \thesection. \ \fi
            #1}}
        }

%
% Chapter heading components
%

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                    \else
                      \addcontentsline{toc}{chapter}{#1}
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi
        }

\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \reset@font
    \ifnum \c@secnumdepth >\m@ne
         \LARGE \@chapapp{} \thechapter
         \par
         \vskip 10\p@
       \fi
    \Huge #1\par
    \nobreak
    \vskip 20\p@
  }}

\def\@schapter#1{\if@twocolumn
                   \@topnewpage[\@makeschapterhead{#1}]%
                 \else
                   \@makeschapterhead{#1}%
                   \@afterheading
                 \fi}

\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \reset@font
    \Huge #1\par
    \nobreak
    \vskip 40\p@
  }}

%
% *Section heading components
%

\def\@startsection#1#2#3#4#5#6{%
  \if@noskipsec \leavevmode \fi
  \par
  \@tempskipa #4\relax
  \@afterindenttrue
  \ifdim \@tempskipa <\z@
    \@tempskipa -\@tempskipa \@afterindentfalse
  \fi
  \if@nobreak
    \everypar{}%
  \else
    \addpenalty\@secpenalty\addvspace\@tempskipa
  \fi
  \@ifstar
    {\@ssect{#3}{#4}{#5}{#6}}%
    {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}

\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{\interlinepenalty \@M #8\@@par}%
      \reversemarginpar{\marginpar{{\rightline{\@svsec}}}}
    \endgroup
    \csname #1mark\endcsname{#7}%
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c@secnumdepth \else
        \protect\numberline{\csname the#1\endcsname}%
      \fi
      #7}%
  \else
    \def\@svsechd{%
      #6{\hskip #3\relax
      \@svsec #8}%
      \csname #1mark\endcsname{#7}%
      \addcontentsline{toc}{#1}{%
        \ifnum #2>\c@secnumdepth \else
          \protect\numberline{\csname the#1\endcsname}%
        \fi
        #7}}%
  \fi
  \@xsect{#5}
  }

%
% Table of contents
%

\renewcommand\contentsname{Table of contents}
\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{\contentsname}{}}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }

%
% List of Figures
%

\renewcommand\listfigurename{List of figures}
\renewcommand\listoffigures{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename
      \@mkboth{\listfigurename}{}}%
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }

%
% List of Tables
%

\renewcommand\listtablename{List of tables}
\renewcommand\listoftables{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listtablename
      \@mkboth{\listtablename}{}}%
    \@starttoc{lot}%
    \if@restonecol\twocolumn\fi
    }

%
% Glossary
%

\newcommand\gloname{Glossary}
\newcommand\gloss{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\gloname
      \@mkboth{\gloname}{}}%
    \input{glossary}
    \vfill
    \if@restonecol\twocolumn\fi
    }

%
% Bibliography
%

\renewenvironment{thebibliography}[1]
     {\chapter*{\bibname
        \@mkboth{\bibname}{}}%
      \list{\@biblabel{\arabic{enumiv}}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
%            \if@openbib
%              \advance\leftmargin\bibindent
%              \itemindent -\bibindent
%              \listparindent \itemindent
%              \parsep \z@
%            \fi
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\arabic{enumiv}}}%
%      \if@openbib
%        \renewcommand\newblock{\par}
%      \else
        \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}%
%      \fi
      \sloppy\clubpenalty4000\widowpenalty4000%
      \sfcode`\.=\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}

%
% Chapter
%

\renewcommand\chapter{%
    \if@openright\cleardoublepage\else\clearpage\fi
    \thispagestyle{plain}%
    \global\@topnum\z@
    \@afterindentfalse
    \secdef\@chapter\@schapter
    }

%
% *Sections
%

% \z@ -- zero?

% \@startsection{name}{depth}
%         {indent}
%         {beforeskip \@plus foo \@minus bar} 
%         foo: ... ; bar: jitter back up page?
%         {afterskip}
%         {style}

\renewcommand\section{%
    \@startsection{section}{1}
        {\z@}%
        {-5ex \@plus 5ex \@minus -.5ex}%
        {2.5ex  \@minus .5ex}%
        {\reset@font\Large}%
    }

\renewcommand\subsection{%
    \@startsection{subsection}{2}
        {\z@}%
        {-3ex  \@plus 3ex \@minus -.5ex}%
        {1.5ex \@minus .5ex}%
        {\reset@font\large}%
    }

\renewcommand\subsubsection{%
    \@startsection{subsubsection}{3}
        {\z@}%
        {-1ex \@plus 1ex \@minus -.5ex}%
        {1ex  \@minus .5ex}%
        {\reset@font\normalsize\sl}%
    }

\makeatother
\endinput

