%     \changes{v1.01}{1995/05/02}{Date added to \cs{NeedsTeXFormat}}
% \iffalse
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%<package>\ProvidesPackage{prelim2e}
%<package>         [2009/05/29 v1.3 prelim2e Package (MS)]
%
%<*driver>
\ProvidesFile{prelim2e.drv}
      [2009/05/29 v1.3 Driver for prelim2e Package (MS)]
\documentclass[a4paper]{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage[toc]{multitoc}
\usepackage{lmodern,microtype,svn}
\usepackage{hypdoc}
\usepackage{geometry}
\usepackage[scrtime]{prelim2e}
\GetFileInfo{prelim2e.sty}
\EnableCrossrefs
\RecordChanges    % Gather update information
%%\DisableCrossrefs% Say \DisableCrossrefs if index is ready
\CodelineIndex    % Index code by line number
%\OnlyDescription  % comment out for implementation details
%%\OldMakeIndex    % use if your MakeIndex is pre-v2.9
\setcounter{IndexColumns}{2}
% onecolumn glossary
\makeatletter
  \renewenvironment{theglossary}{%
  \glossary@prologue
  \setlength\emergencystretch{5em}
  \GlossaryParms \let\item\@idxitem \ignorespaces}{}
\makeatother
\setlength{\IndexMin}{40ex}
\setlength{\columnseprule}{.4pt}
\addtolength{\oddsidemargin}{2cm}
\addtolength{\textwidth}{-2cm}
\begin{document}
   \DocInput{prelim2e.dtx}
   \PrintIndex\PrintChanges
   %  Make sure that the index is not printed twice
   %  (ltxdoc.cfg might have a second \PrintIndex command)
   \let\PrintChanges\relax
   \let\PrintIndex\relax
\end{document}
%</driver>
%
% Copyright (C) 1995..2009 by Martin Schr\"oder.
%
% 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
% 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Martin Schröder
%
% This work consists of the files prelim2e.dtx and prelim2e.ins
% and the derived files prelim2e.sty
%
% \fi
%
% \CheckSum{129}
%
%% \CharacterTable
%% {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%  Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%  Digits        \0\1\2\3\4\5\6\7\8\9
%%  Exclamation   \!     Double quote  \"     Hash (number) \#
%%  Dollar        \$     Percent       \%     Ampersand     \&
%%  Acute accent  \'     Left paren    \(     Right paren   \)
%%  Asterisk      \*     Plus          \+     Comma         \,
%%  Minus         \-     Point         \.     Solidus       \/
%%  Colon         \:     Semicolon     \;     Less than     \<
%%  Equals        \=     Greater than  \>     Question mark \?
%%  Commercial at \@     Left bracket  \[     Backslash     \\
%%  Right bracket \]     Circumflex    \^     Underscore    \_
%%  Grave accent  \`     Left brace    \{     Vertical bar  \|
%%  Right brace   \}     Tilde         \~}
%%
%% \iffalse meta-comment
%% ===================================================================
%%  @LaTeX-package-file{
%%    author            = {Martin Schr\"oder},
%%    version           = "1.3",
%%    date              = "29 May 2009",
%%    filename          = "prelim2e.sty",
%%    address           = {Martin Schr\"oder
%%                         Barmer Stra\"se 14
%%                         44137 Dortmund
%%                         Germany},
%%    telephone         = "+49-231-1206574",
%%    email             = "martin@oneiros.de",
%     codetable         = "ISO/ASCII",
%     keywords          = "LaTeX2e, preliminary versions, versions",
%     dependences       = "everyshi, scrtime",
%     supported         = "yes",
%%    docstring         = "LaTeX package which allows the marking of
%%                         preliminary versions of a document."
%%  }
%% ===================================================================
%% \fi
%
% \SVN $Rev: 1374 $
% \SVNdate $Date: 2009-05-30 22:23:36 +0200 (Sa, 30. Mai 2009) $
%
%  \renewcommand{\PrelimWords}{^^A
%     \package{prelim2e} package --
%     Version \fileversion (\SVNRev) --
%     Documentation \LaTeX{}ed^^A
%     }
%
%  \changes{v1.00}{1995/01/26}{New}
%  \changes{v1.21}{1998/08/09}{Documentation improved}
%  \changes{v1.22}{1999/06/08}{Moved to LPPL}
%  \changes{v1.3}{2009/05/29}{LPPL 1.3}
%
%  \newcommand*{\option}[1]{\textnormal{\sffamily#1}}
%  \newcommand*{\package}[1]{\textnormal{\sffamily#1}}
%  \newcommand*{\NEWfeature}[1]{%
%     \hskip 1sp \marginpar{\small\sffamily\raggedright
%     New feature\\#1}}
%  \newcommand*{\NEWdescription}[1]{%
%     \hskip 1sp \marginpar{\small\sffamily\raggedright
%     New description\\#1}}
%
%  \pagestyle{headings}
%
%
% ^^A -----------------------------
%
%  \title{\unskip
%   The \package{prelim2e} package^^A
%   \thanks{^^A
%     The version number of this file is \fileversion, subversion
%     revision~\#\SVNRev, last revised \protect\SVNDate.}^^A
%        }
%  \author{Martin Schr\"oder\\[0.5ex]
%          \normalsize  Barmer Stra\ss{}e 14\\
%          \normalsize  44137 Dortmund\\
%          \normalsize  Germany\\
%          \normalsize  \href{mailto:martin@oneiros.de}{\texttt{martin@oneiros.de}}}
%  \maketitle
%
% ^^A -----------------------------
%
%
%  \begin{abstract}
%     This package allows the marking of (preliminary) versions of a
%     document on the output.
%  \end{abstract}
%
% ^^A -----------------------------
%
%  \tableofcontents
%
% ^^A -----------------------------
%
%  \section{Introduction}
%  ^^A
%  This package allows the marking of (preliminary) versions of a
%  document.
%  This is done using the command \cs{PrelimText}, whose expansion
%  is added \emph{below the footer} of every page of a document (look
%  at the bottom of this page for an example).
%
% ^^A -----------------------------
%
%  \section{Usage}
%  ^^A
%  Simply using this package via 
%  \mbox{\cs{usepackage\{}\package{prelim2e}\texttt{\}}} produces a
%  text in the form of ``Preliminary version -- \today''.
%
%  \DescribeMacro{\PrelimText}
%  \DescribeMacro{\PrelimWords}
%  The text is produced by the commands \cs{PrelimText} and 
%  \cs{PrelimWords}, which can be changed via \cs{renewcommand} or by 
%  using options at the \cs{usepackage} command (see 
%  section~\ref{sec:options}).
%
%  The footer for this documentation was produced by changing 
%  \cs{PrelimWords} to
%  \begin{quote}
%\begin{verbatim}
%\renewcommand{\PrelimWords}{%
%   \textsf{prelim2e} package --
%   Version \fileversion (\svnInfoRevision) --
%   Documentation \LaTeX{}ed%
%   }
%\end{verbatim}
%  \end{quote}
%
%
% ^^A -----------------------------
%
%  \section{Options}
%  \label{sec:options}
%  ^^A
%  The package has the following options:
%  \nopagebreak
%  \begin{description}
%     \item[\normalfont\option{danish}]
%           \changes{v1.23}{2001/02/17}{\option{danish} option added}
%           \NEWfeature{2001/02/17}
%        This sets the text to ``Forel\o{}big version''.
%        It does not use the \package{babel} package.
%     \item[\normalfont\option{draft}]
%        If this option is used a text appears below the normal 
%        pagebody.
%        It is the default.
%     \item[\normalfont\option{final}]
%        If this option is used \package{prelim2e} produces no text.
%     \item[\normalfont\option{english}]
%        This sets the text to ``Preliminary version''.
%        It is the default.
%     \item[\normalfont\option{french}]
%           \changes{v1.20}{1997/05/12}{\option{french} option added}
%           \NEWfeature{1997/05/12}
%        This sets the text to ``Version pr\'eliminaire''.
%        It does not use the \package{french} or \package{babel} package.
%     \item[\normalfont\option{german}]
%        This sets the text to ``Vorl\"aufige Version''.
%        It does not use the \package{german} or \package{babel} package.
%     \item[\normalfont\option{italian}]
%           \changes{v1.23}{2001/02/17}{\option{italian} option added}
%           \NEWfeature{2001/02/17}
%        This sets the text to ``Versione preliminare''.
%        It does not use the \package{babel} package.
%     \item[\normalfont\option{norsk}]
%           \changes{v1.3}{2009/05/29}{\option{norsk} option added}
%           \NEWfeature{2009/05/29}
%        This sets the text to ``Forel\o{}pig versjon''.
%        It does not use the \package{babel} package.
%     \item[\normalfont\option{time}]
%           \changes{v1.10}{1996/01/01}{\option{time} option added}
%           \NEWdescription{1997/05/12}
%        This adds the time at the beginning of the current \LaTeX{}
%        to the text.
%        The time is produced using the \cs{thistime} command, which may
%        be provided by the \package{scrtime} package\cite{package:scrtime}.
%        If you don't use the \package{scrtime} package (e.\,g. by 
%        specifying the \option{scrtime} option), you must
%        provide it yourself or by some other package.
%     \item[\normalfont\option{scrtime}]
%           \changes{v1.20}{1997/05/12}{\option{scrtime} option added}
%           \NEWfeature{1997/05/12}
%        This loads the \package{scrtime} package\cite{package:scrtime} 
%        (part of the KOMA-Script bundle), which provides the 
%        \cs{thistime} command used by the \option{time} option.
%        The \option{scrtime} option implies the \option{time} option.
%  \end{description}
%  All other options are passed to the \package{scrtime} package if the
%  \option{scrtime} option is selected.
%
%
% ^^A -----------------------------
%
%  \section{Required packages}
%  ^^A
%  The package requires the following packages:
%  \begin{description}
%     \item[\normalfont\package{everyshi}\cite{package:everyshi}]
%        It is used to implement the setting of the text below the normal 
%        pagebody.
%     \item[\normalfont\package{scrtime}\cite{package:scrtime}]
%           \changes{v1.10}{1996/01/01}{\package{scrtime} instead of 
%              \package{printtim}}
%           \NEWdescription{1997/05/12}
%        It is used to typeset the current time and is needed if the 
%        \option{scrtime} option is selected.
%  \end{description}
%
%
% ^^A -----------------------------
%
%  \section{Putting more things at the bottom}
%  ^^A
%  Another package you might like to use with \package{prelim2e} is 
%  \package{vrsion}\cite{package:vrsion}.
%  This allows the definition and maintenance of a version number like
%  3.14159 \emph{within \LaTeX}, which can be put at the bottom of every
%  page using \package{prelime2e}.
%
%
% ^^A -----------------------------
%
%  \StopEventually{^^A
%
%
% ^^A -----------------------------
%
%  \section{Acknowledgements}
%  ^^A
%  The idea of this package is based on 
%  \texttt{prelim.sty}\cite{package:prelim} for \LaTeX2.09 by Robert 
%  Tolksdorf (\texttt{tolk@cs.tu-berlin.de}).
%  It provides nearly the same functionality as \package{prelim2e}, but
%  in a very dirty way: it uses a modified output routine and does not 
%  work with \LaTeXe.
%
%  The time functionality now uses the \package{scrtime} package by
%  Markus Kohm (\texttt{markus.kohm@gmx.de}).
%
%  Rowland Bartlett (\texttt{R.BARTLETT@liverpool-john-moores.ac.uk})
%  brought forth the idea of separating the \option{time} option and the
%  \package{scrtime} package; 
%  Daniel Courjon (\texttt{dcourjon@utinam.univ-fcomte.fr}) provided
%  the text for the \option{french} option,
%  Arne J\o{}rgensen (\texttt{arne.jorgensen@tug.dk}) 
%  provided the text for the \option{danish} option,
%  Davide Giovanni Maria Salvetti (\texttt{salve@debian.org}) 
%  and Riccardo Murri (\texttt{murri@phc.unipi.it}) 
%  both provided the text for the \option{italian} option,
% and Sveinung Heggen (\texttt{sveinung.heggen@orkla.no}) provided the
% text for the \option{norsk} option.
%
%  As usual Rebecca Stiels improved the quality of this documentation.
%
%
% ^^A -----------------------------
%
%  \begin{thebibliography}{1}
%     \raggedright
%     \bibitem{package:prelim}
%        Mats Dahlgren.
%        \newblock \package{vrsion} -- a \LaTeX{} Macro for version 
%           Numbering of Files.
%        \newblock \url{CTAN: tex-archive/macros/latex/contrib/supported/vrsion/vrsion.dtx}.
%        \newblock \LaTeXe{} package.
%     \bibitem{package:scrtime}
%        Markus Kohm.
%        \newblock The \package{KOMA}-timedate-bundle.
%        \newblock \url{CTAN: tex-archive/macros/latex/contrib/supported/koma-script/scrtime.dtx}.
%        \newblock \LaTeXe{} package.
%     \bibitem{package:everyshi}
%        Martin Schr\"oder.
%        \newblock The \package{everyshi} package.
%        \newblock \url{CTAN: tex-archive/macros/latex/contrib/supported/ms/everyshi.dtx}.
%        \newblock \LaTeXe{} package.
%     \bibitem{package:vrsion}
%        Robert Tolksdorf.
%        \newblock Kennzeichnung von Vorversionen eines Dokuments.
%        \newblock \url{CTAN: tex-archive/macros/latex209/contrib/prelim/}.
%        \newblock \LaTeX2.09 package.
%  \end{thebibliography}
%
%  }
%
%
% ^^A -----------------------------
%
%  \section{The implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsection{Initial Code}
%  ^^A
%  \begin{macro}{\if@prelim@draft}
%  \cs{if@prelim@draft} is used to flag the use of the \option{draft}
%  or \option{final} option.
%    \begin{macrocode}
\newif\if@prelim@draft
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\if@prelim@time}
%     \changes{v1.10}{1996/01/01}{new}
%  \cs{if@prelim@time} is used to flag the use of the \option{time}
%  option.
%    \begin{macrocode}
\newif\if@prelim@time
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\if@prelim@scrtime}
%     \changes{v1.20}{1997/05/12}{new}
%  \cs{if@prelim@scrtime} is used to flag the use of the \option{scrtime}
%  option.
%    \begin{macrocode}
\newif\if@prelim@scrtime
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\PrelimWords}
%  \cs{PrelimWords} holds the language-dependend text used in 
%  \cs{PrelimText}
%    \begin{macrocode}
\newcommand{\PrelimWords}{}
%    \end{macrocode}
%  \end{macro}
%
%
% ^^A -----------------------------
%
%  \subsection{Declaration of options}
%
% ^^A -----------------------------
%
%
%  \subsubsection{\option{draft} option}
%  ^^A
%  The \option{draft} and \option{final} option control the behavior
%  of \package{prelim2e}: Only if \option{final} is used in 
%  \cs{documentclass} or 
%  \mbox{\cs{usepackage\{}\package{prelim2e}\texttt{\}}} text is
%  produced.
%    \begin{macrocode}
\DeclareOption{draft}{\@prelim@drafttrue}
\DeclareOption{final}{\@prelim@draftfalse}
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsubsection{Language options}
%  ^^A
%  \option{danish}, \option{english}, \option{french}, \option{german},
%  \option{italian} and \option{norsk} control the content of \cs{PrelimWords}.
%     \changes{v1.20}{1997/05/12}{\option{french} option added}
%     \changes{v1.23}{2001/02/17}{\option{danish} option added}
%     \changes{v1.23}{2001/02/17}{\option{italian} option added}
%     \changes{v1.3}{2009/05/29}{\option{norsk} option added}
%    \begin{macrocode}
\DeclareOption{danish}{%
   \renewcommand{\PrelimWords}{Forel\o{}big version}}
\DeclareOption{english}{%
   \renewcommand{\PrelimWords}{Preliminary version}}
\DeclareOption{french}{%
   \renewcommand{\PrelimWords}{Version pr\'eliminaire}}
\DeclareOption{german}{%
   \renewcommand{\PrelimWords}{Vorl\"aufige Version}}
\DeclareOption{italian}{%
   \renewcommand{\PrelimWords}{Versione preliminare}}
\DeclareOption{norsk}{%
  \renewcommand{\PrelimWords}{Forel\o{}pig versjon}} 
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsubsection{Time options}
%  ^^A
%     \changes{v1.10}{1996/01/01}{\option{time} option added}
%  \option{time} controls the output of the current time at
%  \cs{PrelimWords}.
%    \begin{macrocode}
\DeclareOption{time}{\@prelim@timetrue}
%    \end{macrocode}
%
%     \changes{v1.20}{1997/05/12}{\option{scrtime} option added}
%  \option{scrtime} controls the loading of the \package{scrtime} 
%  package.
%  It implies \option{time}.
%    \begin{macrocode}
\DeclareOption{scrtime}{\@prelim@scrtimetrue\@prelim@timetrue}
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsubsection{Other options}
%  ^^A
%     \changes{v1.20}{1997/05/12}{check \cs{if@prelim@scrtime}}
%     \changes{v1.10}{1996/01/01}{\cs{DeclareOption*} added}
%  All unused options are passed to the \package{scrtime} package if 
%  the \option{scrtime} option is selected.
%    \begin{macrocode}
\DeclareOption*{%
   \if@prelim@scrtime
      \PassOptionsToPackage{\CurrentOption}{scrtime}%
   \fi
   }
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsection{Executing options}
%  ^^A
%  The default options are \option{draft} and \option{english}.
%    \begin{macrocode}
\ExecuteOptions{draft,english}
\ProcessOptions\relax
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsection{Loading packages}
%  ^^A
%     \changes{v1.20}{1997/05/12}{check \cs{if@prelim@scrtime}}
%  We need the \package{everyshi} package---and \package{scrtime}, if the
%  \option{scrtime} option is specified.
%    \begin{macrocode}
\RequirePackage{everyshi}[1995/01/25]
\if@prelim@scrtime
   \RequirePackage{scrtime}
\fi
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsection{Producing the text}
%  ^^A
%  \begin{macro}{\PrelimText}
%     \changes{v1.10}{1996/01/01}{\cs{thistime} instead of \cs{PrintTime}}
%  \cs{PrelimText} produces the text which is put below the page.
%  It can be changed via \cs{renewcommand}.
%  The style of the text is controlled by \cs{PrelimTextStyle}.
%  We first have to reset the style and size, otherwise the settings in
%  effect at the point of text where \cs{ouput} is called would be used.
%    \begin{macrocode}
\newcommand{\PrelimText}{%
   \textnormal{%
      \footnotesize
      \PrelimTextStyle
      \PrelimWords{} -- \today
      \if@prelim@time
         \ -- \thistime
      \fi
      }%
   }
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\PrelimTextStyle}
%  \cs{PrelimTextStyle} controls the style of the text produced by
%  \cs{PrelimText}.
%  It's default is empty.
%    \begin{macrocode}
\newcommand{\PrelimTextStyle}{}
%    \end{macrocode}
%  \end{macro}
%
%
% ^^A -----------------------------
%
%  \subsection{Putting the text below the page}
%  ^^A
%  We put the text below the page via \cs{EveryShipout} provided by
%  the \package{everyshi} package.
%  This is done by \cs{@Prelim@EveryShipout}.
%
%  \begin{macro}{\@Prelim@EveryShipout}
%  \changes{v1.10}{1996/01/01}{\cs{hbox to}$\rightarrow$\cs{hb@xt@}}
%  \changes{v1.24}{2004/03/28}{Bugfix: Add missing \%.
%                              Bug reported by Carsten Heinz (\texttt{cheinz@gmx.de}).}
%  \cs{@Prelim@EveryShipout} puts the text produced by \cs{PrelimText}
%  below the page.
%  To do this we modify \cs{box255}: We append a \cs{vbox} with height
%  and depth of 0pt and the width of \cs{box255} which contains a 
%  \cs{hbox} with the width of \cs{box255} in which \cs{PrelimText}
%  is centered.
%    \begin{macrocode}
\newcommand{\@Prelim@EveryShipout}{%
   \bgroup
%    \end{macrocode}
%  First we save the dimensions of \cs{box255}: height, width and depth;
%  and calculate the total height of \cs{box255}.
%    \begin{macrocode}
      \dimen\z@=\wd\@cclv
      \dimen\@ne=\ht\@cclv
      \dimen\tw@=\dp\@cclv
      \dimen\thr@@=\dimen1
      \advance\dimen\thr@@ by \dimen\tw@
%    \end{macrocode}
%  Then we set \cs{box255}: 
%  A \cs{vbox} to the total height of \cs{box255}.
%  In this a \cs{hbox} to the width of \cs{box255} is included, in which
%  \cs{box255} is set.
%    \begin{macrocode}
      \global\setbox\@cclv\vbox to \dimen\thr@@{%
         \hb@xt@\dimen\z@{%
            \box\@cclv%
            \hss
            }%
%    \end{macrocode}
%  To this we append the text produced by \cs{PrelimText}.
%  It is put in a \cs{vbox} to 0pt in which a \cs{hbox} to the width of 
%  \cs{box255} is included, in which \cs{PrelimText} is set.
%  We have to reset \cs{protect} because it is set to \cs{noexpand} by
%  the output routine.
%    \begin{macrocode}
         \vbox to \z@{%
            \hb@xt@\dimen\z@{%
               \let\protect\relax
               \hfill\PrelimText\hfill
               }%
            \vss
            }%
         \vss
         }%
%    \end{macrocode}
%  Finally we set the dimensions of \cs{box255} to the values they had
%  before \cs{@Prelim@EveryShipout}.
%    \begin{macrocode}
      \wd\@cclv=\dimen\z@
      \ht\@cclv=\dimen\@ne
      \dp\@cclv=\dimen\tw@
   \egroup
   }
%    \end{macrocode}
%  \end{macro}
%
%
% ^^A -----------------------------
%
%  \subsection{Tieing \package{prelim2e} into the system}
%  ^^A
%  \cs{@Prelim@EveryShipout} is tied into the system via 
%  \cs{EveryShipout}.
%  But only if the \option{draft} option is used.
%    \begin{macrocode}
\if@prelim@draft
   \EveryShipout{\@Prelim@EveryShipout}
\fi
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \Finale
% ^^A vim:tw=70:ts=2
