% ^^A -----------------------------
% \iffalse
% File: fltpage.dtx
%
%  Copyright (C) [1998] by Sebastian Gross.  All rights reserved.
% \fi
% ^^A -----------------------------
%
% \iffalse
% IMPORTANT NOTICE:
%
% This is a tool or better yet, an experiments written by Sebastian Gross
% (seppel@zedat.fu-berlin.de), who is writing this not only for it utility
% value, but as part of the process of learning LaTeX.  This utility is far
% from perfect, and comments are welcome.
%
% The usual disclaimers apply:  If it doesn't work right that's your problem!
%
% The usual GNU-style conditions apply: If you change it, you take
% the blame; if you pass it on, pass on all present conditions;
%
% For error reports in case of UNCHANGED versions see fltpage.ins
% \fi
%
% ^^A -----------------------------
% \CheckSum{309}
%%
%% \iffalse meta-comment
%% ===================================================================
%%  @LaTeX-package-file{
%%     author     = {Sebastian Gross},
%%     version    = {0.3},
%%     date       = {13 Nov 1998},
%%     filename   = {fltpage.dtx},
%%     email      = {seppel@zedat.fu-berlin.de},
%%     codetable  = {ISO/ASCII},
%%     keywords   = {LaTeX2e, float, table, figure, caption, FPfigure, FPtable},
%%     supported  = {yes},
%%     docstring  = {LaTeX package which defines new environments to place
%%                   captions of tables and figures on the facing/following page.}
%%  }
%% ===================================================================
%% \fi
%
% ^^A -----------------------------
%
%  \def\fileversion{0.3}
%  \def\filedate{1998/10/29}
%  \newcommand{\docdate}{1998/11/13}
%  \newcommand{\fp}{\textsf{fltpage}}
%
%  \newenvironment{options}[1]%
%  {\begin{list}{}{\renewcommand{\makelabel}[1]{\texttt{##1}\hfil}%
%     \settowidth{\labelwidth}{\texttt{#1\space}}%
%     \setlength{\leftmargin}{\labelwidth}%
%     \addtolength{\leftmargin}{\labelsep}%
%     \setlength{\topsep}{0pt}%
%     \setlength{\itemsep}{0pt}%
%     \setlength{\parsep}{0pt}%
%     \setlength{\partopsep}{0pt}}}%
%  {\end{list}\vspace{4pt}}
%  \setlength{\parskip}{4pt plus2pt minus1pt}
%  \setlength{\parindent}{0pt}
%  \newcommand*{\pkg}[1]{\textsf{#1}}
%  \newcommand*{\cls}[1]{\textsf{#1}}
%
% ^^A -----------------------------
%
%  \changes{v0.3}{1998/10/29}{Added option noHints}
%  \changes{v0.2}{1998/10/28}{Resolved the problem of accessible Variables}
%  \changes{v0.1}{1998/10/07}{First private version}
%
%
% \title{Welcome to the beta test of \fp\thanks{Sorry for the crippled name
%        \fp! I just did not have a better and compelling idea.}\ ~package!}
%  \author{Sebastian Gross\thanks{e-mail: \texttt{seppel@zedat.fu-berlin.de}.}}
%  \date{beta \fileversion\ -- \docdate}
%  \maketitle
%
% ^^A -----------------------------
%
%  \begin{abstract}
%    This package defines the new environments |FPfigure| and |FPtable|,
%    analogous to |figure| and |table|.  In |twoside| mode the caption will
%    be set on the opposite page of a figure/table which needs a whole page.
%    In |oneside| mode the caption will be set on the preceding or following
%    page.
%  \end{abstract}
%
%  \pagestyle{headings}
%
% ^^A -----------------------------
%
%  \section{Introduction}
%
%  In some cases, there is just enough space to place a figure or table on a page,
%  unfortunately there is no space left for the caption below or above.
%  Moreover, it is might be impossible to decrease the size (for example, due to a
%  fixed scale of a map) or the use of \pkg{longtable} is inappropriate.
%  In these (rare) cases it seems acceptable to place the caption on the opposite
%  page in |twoside| mode or on the preceding/following page in |oneside| mode.
%  For this purpose the package \fp\ provides the new environments |FPfigure|
%  and |FPtable| in the sense of `generic markup'.  The basic idea is to use
%  two floats, which follow directly and contain the figure/table and the caption
%  respectively.  For correct positioning on odd or even pages in |twoside| mode
%  at least two compilation runs are required.
%
% ^^A -----------------------------
%
%  \section{Usage}
%
%  \changes{v0.1}{1998/10/07}{First options introduced}
%
%  To use this package just type in the preamble of your document\\
%  \hspace*{1cm} |\usepackage[|\meta{option}|]{fltpage}|.
%
%  The order of caption and figure/table are controlled one of the following options:
%  \begin{options}{closeFloats}
%   \item[closeFloats]
%    the float using the whole page is placed on the next page.
%    When the current page is even the caption is placed on the bottom,
%    when it is odd the caption is placed at the bottom of the page after the
%    float.  In any case the caption appears on opposite page in |twoside|
%    mode of document or the page before in |oneside| mode.
%   \item[rightFloats, CaptionBefore]
%    the big float appears always on the right page and the caption afterwards.
%   \item[leftFloats, CaptionAfterwards]
%    the big float appears always on the left page and the caption afterwards.
%  \end{options}
%
%  To distinguish the `isolated' caption from the text a separator line:
%  \begin{options}{closeFloats}
%   \item[noSeparatorLine]
%     With this option the the separator will be suppressed
%  \end{options}
%
%  To clarify the connection of caption to the float on an other page it might
%  be helpful to give a hint like `Fig. N (on the facing page):'.  The following
%  options control, how this is implemented:
%  \begin{options}{closeFloats}
%   \item[german]
%    So far only German is implemented as other language.
%   \item[varioref]
%    Reference texts are already implemented for many languages in the standard
%    package |varioref|, which implements slightly different expressions, too.
%    With this option these texts will be used.
%  \changes{v0.3}{1998/10/29}{new option}
%   \item[noHints]
%    When this option is used, any hint from the float caption to the float is
%    disabled.
%  \end{options}
%
%  Moreover the following global options (probably declared with the document
%  class) will be evaluated:
%  \begin{options}{closeFloats}
%   \item[draft]
%    causes placing of margin notes, where in the running text the one of the
%    new environments is inserted.
%   \item[oneside, twoside]
%    just to decide mode of document\dots
%  \end{options}
%
% \begin{macro}{FPfigure}
% \begin{macro}{FPtable}
%  In your Document you simply use the new environments instead of the standard
%  environments |table| or |figure| with the usual |\begin{}| and |\end{}| commands:\\
%  \hspace*{1cm}  |\begin{FPtable} ... \end{FPtable}|
%  \\
%  \hspace*{1cm}  |\begin{FPfigure} ... \end{FPfigure}|
% \end{macro}
% \end{macro}
%  Be sure that there are not more than one or two `small' pending floats, otherwise
%  the results will become unpredictable.  Moreover you should not use more than one
%  of the new environment on a page.  The contents of the second will probably
%  overwrite the contents of the first!
%
%  \paragraph{Example}
%  \changes{v0.3}{1998/11/06}{Example inserted}
%  The following example will produce a caption below and an almost empty facing
%  page:\\
%  \begin{FPfigure}
%   \caption{A caption alone on a page will belong to the
%            following figure without a caption!}
%   \fbox{\rule[-10cm]{0pt}{\textheight}Frame symbolizing figure on a whole page.\hspace{5cm}}
%  \end{FPfigure}
%  \hspace*{08mm} |\usepackage[rightFloats]{fltpage}|\\
%  \hspace*{10mm} |...|\\
%  \hspace*{10mm} |\begin{FPfigure}|\\
%  \hspace*{12mm} |\caption{A caption alone ... figure without a caption!}|\\
%  \hspace*{12mm} |\fbox{\rule[-10cm]{0pt}{\textheight}Frame ... page.\hspace{5cm}}|\\
%  \hspace*{10mm} |\end{FPfigure}|
%
% ^^A -----------------------------
%
%  \subsection{Requirements}
%
%  The present version of \fp\ (v.\fileversion) has been developed
%  and tested with \LaTeXe{} of 1998/06/01 using em\TeX~4b running \TeX~3.14159
%  under Windows~3.1, using the \cls{article} document class.
%  It requires
%  the standard \LaTeX\ package \pkg{ifthen} vers.\,1.0n of 1997/11/02
%  and \pkg{tools} package \pkg{afterpage} vers.\,1.08 of 1995/10/27.
%  Maybe it will work with older versions, maybe not\dots
%
%  With the option |varioref| the \pkg{tools} package \pkg{varioref} is
%  needed, as well.
%
% ^^A -----------------------------
%
%  \subsection{Compatibility}
%
%  This package was developed and tested with following versions of the
%  other packages:
%  \begin{center} \begin{tabular}{lll}
%   package           & version & date \\\hline
%   \pkg{sidecap}  & 1.00    & 1997/05/08 \\
%   \pkg{caption}  & 1.4b    & 1995/04/05 \\
%   \pkg{booktabs} & 1.00    & 1995/11/06 \\
%  \end{tabular} \end{center}
%  Again it may work with older versions or not\dots
%
% ^^A -----------------------------
%
%  \section{Known problems and limitations}
%
%  This package is rather a quick and dirty solution to a problem than a
%  sophisticated mechanism for placing captions and floats.  It should be
%  regarded as an experiment, rather than a utility.  It was written by
%  Sebastian Gross not only for it utility value, but as part of the process
%  of learning LaTeX.   Therefore it is far from being perfect, and comments
%  are welcome.   Your remarks and ideas are welcome to improve the concept
%  and implementation in future releases.
%
%  Probably most problems will arose from pending floats, which should be
%  cleared with |\clearpage|.  So far, no attempt is done!
%
%  When unpredicted suites of caption and floats result, you must \emph{first}
%  assure two compilations of your document.
%  An unresolved problem happens for example when the current page is even and
%  the caption should be placed on the bottom of the page, but there is not
%  enough space for it.  It will be moved to the next page (odd) and the long
%  float will be on next even page, which means caption and float are
%  separated!  To inquire this problem the option |draft| is provided, which
%  causes the a margin note, where the FPfloat was inserted in the text.
%
%  The simple design employed does not allow any floats on the odd text page
%  following the big float before the caption is resolved.
%
%  Also there is no solution implemented, when two of the new environments
%  occur within a short interval.  This is especially dangerous when they
%  are called on one page:  The contents of the second will overwrite the
%  contents of the first!
%
%  In some cases the capacity of \TeX\ might be exceeded (main memory).
%  This happens for example, when the table itself is too big.  It is
%  assumed that tables included by files up to approximately 30\,KB will
%  fill one page, even with |\tiny|.   Though, bigger tables may be included
%  with the standard |table| environment\dots
%
%  This package does not work correctly with the \pkg{showkeys} package.
%  Apparently the behaviour of the |\isodd{}| command of the standard
%  \pkg{ifthen} package is disabled.
%
% ^^A -----------------------------
%
%  \section{Acknowlegments}
%
%  This package was partly based on the contributions to |de.comp.text.tex|,
%  particulary of Hans Steffani, Heiko Oberdiek, Martin Schr\"oder, Stefan Ulrich.
%  I have to admit, the exploitation of  Rolf Niepraschk's \pkg{sidecap}
%  package, especially how to write a documented style file.
%
% ^^A -----------------------------
%
%  \section{The documentation driver file}
%
%  The next bit of code contains the documentation driver file for \TeX\, i.\,e.,
%  the file that will produce the documentation you are currently reading.
%  It will be extracted from this file by the \cls{docstrip} program.
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\setlength\hfuzz{5pt}    % ignore small overfull boxes
\GetFileInfo{fltpage.sty}
%\CodelineIndex
%\EnableCrossrefs    % Will prepare and index
%\DisableCrossrefs   % Say \DisableCrossrefs if index is ready
%\OnlyDescription    % comment out for implementation details
%\RecordChanges      % Gather update information
\usepackage[rightFloats]{fltpage}
\MakeShortVerb{\|}
\begin{document}
   \DocInput{fltpage.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
% ^^A -----------------------------
%
%  \StopEventually{}
%  \section{The implementation}
%
%  \subsection{File and Package Identification}
%
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fltpage}[1998/10/29 v.0.3 Floats on full page (SMU)]
%    \end{macrocode}
%
%  \subsection{Necessary files}
%
%    \begin{macrocode}
\RequirePackage{ifthen}
\RequirePackage{afterpage}
%    \end{macrocode}
%
%  \subsection{Some internal variables and macros}
%
% \begin{macro}{FP@figureC}
% \begin{macro}{FP@tableC}
%  Two counters to store the number of instantiations, used to create unique labels:
%    \begin{macrocode}
\newcounter{FP@figureC}
\newcounter{FP@tableC}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\FP@floatCorpusBOX}
%  To store the actual figure or table we will use a box:
%    \begin{macrocode}
\newsavebox{\FP@floatCorpusBOX}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FP@guide}
% \begin{macro}{\FP@guideStyle}
% \begin{macro}{\FP@guideOneside}
% \begin{macro}{\FP@guideTwoside}
% \begin{macro}{\FP@guideAfter}
% \begin{macro}{\FP@guideBefore}
% \begin{macro}{\FP@guideFaceBefore}
% \begin{macro}{\FP@guideFaceAfter}
%  To clarify the connection of caption to the float on other page it might be
%  helpful to give a hint with the macro |\FP@guide|.  The macro |\FP@guideStyle|
%  contains the appropriate style options. The |\FP@guideAfter|,
%  |\FP@guideFaceAfter|, and |\FP@guideFaceAfter| contain the the default text
%  strings:
%    \begin{macrocode}
\newcommand*{\FP@guide}{}%
\newcommand*{\FP@guideStyle}{\slshape}
\newcommand*{\FP@guideOneside}{following page}
\newcommand*{\FP@guideTwoside}{facing page}
\newcommand*{\FP@guideAfter}{following page}
\newcommand*{\FP@guideBefore}{preceding page}
\newcommand*{\FP@guideFaceBefore}{preceding page}
\newcommand*{\FP@guideFaceAfter}{following page}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\FP@separatorCaption}
%  To distinguish the caption on the separate page better from the text, we define
%  a separator:
%    \begin{macrocode}
\newcommand*{\FP@separatorCaption}{\rule{\linewidth}{.4pt}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FP@positionLabel}
%  To get information about the page we need some unique labels
%    \begin{macrocode}
\newcommand{\FP@positionLabel}{FP\@captype-\number\value{FP@\@captype C}-pos}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FP@helpNote}
%  For debugging the following messages are displayed helping to identify the
%  position of an |FPfigure| resp.\ |FPtable|.
%    \begin{macrocode}
\newcommand{\FP@helpNote}[2]{%
  \typeout{FP#1 is inserted on page \pageref{#2}!}}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FP@float}
% \begin{macro}{\FP@floatOneside}
% \begin{macro}{\FP@floatTwoside}
%  The Internal Macro |\FP@float| is the central output macro to perform the
%  sequence of caption and float.  Here it is preliminary defined as a dummy:
%    \begin{macrocode}
\newcommand{\FP@floatOneside}{}
\newcommand{\FP@floatTwoside}{}
\newcommand{\FP@float}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Declaration of options}
%
% \begin{macro}{german}
%  In other languages the text strings pointing to the page of the float must be
%  declared in other languages.  So far only German is implemented.
%  When option |varioref| is later used, we must pass this option to
%  \pkg{varioref}:
%    \begin{macrocode}
\DeclareOption{german}{%
  \renewcommand{\FP@guideAfter}{n\"achste Seite}
  \renewcommand{\FP@guideBefore}{vorhergehende Seite}
  \renewcommand{\FP@guideOneside}{\FP@guideAfter}
  \renewcommand{\FP@guideFaceBefore}{gegen\"uberliegende Seite}
  \renewcommand{\FP@guideFaceAfter}{gegen\"uberliegende Seite}
  \renewcommand{\FP@guideTwoside}{\FP@guideFaceAfter}
  \PassOptionsToPackage{german}{varioref}
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{varioref}
%  Reference texts are already implemented for many languages in the standard
%  package \pkg{varioref}, which implements slightly different expressions.
%  To ensure the inclusion of the package we use |\RequirePackage{}|, which can
%  only placed after |\ProcessOptions| below.  Therefore the code is delayed
%  by |\AtBeginDocument{}|.
%    \begin{macrocode}
\DeclareOption{varioref}{%
  \AtBeginDocument{%
    \RequirePackage{varioref}
    \ifthenelse{\equal{\reftextbefore}{\@empty}}%
      {}{\renewcommand{\FP@guideBefore}{\reftextbefore}}%
    \ifthenelse{\equal{\reftextafter}{\@empty}}%
      {}{\renewcommand{\FP@guideAfter}{\reftextafter}}%
    \renewcommand{\FP@guideOneside}{\FP@guideAfter}
    \ifthenelse{\equal{\reftextfacebefore}{\@empty}}%
      {}{\renewcommand{\FP@guideFaceBefore}{\reftextfacebefore}}%
    \ifthenelse{\equal{\reftextfaceafter}{\@empty}}%
      {}{\renewcommand{\FP@guideFaceAfter}{\reftextfaceafter}}%
    \renewcommand{\FP@guideTwoside}{\FP@guideFaceAfter}%
  }%
}%
%    \end{macrocode}
% \end{macro}
%
%   The Options are implemented via |\FP@float|, which will now have
%   three arguments:
%   The first is the label of the current page to determine if it is odd or even.
%   The second contains the float itself, i.e. the figure ore table.
%   The third contains all the commands, to initialize counters etc..
%   The fourth is the caption part.
% \begin{macro}{closeFloats}
%    \begin{macrocode}
\DeclareOption{closeFloats}{%
  \renewcommand{\FP@floatOneside}[3]{#3#2#1}%
  \renewcommand{\FP@floatTwoside}[4]{%
    \ifthenelse{\isodd{\pageref{#1}}}{#2#3#4}{#4#3#2}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{leftFloats}
%    \begin{macrocode}
\DeclareOption{leftFloats}{%
  \renewcommand{\FP@floatOneside}[3]{#1#2#3}%
  \renewcommand{\FP@floatTwoside}[4]{%
    \ifthenelse{\isodd{\pageref{#1}}}{{#2#3#4}}{\afterpage{#2#3#4}}}%
  \renewcommand{\FP@guideOneside}{\FP@guideBefore}%
  \renewcommand{\FP@guideTwoside}{\FP@guideFaceBefore}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{rightFloats}
%    \begin{macrocode}
\DeclareOption{rightFloats}{%
  \renewcommand{\FP@floatOneside}[3]{#3#2#1}%
  \renewcommand{\FP@floatTwoside}[4]{%
    \ifthenelse{\isodd{\pageref{#1}}}{\afterpage{#4#3#2}}{{#4#3#2}}}%
  \renewcommand{\FP@guideOneside}{\FP@guideAfter}%
  \renewcommand{\FP@guideTwoside}{\FP@guideFaceAfter}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{CaptionAfterwards}
% \begin{macro}{CaptionBefore}
% Some synonymous options
%    \begin{macrocode}
\DeclareOption{CaptionAfterwards}{\ExecuteOptions{leftFloats}}
\DeclareOption{CaptionBefore}{\ExecuteOptions{rightFloats}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{draft}
% With the following options, we process options packages etc:
%    \begin{macrocode}
\DeclareOption{draft}{%
  \renewcommand{\FP@helpNote}[2]{%
    \marginpar{Insertion of FP#1}%
    \typeout{FP#1 is inserted on page \pageref{#2}!}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{oneside}
%    \begin{macrocode}
\DeclareOption{oneside}{%
  \renewcommand{\FP@guide}{\FP@guideStyle(\FP@guideOneside)}%
  \renewcommand{\FP@float}[4]{\FP@floatOneside{#2}{#3}{#4}}
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{twoside}
%    \begin{macrocode}
\DeclareOption{twoside}{%
  \renewcommand{\FP@guide}{\FP@guideStyle(\FP@guideTwoside)}%
  \renewcommand{\FP@float}[4]{\FP@floatTwoside{#1}{#2}{#3}{#4}}
}%
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{noSeparatorLine}
%  He we implement some options to disable some of the functionality of the \fp\
%  package: First the implementation of a separator line in |\FP@separatorCaption|
%  is destroyed:
%    \begin{macrocode}
\DeclareOption{noSeparatorLine}{%
  \renewcommand{\FP@separatorCaption}{}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{noHints}
%  Secondly any hint in the caption towards the float is disabled.  We must
%  delay this, because the option |varioref| will be executed later, too.
%  We assume that the order of delayed code is the same as in the declaration.
%    \begin{macrocode}
\DeclareOption{noHints}{%
  \AtBeginDocument{\renewcommand{\FP@guide}{}}
}%
%    \end{macrocode}
% \end{macro}
%
%  Unknown options will result in a warning. Perhaps they mean anything to
%  \pkg{varioref}:
%    \begin{macrocode}
\DeclareOption*{%
  \PackageWarning{fltpage}{Unknown option `\CurrentOption'!}%
  \PassOptionsToPackage{\currentOption}{varioref}
}%
%    \end{macrocode}
%
% \subsection{Excecution of options}
%
%  Set the default behaviour:
%    \begin{macrocode}
\ExecuteOptions{closeFloats}
\ExecuteOptions{oneside}
%    \end{macrocode}
%
%  Don't forget to process the Options in the order of declaration:
%    \begin{macrocode}
\ProcessOptions*
\relax
%    \end{macrocode}
%
% \subsection{New environments}
%
% \subsubsection{Internal environment doing the magic}
%
% \begin{macro}{\FP@floatBegin}
%  The opening statement |\FP@float| has one argument which contains
%  the strings `figure' or `table'.
%    \begin{macrocode}
\newcommand{\FP@floatBegin}[1]{%
%    \end{macrocode}
%  First we save the type of float for further processing to |\@captype|:
%    \begin{macrocode}
  \gdef\@captype{#1}%
%    \end{macrocode}
%  The |caption|, |label| and |fnum@figure| resp. |fnum@table| commands must be saved
%  to be used later in the local group:
%    \begin{macrocode}
  \global\let\FP@savedCaptionCommand\caption%
  \global\let\FP@savedLabelCommand\label%
  \ifthenelse{\equal{\@captype}{figure}}
     {\global\let\old@Fnum\fnum@figure}%
     {\global\let\old@Fnum\fnum@table}%
%    \end{macrocode}
%  Initialize some text variables\dots
%    \begin{macrocode}
  \let\FP@LabelText\@empty%
  \let\FP@CaptionText\@empty%
  \let\FP@optionalCaptionText\@empty%
%    \end{macrocode}
%  Now we redefine the |label| and |caption| commands:
%    \begin{macrocode}
  \renewcommand\label[1]{\gdef\FP@LabelText{##1}}%
  \renewcommand\caption[2][]{\gdef\FP@optionalCaptionText{##1}\gdef\FP@CaptionText{##2}}%
%    \end{macrocode}
%
%  Finally we must start to record/save the contents of the float, i.e. figure or table etc.,
%  in a box.
%    \begin{macrocode}
  \begin{lrbox}{\FP@floatCorpusBOX}%
}%
%    \end{macrocode}
% \end{macro}
%
%
%  \begin{macro}{\FP@floatEnd}
%  The closing statement |\FP@floatEnd| terminates the collection of the float and
%  causes the output of it and the caption.  Since we use |\afterpage|, the local Box
%  |\FP@floatCorpusBOX| must assigned to the global |\FP@floatCorpusBOX|.
%    \begin{macrocode}
\newcommand{\FP@floatEnd}{%
  \end{lrbox}%
  \global\setbox\FP@floatCorpusBOX=\box\FP@floatCorpusBOX
%    \end{macrocode}
%  Creates a label for each figure or table for later determination if the page
%  is odd or even. The counters |FP@figureC| or |FP@tableC| must be
%  incremented before.
%    \begin{macrocode}
  \stepcounter{FP@\@captype C}%
  \FP@savedLabelCommand{\FP@positionLabel}%
%    \end{macrocode}
%  Here we give some hints to the user about the state of the environment\dots
%    \begin{macrocode}
  \FP@helpNote{\@captype}{\FP@positionLabel}%
%    \end{macrocode}
%  Now call the wanted sequence of caption and float according to the options above
%  with the |\FP@float| macro.  The first argument is the location label, which
%  will be used to determine the current page.
%    \begin{macrocode}
  \FP@float{\FP@positionLabel}% location label test
%    \end{macrocode}
%  The second argument contains the float itself:
%  First we open a float environment of type |\@captype| with option |[p]|.  The
%  float itself, i.e. figure or table, will be used the contents of the box
%  |\FP@floatCorpusBOX|.
%  Before placing the label, in order to get the actual page of the figure/table
%  referenced later, rather than the one with the caption, we must increment the
%  the counter of type |\@captype|.
%    \begin{macrocode}
          {\begin{\@captype}[p!]
             \usebox{\FP@floatCorpusBOX}%
             \refstepcounter{\@captype}%
             \ifthenelse{\equal{\FP@LabelText}{\@empty}}
                {}{\FP@savedLabelCommand{\expandafter\protect\FP@LabelText}}%
          \end{\@captype}}
%    \end{macrocode}
%  The third argument is used to reset something changed in the first object.
%  So far it is only the counter of type |\@captype|.
%    \begin{macrocode}
           {\addtocounter{\@captype}{-1}}
%    \end{macrocode}
%  The fourth argument contains the caption:
%  Again we open a float environment of type |\@captype| with option |[p]|.
%  To distinguish the caption from the text, it is separated with a horizontal line.
%  Space above and below are adjusted accordingly.
%  Than we will adjust |\fnum@figure|, when wanted.
%  Finally the caption is given with or without optional argument.
%    \begin{macrocode}
           {\begin{\@captype}[b!]%
             \ifthenelse{\equal{\FP@guide}{\@empty}}%
               {}{\ifthenelse{\equal{\@captype}{figure}}%
                   {\renewcommand{\fnum@figure}{\old@Fnum\ {\FP@guide}}}%
                   {\renewcommand{\fnum@table}{\old@Fnum\ {\FP@guide}}}}%
             \setlength{\abovecaptionskip}{2pt plus2pt minus 1pt} % length above caption
             \setlength{\belowcaptionskip}{2pt plus2pt minus 1pt} % length above caption
             \FP@separatorCaption%
             \ifthenelse{\equal{\FP@optionalCaptionText}{\@empty}}%
               {\FP@savedCaptionCommand{\expandafter\protect\FP@CaptionText}}%
               {\FP@savedCaptionCommand[\expandafter\protect\FP@optionalCaptionText]{\expandafter\protect\FP@CaptionText}}%
           \end{\@captype}}%
}%
%    \end{macrocode}
%  \end{macro}
%
%
%  \subsubsection{The user interface with the new two environments}
%
% \begin{macro}{FPfigure}
% \begin{macro}{FPtable}
%  Finally we implement the new environments, the user wants to use.
%  They redirect to |FP@floatBegin| with the string `figure' or `table' and to
%  |FP@floatEnd|.
%    \begin{macrocode}
\newenvironment{FPfigure}{\FP@floatBegin{figure}}{\FP@floatEnd}
\newenvironment{FPtable}{\FP@floatBegin{table}}{\FP@floatEnd}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% ^^A -----------------------------
%
\endinput
%% \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         \~}
%  \Finale
