% \iffalse meta-comment
%
% Copyright 1994 the LaTeX3 project and the individual authors.
% All rights reserved. For further copyright information see the file
% legal.txt, and any other copyright indicated in this file.
% 
% This file is part of the LaTeX2e system.
% ----------------------------------------
% 
%  This system is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 
% 
% IMPORTANT NOTICE:
% 
% For error reports in case of UNCHANGED versions see bugs.txt.
% 
% Please do not request updates from us directly.  Distribution is
% done through Mail-Servers and TeX organizations.
% 
% You are not allowed to change this file.
% 
% You are allowed to distribute this file under the condition that
% it is distributed together with all files mentioned in manifest.txt.
% 
% If you receive only some of these files from someone, complain!
% 
% You are NOT ALLOWED to distribute this file alone.  You are NOT
% ALLOWED to take money for the distribution or use of either this
% file or a changed version, except for a nominal charge for copying
% etc.
% \fi
%
% \iffalse
%%% File: ltfloat
%
%<*driver>
% \fi
\ProvidesFile{ltfloat.dtx}[1994/05/22 v1.0i LaTeX Kernel (Floats)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfloat.dtx}
\title{\filename}
\date{\filedate}
 \author{%
  Johannes Braams\and
  David Carlisle\and
  Alan Jeffrey\and
  Leslie Lamport\and
  Frank Mittelbach\and
  Chris Rowley\and
  Rainer Sch\"opf}

\begin{document}
\maketitle
 \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \CheckSum{600}
%
% \section{Floats}
%
%  The different types of floats are identified by a \meta{type} name,
%  which is the name of the counter for that kind of float.  For
%  example, figures are of type `figure' and tables are of type `table'.
%  Each \meta{type} has associated a positive \meta{type number}, which
%  is a power of two.  E.g.,\\
%  figures might be have type number~1, tables type number~2, programs
%  type number~4, etc.
%
%  The locations where a float can go are specified by a
%  \meta{placement specifier}, which is a list of the possible
%  locations, each denoted by a letter as follows:
%    \begin{center}
%    \begin{tabular}{l@{ : }l@{ --- }l}
%     h & here   & at the current location in the text.\\
%     t & top    & at the top of a text page.\\
%     b & bottom & at the bottom of a text page.\\
%     p & page   & on a separate float page
%    \end{tabular}
%    \end{center}
%  In addition, in conjunction with these, you can use `!' which means
%  that the current values of the float positioning parameters are
%  ignored for this float. (Has no effect on `p', float page
%  positioning.)
%  For example, `pht' specifies that the float can appear in any of
%  three locations: page, here or top.
%
% \StopEventually{}
%
%
% \changes{v1.0a}{1994/03/04}{Initial version, split from latex.dtx}
% \changes{v1.0b}{1994/03/28}{Split further from ltherest.dtx}
% \changes{v1.0e}{1994/04/25}{Changed warning messages}
% \changes{v1.0e}{1994/04/25}{Removed obsolete tracing code}
% \changes{v1.0f}{1994/05/03}
%     {(CAR) Added \cmd{\@largefloatcheck}}
% \changes{v1.0f}{1994/05/03}{Removed unnecessary braces from
% arguments of \cmd{\@ifnextchar}}
% \changes{v1.0i}{1994/05/22}{Use new warning commands}
%
% \subsection{Floating Environments}
%    \begin{macrocode}
%<*2ekernel>
\message{floats,}
%    \end{macrocode}
% \begin{oldcomments}
%
% Where floats may appear on a page, and how many may appear there
% are specified by the following float placement parameters.  The
% numbers are named like counters so the user can set them with
% the ordinary counter-setting commands.
%
%  \c@topnumber      : Number of floats allowed at the top of a column.
%  \topfraction      : Fraction of column that can be devoted to floats.
%  \c@dbltopnumber, \dbltopfraction 
%                    : Same as above, but for double-column floats.
%  \c@bottomnumber, \bottomfraction 
%                    : Same as above for bottom of page.
%  \c@totalnumber    : Number of floats allowed in a single column,
%                          including in-text floats.
%  \textfraction     :Minimum fraction of column that must contain text.
%  \floatpagefraction: Minimum fraction of page that must be taken
%                          up by float page.
%  \dblfloatpagefraction 
%                    : Same as above, for double-column floats.
%
% The document style must define the following.
%
%    \fps@TYPE   : The default placement specifier for floats of type
%                  TYPE. 
%
%    \ftype@TYPE : The type number for floats of type TYPE.
%
%    \ext@TYPE   : The file extension indicating the file on which the
%                  contents list for float type TYPE is stored.
%                    For example,  \ext@figure = 'lof'.
%
%    \fnum@TYPE  : A macro to generate the figure number for a caption.
%                  For example, \fnum@TYPE == Figure \thefigure.
%
%    \@makecaption{NUM}{TEXT} : 
%              A macro to make a caption, with NUM the value
%              produced by \fnum@... and TEXT the text of the caption.
%              It can assume it's in a \parbox of the appropriate width.
%
% \@float{TYPE}[PLACEMENT] : This macro begins a float environment for a
%     single-column float of type TYPE with PLACEMENT as the placement
%     specifier.  The default value of PLACEMENT is defined by
%     \fps@TYPE.  The environment is ended by \end@float.
%     E.g., \figure == \@float{figure}, \endfigure == \end@float.
%
%  \caption ==
%    BEGIN
%     \refstepcounter{\@captype}
%     \@dblarg{\@caption{\@captype}}
%    END
%
% In following definition, \par moved from after \addcontentsline to
% before \addcontentsline because the \write could cause
% an extra blank line to be added to the paragraph above the
% caption.  (Change made 12 Jun 87)
%
%  \@caption{TYPE}[STEXT]{TEXT} ==
%   BEGIN
%     \par
%     \addcontentsline{\ext@TYPE}{TYPE}{\numberline{\theTYPE}{STEXT}}
%     \begingroup
%       \@parboxrestore
%       \@normalsize
%       \@makecaption{\fnum@TYPE}{TEXT}
%       \par
%     \endgroup
%   END
%
%  \@float{TYPE}[PLACEMENT] ==
%   BEGIN
%     if hmode then \@bsphack
%                   \@floatpenalty := -10002
%              else \@floatpenalty := -10003
%     fi
%     \@captype ==L TYPE
%     if inner
%       then LaTeX Error: 'Not in outer paragraph mode.'
%            \@floatpenalty := 0
%       else if \@freelist nonempty
%              then \@currbox  :=L head of \@freelist
%                   \@freelist :=G tail of \@freelist
%                   \count\@currbox :=G 32*\ftype@TYPE + 16 +
%                                          bits determined by PLACEMENT
%              else \@floatpenalty := 0
%                   LaTeX Error: 'Too many unprocessed floats'
%            fi
%     fi
%     \@currbox :=G \vbox{%% 15 Dec 87 -- removed \boxmaxdepth :=L 0pt
%                         %% that made box zero depth because it screwed
%                         %% things up. Instead, added \vskip 0pt at end
%                     \hsize = \columnwidth
%                     \@parboxrestore
%   END
%
%  \end@float ==
%    BEGIN
%       \vskip 0pt %% makes 0 depth box -- added 15 Dec 87
%       }
%      if \@floatpenalty < 0
%        then add \@currbox to \@currlist
%             if \ht\@currbox > \textheight
%               then WARNING \ht\@currbox :=G \textheight fi
%             if \@floatpenalty < -10002
%               then \penalty -10004
%                    \vbox{}
%                    \penalty \@floatpenalty
%               else \vadjust{\penalty -10004
%                             \vbox{}
%                             \penalty \@floatpenalty}
%                    \@Esphack
%      fi    fi
%    END
%
%  \@dblfloat{TYPE}[PLACEMENT] : Macro to begin a float environment for
%     a double-column float of type TYPE with PLACEMENT as the placement
%     specifier.  The default value of PLACEMENT is 'tp'
%     The environment is ended by \end@dblfloat.
%     E.g., \figure* == \@dblfloat{figure}, 
%           \endfigure* == \end@dblfloat.
%
%  \@dblfloat{TYPE}[PLACEMENT] ==
%     Identical to \@float{TYPE}[PLACEMENT] except \hsize and \linewidth
%     are set to \textwidth.
%
%  \end@dblfloat ==
%     BEGIN    %%% { BRACE MATCHING
%       \vskip 0pt %% makes 0 depth box -- added 15 Dec 87
%       }
%       if \@floatpenalty < 0
%         if \ht\@currbox > \textheight
%           then WARNING \ht\@currbox :=G \textheight fi
%         then \@dbldeferlist :=G \@dbldeferlist * \@currbox
%       fi
%       if \@floatpenalty = -10002 then \@Esphack  fi
%     END
%
%    \begin{macrocode}
\newcount\@floatpenalty
%    \end{macrocode}
%
%    \begin{macrocode}
\def\caption{\refstepcounter\@captype \@dblarg{\@caption\@captype}}
%    \end{macrocode}
%
% \end{oldcomments}
%
% \begin{macro}{\@caption}
% \changes{v1.0b}{1994/03/28}{Use \cs{normalsize} not \cs{@normalsize}}
%    \begin{macrocode}
\long\def\@caption#1[#2]#3{\par\addcontentsline{\csname
  ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname}{\ignorespaces #2}}\begingroup
    \@parboxrestore
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}
%    \end{macrocode}
% \end{macro}
% \begin{oldcomments}
%
%    \begin{macrocode}
\def\@float#1{\@ifnextchar[{\@xfloat{#1}}{\edef\@tempa{\noexpand\@xfloat
    {#1}[\csname fps@#1\endcsname]}\@tempa}}
%    \end{macrocode}
%
% \end{oldcomments}
%
%  \begin{macro}{\@xfloat}
% \changes{LaTeX2e}{1993/12/05}{Command changed}
% \task{???}{change this change}
%    
% \begin{oldcomments}  
%  \@float{TYPE}[PLACEMENT] ==
%   BEGIN
%     \@captype ==L TYPE
%     \@fps     ==L PLACEMENT
%     add default PLACEMENT if at most ! in PLACEMENT == \@fpsadddefault
%     if hmode then \@bsphack
%                   \@floatpenalty := -10002
%              else \@floatpenalty := -10003
%     fi
%     if inner
%       then LaTeX Error: 'Not in outer paragraph mode.'
%            \@floatpenalty := 0
%       else if \@freelist nonempty
%              then \@currbox  :=L head of \@freelist
%                   \@freelist :=G tail of \@freelist
%                   \count\@currbox :=G 32*\ftype@TYPE + 
%                                          bits determined by PLACEMENT
%              else \@floatpenalty := 0
%                   LaTeX Error: 'Too many unprocessed floats'
%            fi
%     fi
%     \@currbox :=G \vbox{ %% 15 Dec 87 -- removed \boxmaxdepth :=L 0pt
%                          %% that made box 0 depth because it screwed
%                          %% things up. Instead, added \vskip0pt at end
%                     \hsize = \columnwidth
%                     \@parboxrestore
%   END
% \end{oldcomments}  
% 
% Setting everything up in |\endfloat|.
% \changes{LaTeX2e}{1994/01/21}{Added missing percent characters.}
%    \begin{macrocode}
\def\@xfloat#1[#2]{%
   \def \@captype {#1}%
   \def \@fps {#2}%
   \def \@tempb {!}%
   \ifx \@tempb \@fps
     \@fpsadddefault
   \else
     \ifx \@fps \@empty
       \@fpsadddefault
     \fi
   \fi
   \ifhmode
     \@bsphack
     \@floatpenalty -\@Mii
   \else
     \@floatpenalty-\@Miii
   \fi
   \ifinner
     \@parmoderr\@floatpenalty\z@
   \else
     \@next\@currbox\@freelist
       {\@tempcnta \sixt@@n
        \expandafter \@tfor \expandafter \@tempa
          \expandafter :\expandafter =\@fps\do
           {\if \@tempa h%
              \ifodd \@tempcnta
              \else
                \advance \@tempcnta \@ne
              \fi
            \fi
            \if \@tempa t%
              \@setfpsbit \tw@
            \fi
            \if \@tempa b%
              \@setfpsbit 4%
            \fi
            \if \@tempa p%
              \@setfpsbit 8%
            \fi
            \if \@tempa !%
              \ifnum \@tempcnta>15
                \advance\@tempcnta -\sixt@@n\relax
              \fi
            \fi
            }%
        \@tempcntb \csname ftype@\@captype \endcsname
        \multiply \@tempcntb \@xxxii
        \advance \@tempcnta \@tempcntb
        \global \count\@currbox \@tempcnta
        }%
     \@fltovf
   \fi
   \global\setbox\@currbox\vbox\bgroup
%    \end{macrocode}
% \changes{v1.0a}{1994/03/07}
%     {(DPC) Extra group for colour}
% \changes{v1.0c}{1994/03/14}
%     {(DPC) Use \cmd{\color@begingroup}}
% \changes{v1.0g}{1994/05/13}
%     {(DPC) Use \cmd{\normalcolor}}
%    \begin{macrocode}
   \color@begingroup
   \normalcolor
   \hsize\columnwidth \@parboxrestore
%    \end{macrocode}
%  Now we have to reset the |@nobreak| switch, so that the float
%  starts with a clean environment. |\outer@nobreak|will be executed
%  in |\@endfloat|, thereby restoring the old value of the switch.
% \changes{v1.0h}{1994/05/20}{Added code for resetting of
%                @nobreak switch.}
%    \begin{macrocode}
   \if@nobreak
     \def\outer@nobreak{\global\@nobreaktrue}\global\@nobreakfalse
   \fi
}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\end@float}
%    \begin{macrocode}
\def\end@float{\par\vskip\z@skip%% \par\vskip\z@ added 15 Dec 87
%    \end{macrocode}
% \changes{v1.0a}
%     {1994/03/07}{(DPC) Extra group for colour}
% \changes{v1.0c}{1994/03/14}
%     {(DPC) Use \cmd{\color@endgroup}}
% \changes{v1.0f}{1994/05/03}
%     {(CAR) Added \cmd{\@largefloatcheck}}
% \changes{v1.0h}{1994/05/20}{Restore outer value of @nobreak switch.}
%    \begin{macrocode}
   \color@endgroup
   \outer@nobreak
   \egroup
   \ifnum\@floatpenalty <\z@
     \@largefloatcheck
     \@cons\@currlist\@currbox
     \ifnum\@floatpenalty <-\@Mii
        \penalty -\@Miv
        \@tempdima\prevdepth    %% saving and restoring \prevdepth added
        \vbox{}%                %% 26 May 87 to prevent extra vertical
        \prevdepth \@tempdima   %% space when used in vertical mode
        \penalty\@floatpenalty
%    \end{macrocode}
% \changes{LaTeX2.09}{1992/03/18}
%         {(RmS) changed \cmd{\@esphack} to \cmd{\@Esphack}}
%    \begin{macrocode}
      \else
        \vadjust{\penalty -\@Miv \vbox{}\penalty\@floatpenalty}\@Esphack
     \fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\outer@nobreak}
% \changes{v1.0h}{1994/05/20}{Macro added: default is to do nothing.}
%    \begin{macrocode}
\let\outer@nobreak\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\end@dblfloat}
% \changes{v1.0f}{1994/05/03}{\cmd{\@largefloatcheck} added}
%    \begin{macrocode}
\def\end@dblfloat{\if@twocolumn
     \par\vskip\z@skip\egroup %% \par\vskip\z@ added 15 Dec 87\egroup
     \ifnum\@floatpenalty <\z@
%    \end{macrocode}
% We make sure that we never exceed |\textheight|, otherwise float
% will never get typeset (91/03/15 FMi).
%    \begin{macrocode}
       \@largefloatcheck
       \@cons\@dbldeferlist\@currbox
     \fi
%    \end{macrocode}
% RmS 92/03/18 changed |\@esphack| to |\@Esphack|.
%    \begin{macrocode}
      \ifnum \@floatpenalty =-\@Mii \@Esphack\fi\else\end@float\fi}
%    \end{macrocode}
% \end{macro}
%
%
%  \begin{macro}{\@largefloatcheck}
% \changes{v1.0e}{1994/04/25}{Command added}
% 
%    This calculates by how much a float is oversize for the page and
%    prints this in a warning message.
%    
%    \begin{macrocode}  
\def \@largefloatcheck{%
  \ifdim \ht\@currbox>\textheight
    \@tempdima -\textheight
    \advance \@tempdima \ht\@currbox
%    \end{macrocode}
% \changes{v1.0e}{1994/04/25}{Changed warning message to give more
% info}
%    \begin{macrocode}
    \@latex@warning {Float too large for page by \the\@tempdima}%
    \ht\@currbox \textheight
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
% \begin{oldcomments}
%
%    \begin{macrocode}
\def\@dblfloat{\if@twocolumn\let\@tempa\@dbflt\else\let\@tempa\@float\fi
  \@tempa}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@dbflt#1{\@ifnextchar[{\@xdblfloat{#1}}{\@xdblfloat{#1}[tp]}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@xdblfloat#1[#2]{%
  \@xfloat{#1}[#2]\hsize\textwidth\linewidth\textwidth}
%    \end{macrocode}
% \end{oldcomments}
%
% Moved to ltoutput 93/12/16
%    \begin{macrocode}
%\newcount\c@topnumber
%\newcount\c@dbltopnumber
%\newcount\c@bottomnumber
%\newcount\c@totalnumber
%    \end{macrocode}
%
% An analysis of |\@floatplacement|:
%
% This should be called whenever |\@colht| has been set.
%    \begin{macrocode}
\def\@floatplacement{\global\@topnum\c@topnumber
    % Textpage bit, global:
   \global\@toproom \topfraction\@colht
   \global\@botnum  \c@bottomnumber
   \global\@botroom \bottomfraction\@colht
   \global\@colnum  \c@totalnumber
    % Floatpage bit, local:
   \@fpmin   \floatpagefraction\@colht}
%    \end{macrocode}
%
%  \begin{macro}{\@dblfloatplacement}
% \changes{LaTeX2e}{1993/12/05}{Command changed}
% 
%     This should be called only within a group.  Now changed to
%     provide extra checks in |\@addtodblcol|, needed when processing a
%     BANG float.
%    
%    \begin{macrocode}  
\def \@dblfloatplacement {%
%    \end{macrocode}
%    Textpage bit: global, but need not be.
%    \begin{macrocode}  
  \global \@dbltopnum \c@dbltopnumber
  \global \@dbltoproom \dbltopfraction\@colht
%    \end{macrocode}
%   This new bit uses |\@textmin| to locally store the amount of extra
%   room in the column.   
%    \begin{macrocode}
  \@textmin \@colht
  \advance \@textmin -\@dbltoproom
%    \end{macrocode}
%    Floatpage bit: must be local.
%    \begin{macrocode}
  \@fpmin \dblfloatpagefraction\textheight
  \@fptop \@dblfptop
  \@fpsep \@dblfpsep
  \@fpbot \@dblfpbot
}
%    \end{macrocode}
%  \end{macro}
%
%
% \begin{oldcomments}
%   MARGINAL NOTES:
%
%   Marginal notes use the same mechanism as floats to communicate
%   with the \output routine.  Marginal notes are distinguished from
%   floats by having a negative placement specification.  The command
%   \marginpar [LTEXT]{RTEXT} generates a marginal note in a parbox,
%   using LTEXT if it's on the left and RTEXT if it's on the right.
%   (Default is RTEXT = LTEXT.)  It uses the following parameters.
%
%   \marginparwidth : Width of marginal notes.
%   \marginparsep   : Distance between marginal note and text.
%        the page layout to determine how to move the marginal
%        note into the margin.   E.g., \@leftmarginskip ==
%        \hskip -\marginparwidth \hskip -\marginparsep .
%   \marginparpush  :  Minimum vertical separation between \marginpar's
%
%  Marginal notes are normally put on the outside of the page
%  if @mparswitch = true, and on the right if @mparswitch = false.
%  The command \reversemarginpar reverses the side where they
%  are put.  \normalmarginpar undoes \reversemarginpar.
%  These commands have no effect for two-column output.
%
%  SURPRISE: if two marginal notes appear on the same line of
%  text, then the second one could appear on the next page, in
%  a funny position.
%
%
%  \marginpar [LTEXT]{RTEXT} ==
%   BEGIN
%     if hmode then \@bsphack
%                   \@floatpenalty := -10002
%              else \@floatpenalty := -10003
%     fi
%     if inner
%       then LaTeX Error: 'Not in outer paragraph mode.'
%            \@floatpenalty := 0
%       else if \@freelist has two elements:
%              then get \@marbox, \@currbox  from \@freelist
%                   \count\@marbox :=G -1
%              else \@floatpenalty := 0
%                   LaTeX Error: 'Too many unprocessed floats'
%                   \@currbox, \@marbox := \@tempboxa    %%use \def
%            fi
%     fi
%     if optional argument
%       then %% \@xmpar ==
%            \@savemarbox\@marbox{LTEXT}
%            \@savemarbox\@currbox{RTEXT}
%       else %% \@ympar ==
%            \@savemarbox\@marbox{RTEXT}
%            \box\@currbox :=G \box\@marbox
%    fi
%    %% \@xympar ==
%    if \@floatpenalty < 0 then add \@marbox to \@currlist fi
%    \setbox\@tempboxa =L    %% added 3 Jan 88 to correct bug introduced
%       { \end@float
%         @ignore := G F
%         \@esphack %%%% BRACE MATCHING} %% by 15 Dec 87 change
%   END
%
% \@savemarbox\BOX{TEXT} ==
%   BEGIN
%     \BOX  :=G \vtop{ \hsize = \marginparwidth
%                      \@parboxrestore
%                      TEXT
%                    }
%   END
%
% \reversemarginpar == BEGIN \@mparbottom   :=G 0
%                            @reversemargin :=G true
%                      END
%
% \normalmarginpar  == BEGIN \@mparbottom   :=G 0
%                            @reversemargin :=G false
%                      END
%
%    \begin{macrocode}
\def\marginpar{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
   \@floatpenalty-\@Miii\fi\ifinner
      \@parmoderr\@floatpenalty\z@
    \else\@next\@currbox\@freelist{}{}\@next\@marbox\@freelist{\global
      \count\@marbox\m@ne}{\@floatpenalty\z@ \@fltovf
         \def\@currbox{\@tempboxa}\def\@marbox{\@tempboxa}}\fi
     \@ifnextchar [\@xmpar\@ympar}
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\@xmpar[#1]#2{\@savemarbox\@marbox{#1}\@savemarbox\@currbox
   {#2}\@xympar}
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\@ympar#1{\@savemarbox\@marbox{#1}\global\setbox\@currbox
     \copy\@marbox\@xympar}
%    \end{macrocode}
%
% \end{oldcomments}
% \begin{macro}{\@savemarbox}
% \changes{v1.0b}{1994/03/12}
%     {(DPC) Extra group for colour}
% \changes{v1.0c}{1994/03/14}
%     {(DPC) Use \cmd{\color@begingroup}}
% \changes{v1.0d}{1994/04/18}
%     {(DPC) Remove Colour support}
%    \begin{macrocode}
\long\def\@savemarbox#1#2{%
  \global\setbox#1\vtop{%
    \hsize\marginparwidth
       \@parboxrestore #2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xympar}
%    \begin{macrocode}
\def\@xympar{\ifnum\@floatpenalty <\z@\@cons\@currlist\@marbox\fi
     \setbox\@tempboxa\vbox   %% added 3 Jan 88
%    \end{macrocode}
% \changes{LaTeX2.09}{1992/03/18}
%     {(RmS) added \cmd{\global}\cmd{\@ignorefalse}}
% \changes{v1.0b}{1994/03/12}
%     {(DPC) Extra bgroup for colour}
% \changes{1.0c}{1994/03/14}
%     {(DPC) Use \cmd{\color@begingroup}}
%    \begin{macrocode}
     \bgroup\color@begingroup
       \end@float\global\@ignorefalse\@esphack}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\def\reversemarginpar{\global\@mparbottom\z@ \@reversemargintrue}
\def\normalmarginpar{\global\@mparbottom\z@ \@reversemarginfalse}
%    \end{macrocode}
%
%    \begin{macrocode}
\message{footnotes,}
%    \end{macrocode}
%
% \subsection{Footnotes}
%
% \begin{oldcomments}
%
%   \footnote{NOTE}       : User command to insert a footnote.
%
%   \footnote[NUM]{NOTE}: User command to insert a footnote numbered
%                       NUM, where NUM is a number -- 1, 2,
%                       etc.  For example, if footnotes are numbered
%                       *, **, etc. within pages, then \footnote[2]{...}
%                       produces footnote '**'.  This command does not
%                       step the footnote counter.
%
%   \footnotemark[NUM] : Command to produce just the footnote mark in
%                        the text, but no footnote.  With no argument,
%                        it steps the footnote counter before generating
%                        the mark.
%
%   \footnotetext[NUM]{TEXT} : Command to produce the footnote but no
%                              mark.  \footnote is equivalent to
%                              \footnotemark \footnotetext .
%
%   As in PLAIN, footnotes use \insert\footins, and the following
%   parameters: 
%
%   \footnotesize   : Size-changing command for footnotes.
%
%   \footnotesep    : The height of a strut placed at the beginning of
%                     every footnote.
%   \skip\footins   : Space between main text and footnotes.  The rule
%                     separating footnotes from text occurs in this
%                     space. This space lies above the strut of height
%                     \footnotesep which is at the beginning of the
%                     first footnote.
%   \footnoterule   : Macro to draw the rule separating footnotes from
%                     text. It is executed right after a \vspace of
%                     \skip\footins. It should take zero vertical
%                     space--i.e., it should to a negative skip to
%                     compensate for any positive space it occupies.
%                     (See PLAIN.TEX.)
%
%   \interfootnotelinepenalty : Interline penalty for footnotes.
%
%   \thefootnote : In usual LaTeX style, produces the footnote number.
%                  If footnotes are to be numbered within pages, then
%                  the document style file must include an \@addtoreset
%                  command to cause the footnote counter to be reset
%                  when the page counter is stepped.  This is not a good
%                  idea, though, because the counter will not always be
%                  reset in time to ensure that the first footnote on a
%                  page is footnote number one.
%
%   \@thefnmark : Holds the current footnote's mark--e.g., \dag or '1'
%                 or 'a'. 
%
%   \@mpfnnumber     : A macro that generates the numbers for \footnote
%                      and \footnotemark commands. It == \thefootnote
%                      outside a minipage environment, but can be
%                      changed inside to generate numbers for
%                      \footnote's.
%
%   \@makefnmark : A macro to generate the footnote marker from
%                 \@thefnmark The default definition is
%                 \hbox{$^\@thefnmark$}.
%
%   \@makefntext{NOTE} :
%        Must produce the actual footnote, using \@thefnmark as the mark
%        of the footnote and NOTE as the text.  It is called when
%        effectively  inside a \parbox, with \hsize = \columnwidth.
%          For example, it might be as simple as
%               $^{\@thefnmark}$
%
% NOTE
% In a minipage environment, \footnote and \footnotetext are redefined
% so that
%    (a) they use the counter mpfootnote
%    (b) the footnotes they produce go at the bottom of the minipage.
% The switch is accomplished by letting \@mpfn == footnote or mpfootnote
% and \thempfn == \thefootnote or \thempfootnote, and by redefining
% \@footnotetext to be \@mpfootnotetext in the minipage.
%
% \footnote{NOTE}  ==
%  BEGIN
%    \stepcounter{\@mpfn}
%    begingroup
%       \protect == \noexpand
%       \@thefnmark :=G eval (\thempfn)
%    endgroup
%    \@footnotemark
%    \@footnotetext{NOTE}
%  END
%
% \footnote[NUM]{NOTE} ==
%  BEGIN
%    begingroup
%       \protect == \noexpand
%       counter \@mpfn :=L NUM
%       \@thefnmark :=G eval (\thempfn)
%    endgroup
%    \@footnotemark
%    \@footnotetext{NOTE}
%  END
%
% \@footnotetext{NOTE} ==
%  BEGIN
%    \insert into \footins
%       {\footnotesize
%        \interlinepenalty :=L \interfootnotelinepenalty
%        \splittopskip     :=L \footnotesep
%        \splitmaxdepth    :=L \dp\strutbox
%        \floatingpenalty  :=L 20000
%        \hsize :=L \columnwidth
%        \@parboxrestore
%        set \@currentlabel to make \label command work right
%        \@makefntext{\rule{0pt}{\footnotesep} NOTE}
%       }
%  END
%
% \footnotemark      ==
%  BEGIN \stepcounter{footnote}
%        begingroup
%           \protect == \noexpand
%           \@thefnmark :=G eval(\thefootnote)
%        endgroup
%        \@footnotemark
%  END
%
% \footnotemark[NUM] ==
%   BEGIN
%       begingroup
%         footnote counter :=L NUM
%         \protect == \noexpand
%        \@thefnmark :=G eval(\thefootnote)
%       endgroup
%       \@footnotemark
%   END
%
% \@footnotemark ==
%   BEGIN
%    \leavevmode
%    IF hmode THEN \@x@sf := \the\spacefactor FI
%    \@makefnmark          % put number in main text
%    IF hmode THEN \spacefactor := \@x@sf FI
%   END
%
% \footnotetext      ==
%    BEGIN begingroup \protect == \noexpand
%                     \@thefnmark :=G eval (\thempfn)
%          endgroup
%          \@footnotetext
%    END
%
% \footnotetext[NUM] ==
%    BEGIN begingroup  counter \@mpfn :=L NUM
%                      \protect == \noexpand
%                      \@thefnmark :=G eval (\thempfn)
%          endgroup
%          \@footnotetext
%    END
%
%    \begin{macrocode}
\@definecounter{footnote}
\def\thefootnote{\arabic{footnote}}
%    \end{macrocode}
%
%    \begin{macrocode}
\@definecounter{mpfootnote}
\def\thempfootnote{\alph{mpfootnote}}
%    \end{macrocode}
%
% Default definition
%    \begin{macrocode}
\def\@makefnmark{\hbox{$^{\@thefnmark}\m@th$}}
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\footnotesep
%    \end{macrocode}
%
% \end{oldcomments}
% \begin{macro}{\footnote}
% \changes{LaTeX2.09}{1991/11/01}
%         {(RmS) Added \cmd\let\cmd\protect\cmd\noexpand in
%          \cmd\footnote, \cmd\footnotemark,
%               and \cmd\footnotetext, since \cmd\xdef is used}
% \changes{LaTeX2.09}{1991/11/22}
%         {(RmS) Added \cmd\let\cmd\protect\cmd\noexpand in
%             \cmd{\@xfootnote}, \cmd{\@xfootnotemark},
%               and \cmd{\@xfootnotetext}}
% \changes{LaTeX2.09}{1992/11/26}
%         {(RmS) Changed all to 
%             `def`protect\string{`noexpand`protect`noexpand\string}}
%    \begin{macrocode}
\def\footnote{\@ifnextchar[\@xfootnote{\stepcounter{\@mpfn}%
     \begingroup%\let\protect\noexpand
         \def\protect{\noexpand\protect\noexpand}%
       \xdef\@thefnmark{\thempfn}\endgroup
     \@footnotemark\@footnotetext}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xfootnote}
%    \begin{macrocode}
\def\@xfootnote[#1]{\begingroup \csname c@\@mpfn\endcsname #1\relax
   \def\protect{\noexpand\protect\noexpand}%
   \xdef\@thefnmark{\thempfn}\endgroup
   \@footnotemark\@footnotetext}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@footnotetext}
