%%
%% This is file `ustitle.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ustitle.dtx  (with options: `pkg')
%% 
%% -------------------------------------------------------------------
%%         University of Stellenbosch Title Page Package
%% -------------------------------------------------------------------
%% 
%% Author: Danie Els
%% 
%%         Copyright (C) 2005 Danie Els
%%         All rights reserved.
%% 
%% This work may be distributed and/or modified under the conditions
%% of the LaTeX Project Public License, either version 1.3 of this
%% license or (at your option) any later version.  The latest version
%% of this license is in:  http://www.latex-project.org/lppl.txt  and
%% version 1.3 or later is part of all distributions of LaTeX version
%% 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Danie Els (dnjels@sun.ac.za)
%% -------------------------------------------------------------------
%% 
\newcommand*{\USTitleFileDate}{2005/05/17}
\newcommand*{\USTitleFileVersion}{v1.0}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{ustitle}[\USTitleFileDate\space
                          \USTitleFileVersion\space
                          Stellenbosh Title Page Package (DNJ ELS)]
\RequirePackage{ifthen}
\RequirePackage{keyval}
\AtBeginDocument{%
   \@ifpackageloaded{graphicx}{}{%
      \PackageError{ustitle}{You must load the graphicx package}{}%
      }}
\def\UST@true{true}
\def\UST@false{false}
\def\UST@boolkey{\@dblarg\UST@@boolkey}
\def\UST@@boolkey[#1]#2#3{%
    \lowercase{\def\UST@tempa{#3}}%
    \ifx\UST@tempa\@empty
        \let\UST@tempa\UST@true
    \fi
    \ifx\UST@tempa\UST@true
    \else
        \ifx\UST@tempa\UST@false
        \else
            \let\UST@tempa\relax
        \fi
    \fi
    \ifx\UST@tempa\relax
        \PackageWarning{ustitle}{%
            Unexpected value `#3'\MessageBreak
            of option `#1' instead of\MessageBreak
            `true' or 'false'}
    \else
        \csname UST@#2\UST@tempa\endcsname
    \fi}
\newcommand*{\UST@processKVoptions}[1]{%
   \let\@tempa\@empty
   \@for\CurrentOption:=\@classoptionslist\do{%
      \@ifundefined{KV@#1@\CurrentOption}%
         {}%
         {\edef\@tempa{\@tempa,\CurrentOption,}}}%
   \edef\@tempa{%
      \noexpand\setkeys{#1}{\@tempa\@ptionlist{\@currname.\@currext}}}%
   \@tempa
   \AtEndOfPackage{\let\@unprocessedoptions\relax}}%
\newif\ifUST@titlepage
\UST@titlepagefalse
\define@key{UST@KeyOpt}{titlepage}[true]{%
    \UST@boolkey{titlepage}{#1}}
\newif\ifUST@BW
\UST@BWfalse
\define@key{UST@KeyOpt}{BW}[true]{
    \UST@boolkey{BW}{#1}%
    \UST@SetUSLogo}
\define@key{UST@KeyOpt}{scale}[1.0]{%
    \def\UST@logoscale{#1}}
\def\UST@vspace{0pt}%
\define@key{UST@KeyOpt}{vspace}[0pt]{%
    \def\UST@vspace{#1}}
\newcounter{UST@logocnt}
\newif\ifUST@logo
\UST@logotrue
\define@key{UST@KeyOpt}{logo}[top]{%
   \ifthenelse{\equal{#1}{none}}   {\UST@logofalse}             {%
   \ifthenelse{\equal{#1}{plain}}  {\setcounter{UST@logocnt}{0}}{%
   \ifthenelse{\equal{#1}{top}}    {\setcounter{UST@logocnt}{1}}{%
   \ifthenelse{\equal{#1}{stacked}}{\setcounter{UST@logocnt}{2}}{%
   \ifthenelse{\equal{#1}{left}}   {\setcounter{UST@logocnt}{3}}{%
      \PackageWarning{ustitle}{logo=`#1' is invalid, default to `top'}%
      \setcounter{UST@logocnt}{0}%
      }}}}}%
   \UST@SetUSLogo}
