% \iffalse
%<*never>
\documentclass{ltxdoc}

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{xspace,url}
\usepackage[english]{babel}

\newcommand{\prosper}{\textsf{prosper}\xspace}
\newcommand{\pprprv}{\textsf{ppr-prv}\xspace}

\setlength{\parindent}{15pt}

\MakeShortVerb{\|}
\AtBeginDocument{\CodelineIndex\EnableCrossrefs}
\AtEndDocument{\PrintIndex}
\GetFileInfo{ppr-prv.cls}
\begin{document}
\def\fileversion{v 0.13c}
\def\filedate{2005/09/02}
\def\docdate{2004/03/21}

\DocInput{ppr-prv.dtx}
\end{document}
%</never>
% \fi
% \CheckSum{1289}
% \iffalse meta-comment
%
%========================================================================
% ppr-prv class: "Prosper Preview", a class to produce a printable
%                version of prosper slides
% Copyright (C) 2003-2004 Mathieu Goutelle
% mgoutell[at]users[dot]sourceforge[dot]net
%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% 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.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
% CVSId: $Id: ppr-prv.dtx,v 1.9 2005/09/04 19:10:39 mgoutell Exp $
%========================================================================
%
% \fi
%% \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         \~}
%
% \urlstyle{sf}
% \title{The \pprprv class: Prosper Preview}
% \author{Mathieu \textsc{Goutelle}}
% \date{\fileversion, \docdate}
% \maketitle
% \tableofcontents
%
% \section{Introduction}
%
% \subsection{Presentation}
% This class is used with LaTeX presentations using the \prosper class. \pprprv
% stands for "Prosper Preview". The aim of this class is to produce a printable
% version of the slides written with \prosper, with two slides per page.
%
% The result tries to be as accurate as possible. The major problem is the support
% of the starred version of the \{only,until,from\}Slide macros: the result is
% approximately what you can expect... It is far from perfect, just because the
% content of this macros are heaped over each other. But, it is difficult to
% handle these overlays on a sheet of paper!
%
% You can send comments, bugs report or proposed improvements to the author by
% email: \url{mgoutell[at]users[dot]sourceforge[dot]net}.
%
% \subsection{Use of \pprprv}
%
% The installation of ppr-prv files follows the same scheme as any other package
% installation on your distrib. You can consult this page from the UK TeX FAQ:
% \url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=instpackages}.
%
% To use ppr-prv, you just have to change the |\documentclass| from |prosper| to
% |ppr-prv|. You don't need to change another thing to your \prosper document: all
% the macros and options of \prosper are normally fully supported by \pprprv. You
% can change the footer of each "slide" by changing |\slidename| and |\no|. By
% default, it is defined as: |\newcommand{\slidename}{slide}| and
% |\newcommand{\no}{\#}|. Since version 0.07, it uses Babel to support various
% languages (english, french, german and all their variants): if Babel is loaded,
% the footer is adapted to the chosen language. You can off course change it
% manually with |\renewcommand{\slidename}{...}| and |\renewcommand{\no}{...}| after
% |\begin{document}|.
%
% There is a new option for \pprprv since v0.11: |nopagebreak|. This can be used
% to let \LaTeX{} decide where to break the page instead of every two slides. It
% may be used for producing a more compact document. The macro |\NoPageBreak| has
% exactly the same meaning, except that it can be used at any time in the
% document. \pprprv also used since v0.11 the |geometry| package to define the
% layout of the page. You can change it by using |\geometry{...}| (see the
% documentation of this package for more details).
%
% If you use the patch for Prosper written by Hendri Adriaens
% (\url{http://stuwww.uvt.nl/~hendri/Downloads/haprosper.html}), you can use
% \pprprv as well since v. 0.09: features like toc, toc section and notes are
% fully supported. The use is exactly the same if you either load the patch or
% not. You just have to change your |documentclass| from |prosper| to |ppr-prv|
% and let the class do the work of redefining the macros for you. Since v. 0.09
% is the first release with a support for the patch, it may remain some bugs.
% Don't hesitate to report them to the author of \pprprv.
%
% I have tried not to depend on |pstricks| in \pprprv. It means that, if you don't
% use |pstricks| in your slide, you can use pdf\LaTeX{} to compile your \pprprv
% document, even if the compilation can lead to |Non-PDF special ignored!|
% warnings. Obviously, it doesn't work if you have some |pstricks| stuff in your
% slide contents or if you don't provide the figures in a format pdf\LaTeX{} can
% understand (PDF, PNG, JPG, MetaPost e.g.): in these cases, you still need to
% use \LaTeX{} to produce your document.
%
% A common mistake is to use floating environment in slides. It may work with
% regular \prosper document. But with \pprprv, it may leads to error message
% such as |Not in outer par mode| or |Float lost|. \pprprv tries to handle this
% issue by defining the floats as non-floating. But, if you specify some
% placement options (like [hbtp]), you will get these errors. By the way, you
% \textbf{really} don't need floats in slides!
%
% \StopEventually{}
%
% \section{Details of the code}
%
% \subsection{Preamble and options}
% We define first the version and all the stuff we need (or not) to begin
%    \begin{macrocode}
%<*class>
\def\PPRPRV@Version{v. 0.13}
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{ppr-prv}[2005/09/02, \PPRPRV@Version]
\typeout{(c) 2003-2005 Mathieu Goutelle}
%</class>
%    \end{macrocode}
%
% Then we define the \prosper options to handle the one useful in our case
% (e.g. draft, footer) and ignore the others. There is also the declaration of
% the |nopagebreak| option specific to \pprprv.
%    \begin{macrocode}
%<*class>
\newif\ifDVItoPS
\DeclareOption{ps}{\global\DVItoPStrue}
\DeclareOption{pdf}{\global\DVItoPSfalse}

\newif\ifisDraft
\DeclareOption{draft}{\global\isDrafttrue}
\DeclareOption{final}{\global\isDraftfalse}

\newif\ifinColor
\DeclareOption{slideColor}{}
\DeclareOption{slideBW}{}

\newif\ifallPages
\DeclareOption{total}{}
\DeclareOption{nototal}{}

\newif\ifcolorBG
\DeclareOption{nocolorBG}{}
\DeclareOption{colorBG}{}

\newif\ifAccumulate
\DeclareOption{accumulate}{}
\DeclareOption{noaccumulate}{}

\newif\ifnoFooter
\DeclareOption{noFooter}{\global\noFootertrue}
\noFooterfalse

\newif\if@distiller
\@distillerfalse
\DeclareOption{distiller}{\global\@distillertrue}

\newif\if@nopagebreak
\@nopagebreakfalse
\DeclareOption{nopagebreak}{\global\@nopagebreaktrue}

\DeclareOption{YandY}{\gdef\@pdf@driver{dvipsone}}
\DeclareOption{ps2pdf}{\gdef\@pdf@driver{ps2pdf}}
\DeclareOption{vtex}{\gdef\@pdf@driver{vtex}}

%% Default style file = default
\def\Style@chosen{default}
\DeclareOption*{\global\let\Style@chosen=\CurrentOption}
%</class>
%    \end{macrocode}
%
% Here we pass all options a user want to add to specify the paper and font
% sizes to the article class and geometry package.
%    \begin{macrocode}
%<*class>
\DeclareOption{a4paper}{%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}
\DeclareOption{a5paper}{%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}
\DeclareOption{b5paper}{%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}
\DeclareOption{letterpaper}{%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}
\DeclareOption{legalpaper}{%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}
\DeclareOption{executivepaper}{%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}
\DeclareOption{landscape}{%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}

\PassOptionsToClass{10pt,11pt,12pt,oneside,twoside,final,draft,
  leqno,fleqn,openbib}{article}
%</class>
%    \end{macrocode}

% Then, we define a default behaviour, which is exactly the same as the \prosper
% one, except we add options for article (a4paper and 10pt).
%    \begin{macrocode}
%<*class>
\ExecuteOptions{final,slideBW,total,nocolorBG,noaccumulate,ps,ps2pdf,a4paper,10pt}
\ProcessOptions\relax
%</class>
%    \end{macrocode}
%
% \subsection{Main code}
% As a first action, we load the article class and save some macros for further use.
%    \begin{macrocode}
%<*class>
%% Preliminary stuff
\LoadClass{article}

%% I save here the old value of the macros I need and which may be
%% modified by HA-prosper and define a test for detecting HA-prosper.
\newif\if@HAprosper\global\@HAprosperfalse
\let\old@section\section
\let\old@subsection\subsection
\let\old@itemize\itemize
\let\old@enditemize\enditemize
\let\old@enumerate\enumerate
\let\old@endenumerate\endenumerate
%</class>
%    \end{macrocode}
%
% We then load |pstricks|, |graphicx| and |hyperref| to exactly mimic the
% \prosper environment and some others for internal use (|textcomp| and
% |geometry|). The |keyval| package is for HA-\prosper support.
%    \begin{macrocode}
%<*class>
\RequirePackage{pstricks}
\RequirePackage{textcomp}
\RequirePackage{graphicx}
\RequirePackage[hmargin=2cm,vmargin=2cm,noheadfoot]{geometry}
\RequirePackage{keyval,ifpdf}
\ifpdf\gdef\@pdf@driver{pdftex}\fi
\RequirePackage[\@pdf@driver,plainpages=false,colorlinks=true]{hyperref}
%</class>
%    \end{macrocode}
%
% Here we want to suppress the common error of using floats in slides: we
% redefine them as non-floats.
%    \begin{macrocode}
%<*class>
\RequirePackage{float}
\newfloat{figure}{H}{lof}
\newfloat{table}{H}{lot}
%</class>
%    \end{macrocode}
%
% \DescribeMacro{NoPageBreak}
% The |\NoPageBreak| macro has the same meaning has the |nopagebreak| option,
% except it can be used at any time in the document. To revert the effect of
% |\NoPageBreak|, the |\PageBreak| macro is defined. We define also the indent
% to 0pt and we don't want folio nor head/foot.
%    \begin{macrocode}
%<*class>
\newcommand{\NoPageBreak}{\global\@nopagebreaktrue}
\newcommand{\PageBreak}{\global\@nopagebreakfalse}

\setlength{\parindent}{0pt}
\pagestyle{empty}
%</class>
%    \end{macrocode}
%
% For the support for the HA-propser package, we need to define some \prosper
% internals to avoid the HA patch to complain about a missing length or macro.
%    \begin{macrocode}
%<*class>
%% Support for the HA-propser package: we try here to mimic the prosper
%% class to avoid the HA patch to complain about a missing length or
%% macro.
\let\normal@write\write
\newlength{\slideWidth}
\setlength{\slideWidth}{\linewidth}
\newlength{\slidewidth}
\setlength{\slidewidth}{\linewidth}
\newlength{\slideheight}
\newcounter{trueSlideCounter}
\newcounter{overlaysCount}
\newcounter{item@step}
\newcommand{\slidetitle}[1]{}
\newcommand{\slideframe}[1]{}
\newcommand{\NewSlideStyle}[4][]{}
\newcommand{\newslideframe}[2]{}
\newcommand{\slidepagestyle}[1]{}
\def\@fontTextColor{}
\def\@fontTextBW{}
\def\@fontTitleColor{}
\def\@fontTitleBW{}
\def\@fontSubtitleColor{}
\def\@fontSubtitleBW{}
\def\ptsize#1{}
\newenvironment{slide@seminar}{}{}
\def\@DefMyItem{}
\def\@titleSpacing{\vspace*{10pt}}
\newif\ifInOverlays\InOverlaysfalse
\newcounter{limitOverlays}
\def\@cleanupOverlay{}
%</class>
%    \end{macrocode}
%
% Here are some \textsf{seminar} internal we need also for HA-\prosper.
%    \begin{macrocode}
%<*class>
%% Commands from Seminar
\newcounter{slide}
\newcommand{\renewpagestyle}[3]{}
\def\slidefonts{}
\newif\ifarticle\articletrue
%</class>
%    \end{macrocode}
%
% This test will be used to decide if we need to insert a page break before
% printing the current slide.
%    \begin{macrocode}
%<*class>
% Test to see if we need a pageskip
\newif\if@needsnewpage\global\@needsnewpagetrue
%</class>
%    \end{macrocode}
%
% \DescribeMacro{part}
% We redefine the |\part| command first to suppress the optional transition
% argument and second to handle pagebreak and slides counter.
%    \begin{macrocode}
%<*class>
%% Definition of the part command to suppress the optional transition argument
\let\part\relax
\newcommand{\part}[2][]{%
  \if@needsnewpage
    \if@nopagebreak\else\ifodd\theslideii\else\mbox{}\clearpage\fi\fi
    \global\@needsnewpagefalse
  \fi
  \refstepcounter{slidei}%
  \old@section*{#2}%
}
%</class>
%    \end{macrocode}
%
% \DescribeMacro{maketitle}
% The |\maketitle| command is completely redefined since the |article| one isn't
% relevant: \prosper define some extra field we need to handle here.
%    \begin{macrocode}
%<*class>
%% Handle all the maketitle stuff
\let\@cartouche\@empty
\newcommand{\slideCaption}[1]{\gdef\@cartouche{#1}}
\let\@Subtitle\@empty
\newcommand{\subtitle}[1]{\gdef\@Subtitle{#1}}
\let\old@Title\title
\renewcommand{\title}[1]{\gdef\@Title{#1}}

\let\@email\@empty
\newcommand{\email}[1]{\gdef\@email{#1}}
\let\@institution\@empty
\newcommand{\institution}[1]{\gdef\@institution{#1}}

\gdef\@Author{}
\renewcommand{\author}[1]{\gdef\@Author{#1}}

\renewcommand{\maketitle}{
  \thispagestyle{empty}\setcounter{page}{0}%
  \refstepcounter{slidei}%
  \mbox{}\vfill
  \begin{center}%
    {\LARGE \@Title \par}%
    \ifx\@Subtitle\@empty\else\vskip 2em{\large\@Subtitle\par}\fi
    \vskip 6em%
    {\large\@Author
    \ifx\@email\@empty\else\vskip 1em\@email\fi
    \ifx\@institution\@empty\else\vskip 1em\@institution\par\fi}%
  \end{center}%
  \vfill\mbox{}\clearpage
  \global\@needsnewpagefalse
}
%</class>
%    \end{macrocode}
%
% \DescribeEnv{Itemize}\DescribeEnv{itemstep}
% We redefine the |Itemize| and |itemstep|. They have the same behaviour as the
% original |itemize| of |article|. We have to ignore the optional argument of
% |itemstep|.
%    \begin{macrocode}
%<*class>
%% Definition of the Itemize environment ;)
\let\Itemize\itemize
\let\endItemize\enditemize

%% Definition of the itemstep environment to gobble the optional argument.
\newenvironment{itemstep}[1][]%
  {\itemize}
  {\enditemize}
%</class>
%    \end{macrocode}
%
% \DescribeEnv{slide}
% We define here the |slide| environment. We first define |prv@slide| because we
% will need it later on, for the support of HA-prosper.
%   
% |\@size@overlay| will contain the height of the current slide and will be used
% to correctly draw the frame around slides. This height is computed as the
% maximum real height of the different overlays (espcially those defined with a
% Slide* macros) of the slide and is equal at least to 4cm, to avoid a really
% little frame when the user wants exactly two slides per page. The
% |\@slide@content| box contains the content of the slide. The first counter is
% for the number printed in footer, i.e.  exactly the same as the one in
% \prosper. The second is used internally to print exactly two slides per page
% (without counting part for example).
%    \begin{macrocode}
%<*class>
%% \@size@overlay contains the height of the current slide if we are using
%% overlays. It is equal at least to 4cm to try to avoid really little frame
%% when the user wants exactly two slides per page.
\newlength{\@size@tmp}
\global\@size@tmp\z@
\newlength{\@size@overlay}
%% Definition of the slide environment
\newsavebox{\@slide@content} % will contain the slide
%% Slide counter to be printed on the bottom of each slide
\newcounter{slidei}\setcounter{slidei}{0}
%% Slide counter to print just two slides per page (even when there is a
%% \part...)
\newcounter{slideii}\setcounter{slideii}{0}

\newenvironment{prv@slide}[1]{%
  \if@needsnewpage
    \if@nopagebreak\else\ifodd\theslideii\mbox{}\clearpage\fi\fi
  \fi
  \global\@needsnewpagetrue
  \if@nopagebreak
    \global\setlength{\@size@overlay}{\z@}%
  \else
    \global\setlength{\@size@overlay}{4cm}%
  \fi
  \begin{lrbox}{\@slide@content}\begin{minipage}{\linewidth}%
  \old@subsection*{#1}%
}{%
  \end{minipage}\end{lrbox}%
  \settoheight{\@size@tmp}{\@slide@content}%
  \begin{minipage}{\linewidth}
  \fbox{%
    \usebox{\@slide@content}%
    \ifdim\@size@overlay>\@size@tmp
       \addtolength{\@size@overlay}{\baselineskip}%
       \rule[-\@size@overlay]{1pt}{0pt}%
    \fi
  }%
  \ifnoFooter\else
    \ifhmode\\\fi
    \makebox[\linewidth][r]{%
      \footnotesize
      \ifx\@cartouche\@empty\else\@cartouche~---~\fi
      \slidename~\no\theslidei}%
  \fi
  \end{minipage}
  \par\if@nopagebreak\bigskip\else\vfill\fi
}
\newenvironment{slide}[2][]
{%
  \refstepcounter{slidei}\stepcounter{slideii}%
  \begin{prv@slide}{#2}%
}
  {\end{prv@slide}}
%</class>
%    \end{macrocode}
%
% At the end of the document, we print an invisible box to attach the |\vfill|
% and be sure the last slide doesn't flush to the bottom of the page.
%    \begin{macrocode}
%<*class>
\AtEndDocument{\if@nopagebreak\else\ifodd\theslideii\vfill\mbox{}\else\fi\fi}
%</class>
%    \end{macrocode}
%
% Here, we ignore a lot of \prosper macros.
%    \begin{macrocode}
%<*class>
%% For the \Logo, don't do anything !
\newcommand{\Logo}{%
    \@ifnextchar({\Logo@one}{\Logo@two}%
}
\def\Logo@one(#1)#2{}
\def\Logo@two#1{}

%% For the \Font*, don't do anything !
\newcommand{\FontTitle}[2]{}
\newcommand{\FontSubtitle}[2]{}
\newcommand{\FontText}[2]{}
%</class>
%    \end{macrocode}
%
% In the following code, we handle the overlays. The tricky part is the
% definition of the starred version of \{only,until,from\}Slide macros. For
% these, we need to measure the content of the material before smashing it in a
% Opt height box. We put this height in the |\@size@overlay| length we use
% previously in |prv@slide| to draw a frame with the correct height.
%    \begin{macrocode}
%<*class>
%% Definition of the whole overlay stuff: a bit annoying...
\newcommand{\overlays}[2]{#2} % We ignore overlays

\def\FromSlide#1{\relax}
\def\UntilSlide#1{\relax}
\def\OnlySlide#1{\relax}

\long\def\fromSlide@NE#1#2{#2}
\long\def\untilSlide@NE#1#2{#2}
\long\def\onlySlide@NE#1#2{#2}

\newbox\PRV@tempbox
\long\def\fromSlide@E#1#2{%
  \sbox\PRV@tempbox{\begin{minipage}{\linewidth}#2\end{minipage}}%
  \setlength{\@size@tmp}{\the\ht\PRV@tempbox}%
  \addtolength{\@size@tmp}{\the\dp\PRV@tempbox}%
  \ifdim\@size@tmp>\@size@overlay\global\@size@overlay\@size@tmp\fi
  \vbox to 0pt\bgroup\usebox{\PRV@tempbox}\egroup
  \vskip -\baselineskip\ignorespaces
}
\long\def\untilSlide@E#1#2{%
  \sbox\PRV@tempbox{\begin{minipage}{\linewidth}#2\end{minipage}}%
  \setlength{\@size@tmp}{\the\ht\PRV@tempbox}%
  \addtolength{\@size@tmp}{\the\dp\PRV@tempbox}%
  \ifdim\@size@tmp>\@size@overlay\global\@size@overlay\@size@tmp\fi
  \vbox to 0pt\bgroup\usebox{\PRV@tempbox}\egroup
  \vskip -\baselineskip\ignorespaces
}
\long\def\onlySlide@E#1#2{%
  \sbox\PRV@tempbox{\begin{minipage}{\linewidth}#2\end{minipage}}%
  \setlength{\@size@tmp}{\the\ht\PRV@tempbox}%
  \addtolength{\@size@tmp}{\the\dp\PRV@tempbox}%
  \ifdim\@size@tmp>\@size@overlay\global\@size@overlay\@size@tmp\fi
  \vbox to 0pt\bgroup\usebox{\PRV@tempbox}\egroup
  \vskip -\baselineskip\ignorespaces
}

\def\fromSlide{\@ifstar{\fromSlide@E}{\fromSlide@NE}}
\def\untilSlide{\@ifstar{\untilSlide@E}{\untilSlide@NE}}
\def\onlySlide{\@ifstar{\onlySlide@E}{\onlySlide@NE}}
%</class>
%    \end{macrocode}
%
% We define some \prosper macros we don't really need in \pprprv. But we
% obviously need to define it...
%    \begin{macrocode}
%<*class>
%% All the things I may have forgotten if I haven't read the docs
%% carefully enough
\newcommand{\PDFtransition}[1]{}
\newcommand{\DefaultTransition}[1]{}
\def\NoFrenchBabelItemize{\relax}
\newcommand{\ColorFoot}[1]{}
\newif\ifshowVersion
\showVersionfalse
\newcommand{\displayVersion}{\global\showVersiontrue}

\def\fontTitle#1{#1}
\def\fontText#1{#1}

\newcommand{\myitem}[2]{}

%% Stolen from the prosper.cls code
\newcommand{\PDForPS}{%
  \ifDVItoPS
    \let\prosper@next\@secondoftwo
  \else
    \let\prosper@next\@firstoftwo
  \fi
  \prosper@next}
%% #1 appears on the slide only on PS mode
\newcommand{\onlyInPS}{%
  \ifDVItoPS
    \let\prosper@next\@iden
   \else
    \let\prosper@next\@gobble
  \fi
  \prosper@next}
%% #1 appears on the slide only on PDF mode
\newcommand{\onlyInPDF}{%
  \ifDVItoPS
    \let\prosper@next\@gobble
  \else
    \let\prosper@next\@iden
  \fi
  \prosper@next}
%</class>
%    \end{macrocode}
%
% \subsection{AtBeginDocument code}
% Finally, we add some |\AtBeginDocument| hackery. The purpose is first to
% support multi-language with Babel and we need to know if this package is
% loaded. 
%    \begin{macrocode}
%<*class>
\AtBeginDocument{% Multi-language support with Babel
%</class>
%    \end{macrocode}
%
% If we detect Babel, we test the loaded language and define the footer macros
% according to this.
%    \begin{macrocode}
%<*class>
  \@ifpackageloaded{babel}{%
    \def\@test{french}%
    \ifx\languagename\@test
      \newcommand{\slidename}{transparent}%
      \providecommand{\no}{n\textdegree}%
    \fi
    \def\@test{english}%
    \ifx\languagename\@test
      \newcommand{\slidename}{slide}%
      \providecommand{\no}{\#}%
    \fi
    \def\@test{british}%
    \ifx\languagename\@test
      \newcommand{\slidename}{slide}%
      \providecommand{\no}{\#}%
    \fi
    \def\@test{canadian}%
    \ifx\languagename\@test
      \newcommand{\slidename}{slide}%
      \providecommand{\no}{\#}%
    \fi
    \def\@test{USenglish}%
    \ifx\languagename\@test
      \newcommand{\slidename}{slide}%
      \providecommand{\no}{\#}%
    \fi
    \def\@test{UKenglish}%
    \ifx\languagename\@test
      \newcommand{\slidename}{slide}%
      \providecommand{\no}{\#}%
    \fi
    \def\@test{german}%
    \ifx\languagename\@test
      \newcommand{\slidename}{transparent}%
      \providecommand{\no}{Nr.}%
    \fi
    \def\@test{germanb}%
    \ifx\languagename\@test
      \newcommand{\slidename}{transparent}%
      \providecommand{\no}{Nr.}%
    \fi
    \def\@test{austrian}%
    \ifx\languagename\@test
      \newcommand{\slidename}{transparent}%
      \providecommand{\no}{Nr.}%
    \fi
    \def\@test{ngerman}%
    \ifx\languagename\@test
      \newcommand{\slidename}{transparent}%
      \providecommand{\no}{Nr.}%
    \fi
    \def\@test{naustrian}%
    \ifx\languagename\@test
      \newcommand{\slidename}{transparent}%
      \providecommand{\no}{Nr.}%
    \fi
  }{}
  \providecommand{\slidename}{slide}%
  \providecommand{\no}{\#}%
}
%</class>
%    \end{macrocode}
%
% \subsection{Support for HA-\protect\prosper}
% If we detect HA-\prosper, we need to redefine all the macros added by this
% patch. All this stuff goes into the \texttt{HAP-ppr-prv.def} file, which is
% loaded at the end of HA-\prosper if it detects \pprprv.
%    \begin{macrocode}
%<*HAPdef>
%% Support for the HA-prosper package: redefinition of the
%% functionnalities added by this patch.
\@ifpackageloaded{HA-prosper}{%
  \global\@HAprospertrue
%     \def\HAP@ReqVersion{v3.9}
%     \ifx\HAP@Version\undefined\else%
%       \ifx\HAP@ReqVersion\HAP@Version\else%
%         \ClassError{ppr-prv}{HA-prosper \HAP@Version\space and
%            ppr-prv \PPRPRV@Version\space are incompatible}%
%           {Read the documentation of HA-prosper.}%
%       \fi%
%     \fi

  \renewenvironment{itemstep}[1][]{\old@itemize}{\old@enditemize}%
  \renewenvironment{enumstep}[1][]{\old@enumerate}{\old@endenumerate}%

  \define@key{PRV@keys@slide}{toc}{\def\@tockey{#1}}
  \define@key{PRV@keys@slide}{bm}{}
  \define@key{PRV@keys@slide}{trans}{}
  \define@key{PRV@keys@slide}{sound}{}
  \define@key{PRV@keys@slide}{template}{}
  \def\xitem{\@ifnextchar<{\PRV@xitem}{\PRV@xitem<>}}
  \def\PRV@xitem<#1>{\item}
  \def\email#1{#1}
  \def\institution#1{#1}

  \renewcommand{\NewSlideStyle}[4][]{}
%</HAPdef>
%    \end{macrocode}
%
% \DescribeEnv{slide}
% We first redefine the |slide| environment to first handle the optional keys
% for defining toc entries. But it is roughly |prv@slide|... The |wideslide|
% environment is set to |slide|.
% 
% There is also some stuff here in case HA-prosper is loaded: since this package
% change |itemize|-like environments |AtBeginDocument|, we need to redefine it
% after... and after |AtBeginDocument| means just before printing the slides. We
% do this only in the first slide by testing the value of |\itemize|.
% 
%    \begin{macrocode}
%<*HAPdef>
  \renewenvironment{slide}[2][]{%
    \refstepcounter{slidei}\stepcounter{slideii}%
    \setcounter{trueSlideCounter}{\theslidei}%
    \let\@tockey\@undefined
    \setkeys{PRV@keys@slide}{#1}%
    \def\@tempa{#2}%
    \ifx\@tempa\@empty
      \ifx\@tockey\@undefined\else
        \ifx\@tockey\@empty\else
          \HAP@contentsline{0}{\@tockey}{\theslidei}{}%
        \fi
      \fi
    \else
      \ifx\@tockey\@undefined
        \HAP@contentsline{0}{#2}{\theslidei}{}%
      \else
        \ifx\@tockey\@empty\else
          \HAP@contentsline{0}{\@tockey}{\theslidei}{}%
        \fi
      \fi
    \fi
    \ifx\itemize\old@itemize\else
      \global\let\itemize\old@itemize
      \global\let\enditemize\old@enditemize
      \global\let\enumerate\old@enumerate
      \global\let\endenumerate\old@endenumerate
    \fi
    \begin{prv@slide}{#2}%
  }
  {%
    \end{prv@slide}%
  }

  \renewenvironment{wideslide}[2][]{\begin{slide}[#1]{#2}}{\end{slide}}
%</HAPdef>
%    \end{macrocode}
%
% \DescribeEnv{dualslide}
% The |dualslide| environment is a bit more complicated to redefine, just
% because we want to get rid of |pstricks|. So we do everything with \LaTeX{}
% boxes and some spaces adjustments.
%    \begin{macrocode}
%<*HAPdef>
  \newsavebox{\@slide@left}%
  \newsavebox{\@slide@right}%
  \newlength{\ht@slide}%

  \def\dualslide{\@ifnextchar[\@dualslide{\@@@dualslide[][][]}}%
  \def\@dualslide[#1]{%
    \@ifnextchar[{\@@dualslide[#1]}{\@@@dualslide[#1][#1][#1]}}%
  \def\@@dualslide[#1][#2]{%
    \@ifnextchar[{\@@@dualslide[#1][#2]}{\@@@dualslide[#1][#2][#1]}}%
  \long\def\@@@dualslide[#1][#2][#3]#4#5#6{%
    \setlength{\HAP@colsep}{.04\linewidth}%
    \setlength{\HAP@lcolwidth}{.47\linewidth}%
    \setlength{\HAP@rcolwidth}{.47\linewidth}%
    \setlength{\HAP@topsep}{0cm}%
    \setlength{\HAP@bottomsep}{.3cm}%
    \setlength{\HAP@indent}{0cm}%
    \setkeys{HAP@keys@dual}{#4}%

    \sbox{\@slide@left}{\begin{minipage}[t]{\HAP@lcolwidth}#5\end{minipage}}%
    \sbox{\@slide@right}{\begin{minipage}[t]{\HAP@rcolwidth}#6\end{minipage}}%

    \setlength{\ht@slide}{\the\ht\@slide@left}%
    \addtolength{\ht@slide}{-0.5\baselineskip}%
    \addtolength{\ht@slide}{\HAP@topsep}%
    \leavevmode\null\kern\the\HAP@indent
    \raisebox{-\ht@slide}{\usebox{\@slide@left}}%
    \kern\the\HAP@colsep
    \setlength{\ht@slide}{\the\ht\@slide@right}%
    \addtolength{\ht@slide}{-0.5\baselineskip}%
    \addtolength{\ht@slide}{\HAP@topsep}%
    \raisebox{-\ht@slide}{\usebox{\@slide@right}}%
    \par\vspace*{\HAP@bottomsep}%
  }
%</HAPdef>
%    \end{macrocode}
%
% We ignore again overlays...
%    \begin{macrocode}
%<*HAPdef>
  \renewcommand{\overlays}[2]{#2} % We ignore overlays (again...)
%</HAPdef>
%    \end{macrocode}
%
% \DescribeMacro{maketitle}
% The redefinition of |\maketitle| is exactly the same as the previous one,
% except that we add the support for the optional toc entry definition.
%    \begin{macrocode}
%<*HAPdef>
  \renewcommand{\maketitle}[1][]{%
    \refstepcounter{slidei}%
    \setcounter{trueSlideCounter}{\theslidei}%
    \let\@tockey\@undefined
    \setkeys{PRV@keys@slide}{#1}%
    \ifx\@tockey\@undefined
    \else
      \ifx\@tockey\@empty\else
        \HAP@contentsline{0}{\@tockey}{\theslidei}{}%
      \fi
    \fi
    \thispagestyle{empty}\setcounter{page}{0}%
    \mbox{}\vfill
    \begin{center}%
      {\LARGE \@title \par}%
      \ifx\@Subtitle\@empty\else\vskip 2em{\large\@Subtitle\par}\fi
      \vskip 6em%
      {\large\begin{tabular}[t]{c}\@author\end{tabular}\par}%
    \end{center}%
    \vfill\HAP@toc
    \vfill\mbox{}\clearpage
    \global\@needsnewpagefalse
  }
%</HAPdef>
%    \end{macrocode}
%
% \DescribeMacro{pcontentsline}
% Here is defined the |\pcontentsline| macro for defining the toc layout printed
% on the first page.
%    \begin{macrocode}
%<*HAPdef>
  \renewcommand{\fontToc}{}
  \newlength{\PRV@indenttoc}
  \setlength{\PRV@indenttoc}{0pt}
  \renewcommand{\pcontentsline}[5]{%
    \if1#1%
      \setlength{\PRV@indenttoc}{0pt}%
    \fi
    \hspace*{\PRV@indenttoc}#2%
    \if1#5\else\leaders\hbox{\hss.\ \hss}\hfill\slidename~\no#3\fi\\
    \if1#1%
      \setlength{\PRV@indenttoc}{10pt}%
    \fi
  }%
%</HAPdef>
%    \end{macrocode}
%
% All the sectioning commands of HA-\prosper are redefined here. We only handle
% the toc entry, so it is much less complicated than in HA-\prosper!
%    \begin{macrocode}
%<*HAPdef>
  % Redefinition of tsection command to remove what is not needed
  \newcounter{MG@tempTrueSlideCounter}
  \renewcommand{\tsection}{%
    \@ifstar
      {\@ifnextchar[{\@tsection{0}{2}}{\@tsection{0}{2}[]}}%
      {\@ifnextchar[{\@tsection{0}{1}}{\@tsection{0}{1}[]}}%
  }%
  \def\@tsection#1#2[#3]#4{%
    \setcounter{MG@tempTrueSlideCounter}{\thetrueSlideCounter}%
    \stepcounter{MG@tempTrueSlideCounter}%
    \HAP@contentsline{1}{#4}{\theMG@tempTrueSlideCounter}{1}%
  }%

  % Redefinition of the part command to deal with the toc key
  \renewcommand{\part}[2][]{%
    \if@needsnewpage
      \if@nopagebreak\else\ifodd\theslideii\else\mbox{}\clearpage\fi\fi
      \global\@needsnewpagefalse
    \fi
    \refstepcounter{slidei}%
    \setcounter{trueSlideCounter}{\theslidei}%
    \let\@tockey\@undefined
    \setkeys{PRV@keys@slide}{#1}%
    \ifx\@tockey\@undefined
      \HAP@contentsline{0}{#2}{\theslidei}{}%
    \else
      \ifx\@tockey\@empty\else
        \HAP@contentsline{0}{\@tockey}{\theslidei}{}%
      \fi
    \fi
    \old@section*{#2}%
  }%
  \renewcommand{\tsectionandpart}{\@ifstar{\tsectionandpart@E}{\tsectionandpart@NE}}
  \newcommand{\tsectionandpart@E}[2][]{%
    \let\@tockey\@undefined
    \setkeys{PRV@keys@slide}{#1}%
    \ifcase
      \ifx\@tockey\@undefined\@ne\fi
      \ifx\@tockey\@empty\@ne\fi
      \z@
      \tsection*{\@tockey}%
    \else
      \tsection*{#2}%
    \fi
    \part[toc={}]{#2}%
  }
  \newcommand{\tsectionandpart@NE}[2][]{%
    \let\@tockey\@undefined
    \setkeys{PRV@keys@slide}{#1}%
    \ifcase
      \ifx\@tockey\@undefined\@ne\fi
      \ifx\@tockey\@empty\@ne\fi
      \z@
      \tsection{\@tockey}%
    \else
      \tsection{#2}%
    \fi
    \part[toc={}]{#2}%
  }
%</HAPdef>
%    \end{macrocode}
%
% Since HA-\prosper enhances the footer (left and right), we try to take
% advantages of this.
%    \begin{macrocode}
%<*HAPdef>
  \let\l@foot\@empty
  \let\r@foot\@empty
  \@ifundefined{HAP@leftfoot}{}{\gdef\l@foot{\HAP@leftfoot}}
  \@ifundefined{HAP@rightfoot}{}{\gdef\r@foot{\HAP@rightfoot}}
  \gdef\@cartouche{\l@foot\hfill\r@foot}
  \renewcommand{\LeftFoot}[1]{%
    \gdef\l@foot{#1}%
    \gdef\@cartouche{\l@foot\hfill\r@foot}%
  }%
  \renewcommand{\RightFoot}[1]{%
    \gdef\r@foot{#1}%
    \gdef\@cartouche{\l@foot\hfill\r@foot}%
  }%
%</HAPdef>
%    \end{macrocode}
%
% \DescribeEnv{notes}
% Again, HA-\prosper adds a |notes| environment. We print it just between the
% slides, in a |quote| environment.
%    \begin{macrocode}
%<*HAPdef>
  \ifHAP@slidesonly\else
    \renewenvironment{notes}[1]{%
      \old@subsection*{#1}\bgroup\quote\footnotesize\sffamily
    }{%
      \endquote\egroup
      \ifHAP@notesonly\else
        \par
        \if@nopagebreak
          \bigskip
        \else
          \vfill
          \ifodd\theslideii\else\mbox{}\clearpage\fi
        \fi
      \fi
      \global\@needsnewpagefalse
    }%
  \fi
%</HAPdef>
%    \end{macrocode}
%
% \DescribeMacro{OnSlide}\DescribeMacro{onSlide}
% HA-\prosper adds also two extra macros for overlays: |\onSlide| and
% |\OnSlide|. To handle it is relatively simple since we only have to
% ``flatten'' overlays (see |\onlySlide| definition above).
%    \begin{macrocode}
%<*HAPdef>
  \def\OnSlide#1{\relax}
  \long\def\onSlide@NE#1#2{#2}
  \long\def\onSlide@E#1#2{%
    \sbox\PRV@tempbox{\begin{minipage}{\linewidth}#2\end{minipage}}%
    \setlength{\@size@tmp}{\the\ht\PRV@tempbox}%
    \addtolength{\@size@tmp}{\the\dp\PRV@tempbox}%
    \ifdim\@size@tmp>\@size@overlay\global\@size@overlay\@size@tmp\fi
    \vbox to 0pt\bgroup\usebox{\PRV@tempbox}\egroup
    \vskip -\baselineskip\ignorespaces
  }
  \def\onSlide{\@ifstar\onSlide@E\onSlide@NE}
}%
{%
  \global\@HAprosperfalse%
}
%</HAPdef>
%    \end{macrocode}
%
% \setcounter{IndexColumns}{2}
% \Finale
%
\endinput