% \changes{LaTeX2.09}{1991/09/29}
%     {(RmS) added \cmd{\reset@font}}
% \changes{LaTeX2.09}{1992/11/26}
%     {(RmS) added protection for \cmd\edef}
% \changes{v1.0a}{1994/03/07}
%     {(DPC) Extra group for colour}
% \changes{v1.0c}{1994/03/14}
%     {(DPC) Use \cmd{\color@begingroup, add \cmd{\endgraf}}}
% \changes{v1.0d}{1994/04/18}
%     {(DPC) Remove Colour support}
% \changes{v1.0g}{1994/05/13}
%     {(DPC) Add new style colour support: \cs{normalcolor}}
% \changes{v1.0g}{1994/05/13}
%     {(DPC) Use \cs{@finalstrut}}
%    \begin{macrocode}
\long\def\@footnotetext#1{\insert\footins{%
    \reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
    \let\@tempa\protect
    \def\protect{\noexpand\protect\noexpand}%
    \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
    \let\protect\@tempa
    \color@begingroup
      \normalcolor
      \@makefntext{%
        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}
    \color@endgroup}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\def\footnotemark{\@ifnextchar[\@xfootnotemark{\stepcounter{footnote}%
     \begingroup\def\protect{\noexpand\protect\noexpand}%
       \xdef\@thefnmark{\thefootnote}\endgroup
     \@footnotemark}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@xfootnotemark[#1]{\begingroup \c@footnote #1\relax
   \def\protect{\noexpand\protect\noexpand}%
   \xdef\@thefnmark{\thefootnote}\endgroup \@footnotemark}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@footnotemark{\leavevmode\ifhmode
  \edef\@x@sf{\the\spacefactor}\fi \@makefnmark
   \ifhmode\spacefactor\@x@sf\fi\relax}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\footnotetext{\@ifnextchar [\@xfootnotenext
   {\begingroup\def\protect{\noexpand\protect\noexpand}%
      \xdef\@thefnmark{\thempfn}\endgroup
    \@footnotetext}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@xfootnotenext[#1]{\begingroup \csname c@\@mpfn\endcsname #1\relax
   \def\protect{\noexpand\protect\noexpand}%
   \xdef\@thefnmark{\thempfn}\endgroup \@footnotetext}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@mpfn{footnote}
\def\thempfn{\thefootnote}
%</2ekernel>
%    \end{macrocode}
%
% \Finale
%
