% csmthesis.sty --- Adjustments to report style, 12pt option
% to produce a Colorado School of Mines graduate thesis.
% Use with \documentstyle[12pt,csmthesis]{report}
% Craig Artley, Colorado School of Mines, 08/12/92
% Copyright 1992, Craig T. Artley

% DO NOT CHANGE THIS FILE!
% If you choose to change something, put the changes in another .sty
% file and include that file as a documentstyle option.  If you
% find a bug or an error in this file, tell me and I will fix it.
%	Craig Artley (cartley@mines.colorado.edu)

%\typeout{*}
%\typeout{* csmthesis documentstyle option by Craig Artley, 08/12/92}
%\typeout{* This is shareware.  If you use it, please pay Craig $10.00!}
%\typeout{*}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% begin changes to report.sty
\def\titlepage{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
     \else \newpage \fi \thispagestyle{thesistitle}}

%   \@pnumwidth : The width of a box in which the page number is put.
%   \@tocrmarg  : The right margin for multiple line entries.  One
%                 wants \@tocrmarg > or = \@pnumwidth
%   \@dotsep    : Separation between dots, in mu units.  Should be \def'd to
%                 a number like 2 or 1.7

%\def\@pnumwidth{1.55em}
%\def\@tocrmarg {2.55em}
%\def\@dotsep{4.5}

\def\tableofcontents{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
                     \fi\chapter*{TABLE OF CONTENTS\@mkboth{TABLE OF CONTENTS}{TABLE OF CONTENTS}}
                     \@starttoc{toc}\if@restonecol\twocolumn\fi}

% modify the List of Figures
% LIST OF FIGURES
%
\def\listoffigures{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
  \fi\fchapter{List of Figures\@mkboth
   {LIST OF FIGURES}{LIST OF FIGURES}}\@starttoc{lof}\if@restonecol
    \twocolumn\fi}
%\def\l@figure{\@dottedtocline{1}{1.5em}{2.3em}}

% modify the List of Tables
% LIST OF TABLES
%
\def\listoftables{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
  \fi\fchapter{List of Tables\@mkboth
   {LIST OF TABLES}{LIST OF TABLES}}\@starttoc{lot}\if@restonecol
    \twocolumn\fi}
%\let\l@table\l@figure

% add a List of Plates (like List of Tables)
% LIST OF PLATES
%
\def\listofplates{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
  \fi\fchapter{List of Plates\@mkboth
   {LIST OF PLATES}{LIST OF PLATES}}\@starttoc{lop}\if@restonecol
    \twocolumn\fi}
\def\l@plate{\@platetocline{1}{1.5em}{2.3em}}