\def\UST@logoname{}%
\newlength\UST@logowdt
\newcommand\UST@SetUSLogo{%
\ifcase\c@UST@logocnt%...................... 0 plain
    \ifUST@BW
        \def\UST@logoname{USlogo-BW}%
    \else
        \def\UST@logoname{USlogo}%
    \fi
    \setlength\UST@logowdt{15.08mm}%
\or%........................................ 1 top
    \ifUST@BW
        \def\UST@logoname{USlogo-BW-top}%
    \else
        \def\UST@logoname{USlogo-top}%
    \fi
    \setlength\UST@logowdt{89.50mm}%
\or%........................................ 2 stacked
    \ifUST@BW
        \def\UST@logoname{USlogo-BW-stack}%
    \else
        \def\UST@logoname{USlogo-stack}%
    \fi
    \setlength\UST@logowdt{32.08mm}%
\or%........................................ 3 left
    \ifUST@BW
        \def\UST@logoname{USlogo-BW-left}%
    \else
        \def\UST@logoname{USlogo-left}%
    \fi
    \setlength\UST@logowdt{108.60mm}%
\fi}
\newcommand\UST@putlogo{%
   \ifUST@logo
      {\vspace*{\UST@vspace}%
       \centering%
       \makebox[0pt][c]{%
          \includegraphics[width=\UST@logoscale\UST@logowdt]{\UST@logoname}}\par
      }%
   \fi
}
\setkeys{UST@KeyOpt}{%
   titlepage = false,
        logo,
          BW = false,
       scale}
\UST@processKVoptions{UST@KeyOpt}
\let\@address\relax
\newcommand\address[1]{\def\@address{#1}}
\ifUST@titlepage
    \renewcommand\maketitle{%
    \begin{titlepage}%
        \let\footnotesize\small
        %\let\footnoterule\relax
        \let \footnote \thanks
        \null
        \UST@putlogo
        \vfil
        \vskip 20mm
        \begin{center}%
           {\LARGE \@title \par}%
            \vskip 10mm%
           {\large
            \lineskip .75em%
            \begin{tabular}[t]{c}%
                \@author
            \end{tabular}\par}%
            \ifx\@address\relax\else
               \vskip 10mm%
              {\normalsize\@address\par}
            \fi
            \vskip 10mm%
           {\large \@date \par}%       % Set date in \large size.
        \end{center}\par
           \vfil\null
        \@thanks
    \end{titlepage}%
    \setcounter{footnote}{0}%
    \global\let\thanks\relax
    \global\let\maketitle\relax
    \global\let\@thanks\@empty
    \global\let\@author\@empty
    \global\let\@date\@empty
    \global\let\@title\@empty
    \global\let\title\relax
    \global\let\author\relax
    \global\let\date\relax
    \global\let\and\relax}
\else
    \renewcommand\maketitle{%
    \par
    \begingroup
        \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
        \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
        \long\def\@makefntext##1{\parindent 1em\noindent
                \hb@xt@1.8em{%
                    \hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
        \if@twocolumn
        \ifnum \col@number=\@ne
            \@maketitle
        \else
            \twocolumn[\@maketitle]%
        \fi
        \else
        \newpage
        \global\@topnum\z@   % Prevents figures from going at top of page.
        \@maketitle
        \fi
        \thispagestyle{plain}\@thanks
    \endgroup
    \setcounter{footnote}{0}%
    \global\let\thanks\relax
    \global\let\maketitle\relax
    \global\let\@maketitle\relax
    \global\let\@thanks\@empty
    \global\let\@author\@empty
    \global\let\@date\@empty
    \global\let\@title\@empty
    \global\let\title\relax
    \global\let\author\relax
    \global\let\date\relax
    \global\let\and\relax}
\def\@maketitle{%
  \newpage
  \null
  \begin{center}%
     \let \footnote \thanks
     \UST@putlogo
     \vskip 15mm%
    {\LARGE \@title \par}%
     \vskip 5mm%
    {\large
     \lineskip .5em%
     \begin{tabular}[t]{c}%
        \@author
     \end{tabular}\par}%
     \ifx\@address\relax\else
        \vskip 10mm%
       {\normalsize\@address\par}
     \fi
     \vskip 5mm%
    {\large \@date}%
  \end{center}%
  \par
  \vskip 5mm}
\fi
\endinput
%%
%% End of file `ustitle.sty'.
