%%% test version for a style producing manuscript-like output.
%%% Stefan Ulrich <ulrich@cis.uni-muenchen.de>, with
%%% suggestions by Rowland <rebecca@astrid.dog.u-net.com, no animal>
%%% and modifications by Steve Kilbane <steve@whitecrow.demon.co.uk>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{manuscript}

\RequirePackage{geometry}% set margins easily
\RequirePackage{setspace}% doublespacing between lines
\RequirePackage{fancyhdr}%
\RequirePackage[normalem]{ulem}% for underlining

% Some settings for day-to-day processing
\newcommand{\@mssspacing}{}
\newcommand{\emp}[1]{\emph{#1}}% Normal emphasis
\newcommand{\@tlhdr}{\today}

% And variants of same for when we're in submission mode
\DeclareOption{submit}{
 % Turn off hyphenation
 \rightskip=0pt plus1fil
 % Double-space the doc
 \renewcommand{\@mssspacing}{\doublespacing}
 %% make courier the default font
 \renewcommand{\rmdefault}{pcr} %%% could also be cmtt

%% now hyphenation is disabled (\hyphenchar is -1).
%% re-enable it:
\newcommand{\@orig@normalfont}{}
\let\@orig@normalfont=\normalfont
\renewcommand{\normalfont}{\@orig@normalfont \hyphenchar\font=`\-}
\renewcommand{\emp}[1]{\uline{#1}}% Normal emphasis
\renewcommand{\@tlhdr}{\@authaddr}
 }

\ProcessOptions\relax
%% setup margins
\geometry{right=1in, top=1in, left=1in, bottom=1in}

%% setup headings
\pagestyle{fancy}
\rhead{\@author/\textsc{\@headtitle}/\thepage}
\lhead{}
\cfoot{}
\rfoot{}
\lfoot{}
\renewcommand{\headrulewidth}{0pt}
\addtolength{\headheight}{\baselineskip}




%%% make \author and \title produce funny output when
%%% not specified in the document
\renewcommand{\author}[1]{\gdef\@author{#1}}
\newcommand{\headtitle}[1]{\gdef\@headtitle{#1}}
\renewcommand{\title}[1]{\gdef\@title{#1}\headtitle{#1}}

% Define commands to set the address and word count
\newcommand{\authaddr}[1]{\gdef\@authaddr{#1}}
\newcommand{\wordcount}[1]{\gdef\@wordcount{#1}}
% ...and create the width of the address field.
\newlength{\@authaddrwidth}
\setlength{\@authaddrwidth}{4in}

{\catcode`\|=0 \catcode`\\=12
|gdef|bslash{\}}
\def\@author{<no \bslash author given!>}
\def\@title{<no \bslash title given!>}
\def\@headtitle{<no \bslash headtitle given!>}
\def\@authaddr{<no \bslash authaddr given!>}
\def\@wordcount{<no \bslash wordcount given!>}


%%% the titlepage
\renewcommand{\maketitle}{%
 \thispagestyle{plain} % Turn off headers for first page
 \parbox[t]{\@authaddrwidth}{\@tlhdr}
	\hfill
 \@wordcount\ words
 \vspace{2in}
 \@mssspacing
 \begin{center}
 \textsc{\@title} %%% sets the title; could also be \uline{\@title}
 \par\vskip\baselineskip
 \@author
 \par
 \end{center}\par\vskip\baselineskip\vskip\baselineskip
}