% following \@dottedtocline in latex.tex, make a similar toc line
% for the List of Plates.  It simply lists the plate number and title.
% There is no leaderfill and no page number, so it ignores #5.
\def\@platetocline#1#2#3#4#5{\ifnum #1>\c@tocdepth \else
  \vskip \z@ plus .2pt
  {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
    \parindent #2\relax\@afterindenttrue
   \interlinepenalty\@M
   \leavevmode 
   \@tempdima #3\relax \advance\leftskip \@tempdima \hbox{}\hskip -\leftskip
    #4\nobreak\hfill \nobreak \hfill\par}\fi}

% define \plate{title} -- adds "title" to the List of Plates
\newcounter{plate}
\def\theplate{\@arabic\c@plate}
\long\def\plate#1{\refstepcounter{plate}\par
\addcontentsline{lop}{plate}{\protect\numberline{\theplate}{\ignorespaces #1}}
\addtocontents{lop}{\protect\addvspace{10pt}}}

% change the format of the Figure number to match Geophysics
\def\fnum@figure{{\sc Fig}.\ \thefigure}

% Change the caption so that . follows the fig/table number, rather than :
% Also, center the caption if it fits on 1 or 2 lines (rather than just 1).
\newdimen\twicehsize     % temporary dimension variable
\long\def\@makecaption#1#2{
   \vskip 10pt 
   \setbox\@tempboxa\hbox{#1. #2}
   \twicehsize=\hsize \multiply\twicehsize by 2
   \ifdim \wd\@tempboxa >\twicehsize   % IF longer than two lines:
       #1. #2\par                 %   THEN set as ordinary paragraph.
     \else                        %   ELSE  center.
       \centering
       #1. #2\par 
   \fi}

%% end changes to report.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% begin changes to rep12.sty
% SIDE MARGINS:
\if@twoside                 % Values for two-sided printing:
   \oddsidemargin 0.5in      %   Left margin on odd-numbered pages.
   \evensidemargin 0.5in     %   Left margin on even-numbered pages.
   \marginparwidth 85pt    %   Width of marginal notes.
\else                       % Values for one-sided printing:
   \oddsidemargin 0.5in     %   Note that \oddsidemargin = \evensidemargin
   \evensidemargin 0.5in
   \marginparwidth 68pt 
\fi

% VERTICAL SPACING:        
                         % Top of page:
%\topmargin -24pt         %    Nominal distance from top of page to top of
\topmargin 12pt         %    Nominal distance from top of page to top of
                         %    box containing running head.
\headheight 12pt         %    Height of box containing running head.
\headsep 48pt            %    Space between running head and text.
% \topskip = 10pt        %    '\baselineskip' for first line of page.
                         % Bottom of page:
\footskip 15pt           %    Distance from baseline of box containing foot 
                         %    to baseline of last line of text.

% DIMENSION OF TEXT:
\textheight = 11pt
\advance\textheight by \topskip
\textwidth 6.0in         % Width of text line.
\hoffset 0.5in

\textfloatsep 30pt plus 2pt minus 4pt    % Space between main text and floats
                                         % at top or bottom of page. Craig
                                         % changed this!!! (was 20pt).
\intextsep 22pt plus 4pt minus 4pt       % Space between in-text figures and 
                                         % text. Craig changed this!!! 
                                         % (was 14pt).

\parindent 24pt                   % Width of paragraph indentation.

% \@makechapterhead {TEXT} : Makes the heading for the \chapter command.
%

\def\@makechapterhead#1{             % Heading for \chapter command
 \vspace*{50pt}                     % Space at top of text page.
  { \parindent 0pt \raggedright 
    \ifnum \c@secnumdepth >\m@ne     % IF secnumdepth > -1 THEN
      %%\normalsize\bf\centering \@chapapp{} \thechapter % Print 'Chapter' and number.
      \LARGE\bf \@chapapp{} \thechapter % Print 'Chapter' and number.
      \par 
      \vskip 15pt \fi                % Space between number and title.
    \LARGE \bf                  % Title.
    %%\uppercase{#1}\par 
    {#1}\par 
    \nobreak                         % TeX penalty to prevent page break.
    \vskip 40pt                      % Space between title and text.
  } }

% \@makeschapterhead {TEXT} : Makes the heading for the \chapter* command.
%

\def\@makeschapterhead#1{            % Heading for \chapter* command
 \vspace*{50pt}                     % Space at top of page.
  { \parindent 0pt \raggedright 
    \LARGE \bf                  % Title.
    {#1}\par 
    \nobreak                         % TeX penalty to prevent page break.
    \vskip 40pt                      % Space between title and text.
  } }

\def\chapter{\clearpage      % Starts new page.
%  \thispagestyle{plain}     % Page style of chapter page is 'plain'
   \global\@topnum\z@        % Prevents figures from going at top of page.
   \@afterindenttrue         % Suppresses indent in first paragraph.  Change
   \secdef\@chapter\@schapter}   % to \@afterindenttrue to have indent.

% \@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE} 
%            optional * [ALTHEADING]{HEADING}
%    Generic command to start a section.  
%    NAME       : e.g., 'subsection'
%    LEVEL      : a number, denoting depth of section -- e.g., chapter=1,
%                 section = 2, etc.  A section number will be printed if
%                 and only if LEVEL < or = the value of the secnumdepth
%                 counter.
%    INDENT     : Indentation of heading from left margin
%    BEFORESKIP : Absolute value = skip to leave above the heading.  
%                 If negative, then paragraph indent of text following 
%                 heading is suppressed.
%    AFTERSKIP  : if positive, then skip to leave below heading,
%                       else - skip to leave to right of run-in heading.
%    STYLE      : commands to set style
%  If '*' missing, then increments the counter.  If it is present, then
%  there should be no [ALTHEADING] argument.  A sectioning command
%  is normally defined to \@startsection + its first six arguments.

\def\section{\ifnum \c@section =\z@ % if first section, add toc space
    \addtocontents{toc}{\protect\addvspace{10pt}}\fi
    \@startsection {section}{1}{\z@}{3.5ex plus 1ex minus 
    .2ex}{2.3ex plus .2ex}{\normalsize\bf}}
%\def\subsection{\ifnum \c@subsection =\z@ % if first section, add toc space
%    \addtocontents{toc}{\protect\addvspace{10pt}}\fi
%    \@startsection{subsection}{2}{\z@}{3.25ex plus 1ex minus 
%    .2ex}{1.5ex plus .2ex}{\normalsize\bf}}
\def\subsection{\@startsection{subsection}{2}{0pt}{3.25ex plus 1ex minus 
    .2ex}{1.5ex plus .2ex}{\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{3}{0}{3.25ex plus 
   1ex minus .2ex}{-1em}{\normalsize\bf}}
\def\paragraph{\@startsection
     {paragraph}{4}{4em}{3.25ex plus 1ex minus .2ex}{-1em}{\normalsize\bf}}
\def\subparagraph{\@startsection
     {subparagraph}{4}{6em}{3.25ex plus 1ex minus .2ex}{-1em}{\normalsize\bf}}

%% end thes12.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% some local definitions
\input epsf.sty			% read in epsf macros for figures
\input doublespace.sty		% thesis is double-spaced
\setstretch{1.6}		% well, not quite

% Definitions of thesis page styles.  
%
\def\ps@thesistitle{\let\@mkboth\@gobbletwo
\def\@oddhead{\hbox{} \rm\rightmark \hfil}% doesn't work on 1st page of doc!(?)
%\def\@oddhead{\hbox{}\rm\@thesisnumber \hfil}%
\def\@oddfoot{}%
\def\@evenhead{\hfil \rm\leftmark\hbox {}}%
\def\@evenfoot{}%
\def\chaptermark##1{}\def\sectionmark##1{}%
\def\subsectionmark##1{}}

\def\ps@thesisfront{\let\@mkboth\@gobbletwo
%\def\@oddhead{\hbox \rm\rightmark \hfil}%
\def\@oddhead{\rm\rightmark \hfil}%
\def\@oddfoot{\hfil \rm\thepage \hfil}%
\def\@evenhead{\hfil \rm\leftmark\hbox {}}%
\def\@evenfoot{\hfil \rm\thepage \hfil}%
\def\chaptermark##1{}\def\sectionmark##1{}%
\def\subsectionmark##1{}}

\def\ps@thesistext{\let\@mkboth\@gobbletwo
%\def\@oddhead{\hbox \rm\rightmark \hfil \rm\thepage}%
\def\@oddhead{\rm\rightmark \hfil \rm\thepage}%
\def\@oddfoot{}%
\def\@evenhead{\rm \thepage\hfil\rm\leftmark\hbox {}}%
\def\@evenfoot{}%
\def\chaptermark##1{}\def\sectionmark##1{}%
\def\subsectionmark##1{}}

\ps@thesisfront                 % select page style for thesis frontmatter

% macros swiped from sep.sty for references, brushing up
% math spacing, and source code listing  -- Craig

% reference macro, second ... lines are indented
\newdimen\dtmp     % temporary dimension variable
\def\reference#1{ \begin{singlespace}
                  \baselineskip=.8\normalbaselineskip \dtmp=\hsize
		\advance\dtmp by-\parindent \parshape 2 0in \hsize \parindent
		\dtmp \noindent #1 \endgraf \baselineskip=\normalbaselineskip
		\vskip4pt
                \end{singlespace}
}

% try these modifications to displayed equations
%\jot=12pt  % Extra space added between lines of an eqnarray environment
           % default in plain.tex is 3pt
%\abovedisplayskip 16pt
%\belowdisplayskip \abovedisplayskip
%\abovedisplayshortskip 12pt
%\belowdisplayshortskip \abovedisplayshortskip

% This macro is for printing out programs using TeX 
%				-- see DIRTY TRICKS in TeXbook
%
% 	This version is designed to print source code at 9 point
% 	fitting an 80 column line into a 6 true inch width with 
% 	8 point line numbers before each line.
%	It handles TAB (^I) characters almost the same as DEC
% 	
% 	usage: 
%		\listing{file.ext}      % use dev:[dir] if you wish
%
%	B.H. Toby  8/86
%	modified by Kamal 4/7/87
%	modified by Craig Artley (CWP) to use Computer Modern font
\font\Alisttt=cmtt9 at 9 truept
\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
\def\listing#1{\par\bigskip\begingroup\parskip=0pt\setupverbatim\input#1%
\endgroup\bigskip}
\def\setupverbatim{
  \Alisttt\baselineskip= 8.5truept\lineskip=1truept
  \lineskiplimit=1truept\topskip=0pt
  \def\par{\leavevmode\egroup\box0\endgraf} 
  \obeylines \uncatcodespecials \obeyspaces
  \catcode`\`=\active \catcode`\^^I=\active
  \everypar{
  \startbox}}
\newdimen\w \setbox0=\hbox{\Alisttt\space} \w=8\wd0
\def\startbox{\setbox0=\hbox\bgroup}
{\catcode`\^^I=\active 
  \gdef^^I{\leavevmode\egroup
    \dimen0=\wd0
    \divide\dimen0 by\w
    \multiply\dimen0 by\w
    \advance\dimen0 by\w
    \wd0=\dimen0 \box0 \startbox}}
{\obeyspaces\global\let =\ }
{\catcode`\`=\active \gdef`{\relax\lq}}

%%%%%%%%%%%%%%%%%%%%%%%%today's kludges%%%%%%%%%%%%%%%%%%%%%%%%%%%

% from latex.tex -- redefined to add space between lot and lof entries
\long\def\@caption#1[#2]#3{\par\addcontentsline{\csname
  ext@#1\endcsname}{#1}{\protect\numberline{\csname 
  the#1\endcsname}{\ignorespaces #2}}\addtocontents{\csname
  ext@#1\endcsname}{\protect\addvspace{10pt}}\begingroup
    \@parboxrestore
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}

% from rep12.sty -- adjusting the \addvspace commands, toc entry in \uppercase
% Could have put the \uppercase in \l@chapter instead, or leave it to user.
% Put it here in case I decide to have "Chapter" printed in toc.  If I put
% it in \l@chapter, then CHAPTER would be printed.  Maybe just leave to user.
% Putting "Chapter" in the toc takes more than putting \@chapapp in the 
% \numberline command.  The box for the chapter number must also be enlarged
% in the \l@chapter definition.
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
        \refstepcounter{chapter}
        \typeout{\@chapapp\space\thechapter.}
        \addcontentsline{toc}{chapter}{\protect
 %      \numberline{\thechapter}\uppercase{#1}}\else
        \numberline{\@chapapp{} \thechapter}{#1}}\else
      \addcontentsline{toc}{chapter}{{#1}}\fi
   \chaptermark{#1}
 % \addtocontents{lof}{\protect\addvspace{10pt}} % Adds between-chapter space
 % \addtocontents{lot}{\protect\addvspace{10pt}} % to lists of figs & tables.
   \if@twocolumn                                 % Tests for two-column mode.  
           \@topnewpage[\@makechapterhead{#2}]  
     \else \@makechapterhead{#2}
           \@afterheading                  % Routine called after chapter and
     \fi}                                  % section heading.

\newcounter{fchapter}

% from report.sty -- redefined for leaderfill.  Used by \chapter AND \fchapter
%% First line of l@chapter changed 24 May 89, as suggested by Jerry Leichter.
%%
\def\l@chapter#1#2{\addpenalty{-\@highpenalty}  
   \vskip 1.0em plus 1pt  % space above chapter line
 % \@tempdima 1.5em       % width of box holding chapter number
   \@tempdima 7em         % width of box holding \@chappapp and chapter number
   \begingroup
     \parindent \z@ \rightskip \@pnumwidth 
     \parfillskip -\@pnumwidth   
     \bf                  % Boldface.
     \leavevmode          % TeX command to enter horizontal mode.       
      \advance\leftskip\@tempdima  %% added 5 Feb 88 to conform to 
      \hskip -\leftskip            %% 25 Jan 88 change to \numberline
     #1\nobreak\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep 
       mu$}\hfill \nobreak \hbox to\@pnumwidth{\hss #2}\par
     \penalty\@highpenalty %% added 24 May 89 as suggested by J. Leichter
   \endgroup}

% make a new sectioning command, \fchapter, for frontmatter (and backmatter)
%    ****************************************
%    *        CHAPTERS AND SECTIONS         *
%    ****************************************
%
% Definition of \part moved to report.doc  19 Jan 88

% \@makefchapterhead {TEXT} : Makes the heading for the \fchapter command.
%

\def\@makefchapterhead#1{            % Heading for \fchapter command
 %\vspace*{50pt}                     % Space at top of text page.
  { \parindent 0pt \raggedright 
    \Large \bf \centering       % Title.
    {#1}\par 
    \nobreak                         % TeX penalty to prevent page break.
    \vskip 40pt                      % Space between title and text.
  } }

% \@makesfchapterhead {TEXT} : Makes the heading for the \fchapter* command.
%

\def\@makesfchapterhead#1{           % Heading for \fchapter command
 %\vspace*{50pt}                     % Space at top of text page.
  { \parindent 0pt \raggedright 
    \Large \bf \centering       % Title.
    {#1}\par 
    \nobreak                         % TeX penalty to prevent page break.
    \vskip 40pt                      % Space between title and text.
  } }

% \secdef{UNSTARCMDS}{STARCMDS} :
%    When defining a \chapter or \section command without using
%    \@startsection, you can use \secdef as follows:
%       \def\chapter { ... \secdef \CMDA \CMDB }
%       \def\CMDA    [#1]#2{ ...   % Command to define \chapter[...]{...}
%       \def\CMDB    #1{ ...       % Command to define \chapter*{...}

\def\fchapter{\clearpage      % Starts new page.
%  \thispagestyle{plain}     % Page style of chapter page is 'plain'
   \global\@topnum\z@        % Prevents figures from going at top of page.
   \@afterindenttrue        % Suppresses indent in first paragraph.  Change
   \secdef\@fchapter\@sfchapter}   % to \@afterindenttrue to have indent.

\def\@fchapter[#1]#2{
      \addcontentsline{toc}{chapter}{{#1}}
   \fchaptermark{#1}
 % \addtocontents{lof}{\protect\addvspace{10pt}} % Adds between-chapter space
 % \addtocontents{lot}{\protect\addvspace{10pt}} % to lists of figs & tables.
   \if@twocolumn                                 % Tests for two-column mode.  
           \@topnewpage[\@makefchapterhead{#2}]  
     \else \@makefchapterhead{#2}
           \@afterheading                  % Routine called after chapter and
     \fi}                                  % section heading.

\def\@sfchapter#1{\if@twocolumn \@topnewpage[\@makesfchapterhead{#1}]
        \else \@makesfchapterhead{#1} 
              \@afterheading\fi}

% Default initializations of \...mark commands.  (See below for their
% us in defining page styles.
%

\def\fchaptermark#1{}

% Bibliography/references changes

% fix the bibliography environment or report.sty to use \fchapter,
% change name from Bibliography to References
\def\thebibliography#1{\fchapter{References\@mkboth
  {REFERENCES}{REFERENCES}}\list
  {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \usecounter{enumi}}
    \def\newblock{\hskip .11em plus .33em minus .07em}
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}

% Call \authordatereferences before beginning thebibliography to suppress
% the numbering of references.  The following is taken from apalike.sty.
\def\authordatereferences{%
  \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}
  \def\@biblabel##1{}

  \newlength{\bibhang}
  \setlength{\bibhang}{2em}

  \def\thebibliography##1{\fchapter{References\@mkboth
    {References}{References}}\list
    {\relax}{\setlength{\labelsep}{0em}
	  \setlength{\itemindent}{-\bibhang}
	  \setlength{\leftmargin}{\bibhang}}
      \def\newblock{\hskip .11em plus .33em minus .07em}
      \sloppy\clubpenalty4000\widowpenalty4000
      \sfcode`\.=1000\relax}

  \def\@citex[##1]##2{\if@filesw\immediate\write\@auxout{\string\citation{##2}}\fi
    \def\@citea{}\@cite{\@for\@citeb:=##2\do
      {\@citea\def\@citea{; }\@ifundefined
         {b@\@citeb}{{\bf ?}\@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
  {\csname b@\@citeb\endcsname}}}{##1}}
}

