% scs-titlepage.sty -*- latex -*-
% For CMU SCS tech reports and theses.
% Essentially cmu-titlepage.sty with fixes and improvements --
%     see the documentation for cmu-titlepage.

% cmu-titlepage.sty created 2 November 1989 R. Harper and D. Long
% substyle for use with standard LaTeX article or report document styles
% adapted from titlepage.sty
%
% Rehacked April 91 by Olin Shivers to make things work when a twopage
%   style with different inner/outer marins is used: 
%   - Making the title page *physically* centered.
%   - Numbering pages from 1 instead of 0.
%   - Discussion of how to number "front matter" (title page, dedication,
%     TOC, etc) appears at the end of this file.
%
% Olin Shivers July 12, 1991
%   Added the \submittedPhD command for dissertation title pages.
%   Renamed scs-titlepage.sty.
%
% NOTE:
% The titlepage stuff no longer resets the page number to 1 at the end.
% This is because you might want more front matter numbered in sequence
% with the title page. So you *must* manually reset the page count to
% 1 when you are ready to begin the main body of the T.R.:
%	\setcounter{page}{1}

\typeout{Document style option 'cmu-titlepage' --- April 1991}
\typeout{With Shivers' extensions --- July 1991}

\newcounter{@savetotal}

\def\title#1{\gdef\@title{#1}}

\def\author#1{\gdef\@author{#1}}

% the following is adapted from latex.tex to flag multiple authors
\def\and{%%                             % \begin{tabular} 
\gdef\@multipleauthors{}%
\end{tabular}\hskip 1em plus .17fil\begin{tabular}[t]{c}%% \end{tabular}
}

\def\date#1{\gdef\@date{#1}}
\gdef\@date{\today}          % default is today's date

% keywords
\def\keywords#1{\gdef\@keywords{#1}}

% technical report number
\def\trnumber#1{\gdef\@trnumber{#1}}
\gdef\@trnumber{CMU-CS-??-???}

% declaring citation information sets up formatting too
\def\citationinfo#1{\gdef\@citationinfo{\vskip 2em\begin{quote}{\small #1}\end{quote}\par}}
\gdef\@citationinfo{}

% Canned "Submitted in partial blah blah blah" for dissertation title page.
\def\submittedPhD{
  \citationinfo{
    \begin{center}\em
    Submitted in partial fulfillment of the requirements \\
    for the degree of Doctor of Philosophy.
    \end{center}}}

% declaring copyright information sets up formatting too
\def\copyrightnotice#1{\gdef\@copyrightnotice{\vfill\begin{center}{\small #1}\end{center}\par}}
\gdef\@copyrightnotice{}

% Typical use:
% \copyrightnotice{{\copyright} 1991 Olin Shivers}

% unmarked footnote
\long\def\unmarkedfootnote#1{{\xdef\@thefnmark{}\@footnotetext
{\ifcase\@ptsize\small\else\relax\fi#1}}}
% Must be a certain size to be readable after copying

% support acknowledgement, defaults to empty
\def\support#1{\begingroup\def\protect{\noexpand\protect\noexpand}\xdef\@support{\@support\protect\unmarkedfootnote{#1}}\endgroup}
\gdef\@support{}

% standardized arpa contract citations

% these just store away the arguments for later consideration
\def\arpasupport#1{\gdef\@arpasupport{#1}}	% could check validity here
\def\othersupport#1{\gdef\@othersupport{#1}}
\def\authorsupport#1{\gdef\@authorsupport{#1}}
\let\@authorsupport=\relax

% generate ``author'' or ``authors,'' depending on the number of
% authors
\def\authororauthors{\@ifundefined{@multipleauthors}{author}{authors}}

% generate the standardized support message, set up the disclaimer
\def\arpablurb#1{\ifcase#1
% Ergo
\unmarkedfootnote{This research was supported in part by the Office of
Naval Research and in part by the Defense Advanced Research Projects
Agency~(DOD), monitored by the Office of Naval Research under Contract
N00014-84-K-0415, ARPA Order No.~5404%
\@ifundefined{@othersupport}{.}{, and in part by \@othersupport.}
\@authorsupport
\gdef\@arpadisclaimer{\unmarkedfootnote{The views and conclusions
contained in this document are those of the \authororauthors\ and
should not be interpreted as representing the official policies,
either expressed or implied, of ONR, DARPA%
\@ifundefined{@otherdisclaimer}{\relax}{, \@otherdisclaimer} or the
U.S.~government.}}}
\or % Speech
\unmarkedfootnote{This research was supported%
\@ifundefined{@othersupport}{\relax}{ in part}
by the Defense Advanced Research Projects Agency~(DOD) and monitored
by the Space and Naval Warfare Systems Command under Contract
N00039-85-C-0163, ARPA Order No.~5167%
\@ifundefined{@othersupport}{.}{ and in part by \@othersupport.}
\@authorsupport
\gdef\@arpadisclaimer{\unmarkedfootnote{The views and conclusions
contained in this document are those of the \authororauthors\ and
should not be interpreted as representing the official policies,
either expressed or implied, of DARPA%
\@ifundefined{@otherdisclaimer}{\relax}{, \@otherdisclaimer} or the
U.S.~government.}}}
\or % Basic
\unmarkedfootnote{This research was sponsored%
\@ifundefined{@othersupport}{\relax}{ in part}
by the Avionics Laboratory, Wright Research and Development Center,
Aeronautical Systems Division (AFSC), U.S. Air Force, Wright-Patterson
AFB, Ohio 45433-6543 under Contract F33615-90-C-1465, ARPA Order
No.~7597%
\@ifundefined{@othersupport}{.}{ and in part by \@othersupport.}
\@authorsupport
\gdef\@arpadisclaimer{\unmarkedfootnote{The views and conclusions
contained in this document are those of the \authororauthors\ and
should not be interpreted as representing the official policies,
either expressed or implied, of %
\@ifundefined{@otherdisclaimer}{the U.S.
government.}{{\@otherdisclaimer} or the U.S. government.}}}}
\or % Strategic
\unmarkedfootnote{This research was sponsored%
\@ifundefined{@othersupport}{\relax}{ in part}
by The Defense Advanced Research Projects Agency, Information Science
and Technology Office, under the title ``Research on Parallel
Computing'', ARPA Order No.~7330, issued by DARPA/CMO under Contract
MDA972-90-C-0035%
\@ifundefined{@othersupport}{.}{ and in part by \@othersupport.}
\@authorsupport
\gdef\@arpadisclaimer{\unmarkedfootnote{The views and conclusions
contained in this document are those of the \authororauthors\ and
should not be interpreted as representing the official policies,
either expressed or implied, of %
\@ifundefined{@otherdisclaimer}{the U.S.
government.}{{\@otherdisclaimer} or the U.S. government.}}}}
\or % HTK
\unmarkedfootnote{This research was sponsored%
\@ifundefined{@othersupport}{\relax}{ in part}
by the Defense Advanced Research Projects Agency, Information Science
and Technology Office, under the title ``Research on Parallel
Computing'', ARPA Order No.~7330.  Work furnished in
connection with this research is provided under prime contract
MDA972-90-C-0035 issued by DARPA/CMO to Carnegie Mellon University 
and under its subcontract, No.~334918-58792 with Networks Systems
Corporation.
\@ifundefined{@othersupport}{\relax}{This work was also sponsored in
part by \@othersupport.}
\@authorsupport
\gdef\@arpadisclaimer{\unmarkedfootnote{The views and conclusions
contained in this document are those of the \authororauthors\ and
should not be interpreted as representing the official policies,
either expressed or implied, of %
\@ifundefined{@otherdisclaimer}{the U.S.
government.}{{\@otherdisclaimer} or the U.S. government.}}}}
\fi}

% disclaimer information may be omitted, defaults to the standard
% disclaimer
\def\disclaimer#1{\begingroup\def\protect{\noexpand\protect\noexpand}\xdef\@disclaimer{\protect\unmarkedfootnote{#1}}\endgroup}
\def\otherdisclaimer#1{\gdef\@otherdisclaimer{#1}}

% abstract is a figure so it can float to next page if needed
\long\def\abstract#1{\long\gdef\@abstract{\vfil\begin{figure}[h]\begin{center}{\bf Abstract}\end{center}#1\end{figure}\par\vfil}}
\gdef\@abstract{}

% code to build the title page
\def\maketitle{
% calculate skip needed to ensure that title appears in the cut-out
\newlength{\@cutoutvskip}
\setlength{\@cutoutvskip}{2.1875 true in}	% position of cut-out
\addtolength{\@cutoutvskip}{-1 true in}		% printer margin
\addtolength{\@cutoutvskip}{-\topmargin}
\addtolength{\@cutoutvskip}{-\headheight}
\addtolength{\@cutoutvskip}{-\headsep}
\begin{titlepage}
%% \begin{titlepage} sets the page to 0, which is an even number.
%% But title pages are right-hand/odd pages, so the even-page margin
%% is the *wrong* thing. Also, the \cleardoublepage won't work correctly.
%% Reset the page to 1 here so things work.
\c@page\@ne

%% Centered things on the title page must be *physically* centered
%% on the page, so they line up with the cut-out window. So we hardwire
%% the margins for the title page so that left margin = right margin:
%%         left margin = (8.5" - textwidth)/2
\oddsidemargin=8.5in
\advance\oddsidemargin by -\textwidth
\oddsidemargin=.5\oddsidemargin
\advance\oddsidemargin by -1in % TeX sux
%
\let\footnoterule\relax
\vglue\@cutoutvskip
\begin{center}
%\begin{minipage}[t]{4.875in}	% must be a minipage due to \thanks
\begin{minipage}[t]{4.8in}	% hackery
\vbox to 2in{
\vfill
\begin{center}
{\Large \strut \@title\par}
\vfill
{\large \begin{tabular}[t]{c}\@author\end{tabular}\par}
\smallskip
{\large \@date\par}
\smallskip
{\sc \@trnumber\par}
\end{center}
\vfill}
\end{minipage}
\end{center}
\vskip 3em
\begin{center}
School of Computer Science \\
Carnegie Mellon University \\
Pittsburgh, PA 15213
\end{center} \par
\@citationinfo
% these are footnotes; abstract must appear afterwards
\@thanks
\@ifundefined{@arpasupport}{\@support}{%
\expandafter\ifx\csname\@arpasupport\endcsname\ergo
\arpablurb0
\else
\expandafter\ifx\csname\@arpasupport\endcsname\speech
\arpablurb1
\else
\expandafter\ifx\csname\@arpasupport\endcsname\basic
\arpablurb2
\else
\expandafter\ifx\csname\@arpasupport\endcsname\strategic
\arpablurb3
\else
\expandafter\ifx\csname\@arpasupport\endcsname\HTK
\arpablurb4
\else
\typeout{Bad ARPA support key --- ignoring} \fi \fi \fi \fi \fi}
\@ifundefined{@disclaimer}{\@ifundefined{@arpadisclaimer}{\relax}{\@arpadisclaimer}}{\@disclaimer}
\@abstract
\@copyrightnotice
\end{titlepage}
\@ifundefined{@keywords}{}{% keywords at bottom of reverse side of title page
% totalnumber hack avoids flushing of pending float (if any)
\setcounter{@savetotal}{\value{totalnumber}}
\setcounter{totalnumber}{0}
{\thispagestyle{empty}\vspace*{\fill}{\bf Keywords:} \@keywords\clearpage}
\setcounter{totalnumber}{\value{@savetotal}}}
% flush abstract if it floated; make sure text starts on a facing page
\thispagestyle{plain}
\cleardoublepage
%Commented out. Books number from the title page (page i), even though they
%don't print the page number. You reset to page 1 after the front matter.
%\setcounter{page}{1}
\setcounter{footnote}{0}
\setcounter{figure}{0}
\let\support\relax\gdef\@support{}\gdef\@author{}\gdef\@title{}\gdef\@trnumber{}\gdef\@citationinfo{}\gdef\@copyrightnotice{}\gdef\@shortabstract{}\gdef\@longabstract{}\let\maketitle\relax}
%%
%% Page numbering:
%% The front matter (title page; dedication; preface; acks; table
%%   of contents, lists of figs and tables) is numbered together,
%%   with the title page being page i. The numbering is roman, except
%%   the title page (both sides) which is blank. So the first number
%%   you see is iii. Each unit in the front matter must start on
%%   on a right-hand/odd page (except the list of figs, which can
%%   go on the back of the last page of the TOC). The pagestyle is
%%   plain -- no headers, footer is just the centered page number.
%%
%% Clearly, for a short tech report, the front matter is minimal:
%% title page, keyword page and abstract, a total of 2-4 pages depending
%% on whether or not the abstract fits on the title page. At the other
%% end of the tech report spectrum, a long dissertation is basically a book,
%% and the front matter can add up.
%%
%% The main body of the text is numbered together, arabic numerals, starting
%% from 1. Appendices come before the bibliography in the books I
%% checked. The authoritative reference on this stuff is *Words into Type*.
%% I haven't seen a clear call on whether the acks go before the
%% TOC or after it. I put mine after, so it would show in the TOC.
%%
%% Here's what the whole setup looked like for my dissertation:
%%     \pagenumbering{roman} % title page is blank anyway.
%%     \input{title}
%%     \input{dedication}
%%     \cleardoublepage \tableofcontents
%%     \input{acks}
%%
%% Then the main body began like this:
%%     \setcounter{page}{1}
%%     \pagenumbering{arabic}
%%     \pagestyle{headings}
%%

%% This could be improved by making a frontmatter environment that
%% would surround the title page and all the rest of the front matter.
%% This env would set the page count/numbering to 1/roman in the
%% prolog and 1/arabic in the epilog. The prolog would set the front
%% matter page style to \pagestyle{plain}.
%% 
%% You do it.
