% \iffalse
%%
%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley
%% All rights reserved.
%%
%% Not for general distribution. In its present form it is not allowed
%% to put this package onto CD or an archive without consulting the
%% the authors.
%% 
% \fi
%

%    \begin{macrocode}
\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${
  \ProvidesPackage{#2}[#4 #3 #5 #6]}
\@tempa$Id: xo-float.dtx,v 1.32 2000/08/11 07:14:11 latex3 Exp $
%    \end{macrocode}
%
% Ignore white space in this package.
%    \begin{macrocode}
\IgnoreWhiteSpace
%    \end{macrocode}
%
%
%
% \begin{macro}{\@xfloat}
% The start of a float environment.
% Unlike \LaTeXe, now save the float as a horizontal list.
%    \begin{macrocode}
\def\@xfloat #1[#2]{%
%<*trace>
\@tracepush{float~environment}
%</trace>
  \@nodocument
% #2 is either user suplied or \fps@#1 (from 2e again)
  \def \@fps {#2}
  \def \float@type {#1}
%    \end{macrocode}
%    Next line could be inline since it is used only once
%    now.\footnote{Change?}
%    \begin{macrocode}
  \expandafter \let \expandafter
      \float@sequence@class \csname sequence@class@#1 \endcsname
%    \end{macrocode}
%    
%    \begin{macrocode}
  \expandafter \let \expandafter
      \float@counter \csname counter@#1 \endcsname
%    \end{macrocode}
%    Floats (not caption) increment counter:
%    \begin{macrocode}
  \refstepcounter\float@counter
   \ifhmode
     \@bsphack
   \fi
  \ifinner
     \@parmoderr\@floatpenalty\z@
  \else
    \@allocating@next\@currbox\@freelist
      {
%
% not used any longer:
%
%       \global\expandafter\let\csname fps@\the\@currbox\endcsname
%                              \@fps
%       \global\expandafter\let\csname ftype@\the\@currbox\endcsname
%                              \@captype
%
      \global\advance\float@sequence@count\@ne
      \expandafter\PutMark\expandafter\float@sequence@class\expandafter{
            \the\float@sequence@count}
      \global\toks\@currbox{}
      }
  \fi
%    \end{macrocode}
%
%  Save |\@currbox| as an |\hbox|.
%    \begin{macrocode}
  \global\let\@saved@label\@empty
  \global \setbox\@currbox
%    \end{macrocode}
%    The float body is typeset in a normalised environment, i.e.., we
%    reset colour and font. This is followed by a call to
%    |\body@|\meta{type} to allow the designer to set up special
%    conventions for each float type, e.g., a special font or font
%    size or a special colour, etc.
%    \begin{macrocode}
      \hbox \bgroup\color@begingroup
       \normalcolor
       \normalfont
       \normalsize
       \csname body@\float@type \endcsname
       \ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@endfloatbox}
% The end of a float environment.
% First finish off the box assignment. Then make a copy in a second box.
% The current code makes use of the fact that the allocated boxes
% are in two continuous runs, |\sbx@offset| apart.
%    \begin{macrocode}
\def \@endfloatbox{%
  \unskip
      \outer@nobreak
  \color@endgroup
   \egroup
       \edef\@tempa{
       \global\toks\@currbox{
         {\the\toks\@currbox}{\SPANCNT}
         {\@saved@label}
         {\csname the\float@counter \endcsname}
         {\@fps}
         {\float@type}
         {\the\float@sequence@count}
       }}
      \@tempa
%<*trace>
\tr@ce{\the\toks\@currbox}
%</trace>
%    \end{macrocode}
%    Simple temporary interface to get here floats for testing. Needs
%    replacment!\footnote{FIX!!!}
%    \begin{macrocode}
   \def\@tempa{h}
   \ifx\@fps\@tempa
     \setup@here@float
   \else
     \@cons\@activelist\@currbox
   \fi
%<*trace>
\@tracepop{float~environment}
%</trace>
}

\def\SPANCNT{} %%% do properly one day: David


%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\float@sequence@count}
%    |\float@sequence@count|  is the counter used to uniquely  refer
%    to the floats, it is incremented whenever we encounter a new float.
%    \begin{macrocode}
\newcount\float@sequence@count
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\label}
%    Modify to save the label string.
%    \begin{macrocode}
\def\label#1{\@bsphack
  \gdef\@saved@label{#1}
  \protected@write\@auxout{}%
         {\string\newlabel{#1}{{\@currentlabel}{\thepage}}}%
  \@esphack}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
%
% \begin{macro}{\DeclareFloatType}
%    A float type is an identifier like ``figure'' the defines a class
%    (?) of floats of floats which have certain attributes in common,
%    e.g., they have the same fixed caption text (e.g. \texttt{Fig}),
%    they use the same counter to number the floats, etc.
%
%    Setting up a float type is done by declaring an instance of type
%    \texttt{floattypesetup} and then executing it.
%    \begin{macrocode}
\def\DeclareFloatType#1#2{
 \DeclareInstance{floattypesetup}{#1}{std}
   { type-id = #1,  #2 }
 \UseInstance{floattypesetup}{#1}
}
%    \end{macrocode}
%
%    For each float type \texttt{TYPE} the following utility macros
%    hold important static data.
%
% \DescribeMacro\sequence@class@TYPE
%    The |\sequence@class@TYPE| holds the name of the float sequence
%    class the float type |TYPE| belongs to. A sequence class contains
%    all types which should be placed in order of their call-outs,
%    e.g., if type ``figure'' and ``table'' are in the same sequence
%    class a table whose call-out is later than that of a figure will
%    not be placed before it. If on the other hand these types are in
%    different sequence classes such reordering will be undertaken by
%    the placement algorithm if feasible.
%
%
% \DescribeMacro\toc@extension@TYPE
%    The |\toc@extension@TYPE| holds the file extension to which
%    caption information for this type is written, e.g., |lot| for
%    tables, or |lof| for figures. If there is the desire to produce
%    combined listing one can use the same extension for different
%    float types.\footnote{This functionality can alternatively be
%    provided by putting all captions into a single external file and
%    then ignore certain entries when reading the data back, so it
%    might vanish again.}
%
%
% \DescribeMacro\fps@TYPE
%    The |\fps@TYPE| holds the default float areas in which this float
%    type is allowed to go. By default this is the full list of all
%    known areas. By restricting it to a subset of areas it is
%    possible to provide special placement arrangements, e.g., tables
%    always at the bottom only.
%
%
% \DescribeMacro\caption@TYPE
%    The |\caption@TYPE| holds the fixed caption text which is
%    displayed together with the caption number, e.g., |Figure|,
%    etc. This is passed to the caption formatting instances.
%
%
% \DescribeMacro\counter@TYPE
%    The |\counter@TYPE| holds the name of the counter to use for
%    numbering the floats of type |TYPE|. It is possible that
%    different types share the same counter, i.e., are numbered as a
%    single sequence. However in that case one should probably ensure
%    that the types belong to a single float sequence class since
%    otherwise the numbers within the document might get out of
%    sequence. On the other hand it is not required to have floats in
%    the same sequence class share a counter; they can be numbered
%    independently without problems.
%
% \DescribeMacro\body@TYPE
%    The |\body@TYPE| holds the formatting instructions that should be
%    applied to the body of each float of type |TYPE|.
%
%    \begin{macrocode}
\DeclareTemplateType{floattypesetup}{0}

\DeclareTemplate{floattypesetup}{std}{0}{
   type-id            =n  \floattypesetup@id,
   sequence-class-id  =n  \floattypesetup@class@id,
   toc-extension      =n  \floattypesetup@toc@ext,
   default-area-list  =n  \floattypesetup@area@list,
   caption-text       =n  \floattypesetup@caption@text,
   numbered-boolean   =b  @test,
   numbered-id        =n  \floattypesetup@numbered@id,
   numbered-within-id =n  \floattypesetup@numbered@within@id,
   numbered-action    =f0 \floattypesetup@numbered@action,
   body-decls         =f0 \floattypesetup@body@decls,

 }
 {
%    \end{macrocode}
%    Setting up defaults is done (at least in parts) in two steps:
%    first we set certain key commands to |\relax| then we run
%    |\DoParameterAssignments| and then check if they are still
%    |\relax|. If so we set the commands that we really want to
%    set. This is necessary because several of them have names that
%    contain the float type as part of the name and this type name is
%    one of the keys.
%    \begin{macrocode}
  \let\floattypesetup@class@id\relax
  \let\floattypesetup@numbered@id\relax
  \let\floattypesetup@numbered@action\relax
  \let\floattypesetup@body@decls\relax
%    \end{macrocode}
%    Now for the defaults we can set directly:
%    the |@test| switch is locally used to denote that we want to
%    number the floats.
%    \begin{macrocode}
  \@testtrue % number by default
%    \end{macrocode}
%    The areas which should be tried for the current type are by
%    default all areas, i.e., |\known@areas|; we use |\def| not |\let|
%    to allow this list to grow afterwards.
%    \begin{macrocode}
  \def\floattypesetup@area@list{\known@areas}
%    \end{macrocode}
%    Default for the fixed caption text is |\@empty|.
%    \begin{macrocode}
  \let\floattypesetup@caption@text\@empty
%    \end{macrocode}
%    By default we don't run the float counter within another
%    counter. We use |\@empty| to denote this since this is also what
%    would be returned from |numbered-within-id=,| which might be
%    specified by a user.
%    \begin{macrocode}
  \let\floattypesetup@numbered@within@id\@empty
%    \end{macrocode}
%    Everything goes by default to the |.toc| file (which isn't too
%    bad if the extended \texttt{xcontents} package is used.
%    \begin{macrocode}
  \def\floattypesetup@toc@ext{toc}  % everything in here by default
%    \end{macrocode}
%    Now we are ready to look at the designer specifications:
%    \begin{macrocode}
  \DoParameterAssignments
%    \end{macrocode}
%    Now for the second step: evaluate what we have: If the
%    |sequence-class-id| is not set up, we try to default it to the
%    |type-id|:
%    \begin{macrocode}
  \ifx\floattypesetup@class@id\relax
    \let\floattypesetup@class@id\floattypesetup@id
  \fi
%    \end{macrocode}
%    Float numbers are only set up if requested (which is the default).
%    \begin{macrocode}
  \if@test
%    \end{macrocode}
%    If the |numbered-id| is not set up, we try to default it to
%    the |type-id|:\footnote{This needs fixing since part of the float
%    handling assumes there is some counter to step etc. FIX!}
%    \begin{macrocode}
    \ifx\floattypesetup@numbered@id\relax
      \let\floattypesetup@numbered@id\floattypesetup@id
    \fi
%    \end{macrocode}
%    Set up the new counter, if it already exists skip this part:
%    \begin{macrocode}
    \expandafter\ifx\csname c@\floattypesetup@numbered@id \endcsname
                    \relax
      \ifx\floattypesetup@numbered@within@id\@empty
        \newcounter\floattypesetup@numbered@id
      \else
        \newcounter\floattypesetup@numbered@id
                   [\floattypesetup@numbered@within@id]
      \fi
%    \end{macrocode}
%    The default display for the float number is ``arabic'', we
%    overwrite this only if requested:
%    \begin{macrocode}
      \ifx\floattypesetup@numbered@action\relax
      \else
        \global\expandafter\let
            \csname the\floattypesetup@numbered@id \endcsname
            \floattypesetup@numbered@action
      \fi
    \fi
  \fi
%    \end{macrocode}
%    
%    Low-level environment declaration (allows overwriting since
%    figure etc already exists)\footnote{Handle better?}
%    \begin{macrocode}
  \expandafter
  \xdef\csname \floattypesetup@id \endcsname
        {\noexpand\@float{\floattypesetup@id}}
  \global\expandafter \let \csname end\floattypesetup@id \endcsname
        \end@float
%    \end{macrocode}
%    The remaining bits of the code set up the data structures that
%    belong to each float type by linking the macro name containing
%    the type in its name (i.e., |\floattypesetup@id|) to the
%    corresponding key macro. Theay are otherwise straight forward
%    |\let|s.
%
%    First for |\sequence@class@|\meta{type}:
%    \begin{macrocode}
  \global\expandafter\let
     \csname sequence@class@\floattypesetup@id \endcsname
     \floattypesetup@class@id
%    \end{macrocode}
%    Then |\toc@extension@|\meta{type}:
%    \begin{macrocode}
  \global\expandafter\let
     \csname toc@extension@\floattypesetup@id \endcsname
     \floattypesetup@toc@ext
%    \end{macrocode}
%    Then |\fps@|\meta{type}:
%    \begin{macrocode}
  \global\expandafter\let
     \csname fps@\floattypesetup@id \endcsname
     \floattypesetup@area@list
%    \end{macrocode}
%    Then |\caption@|\meta{type}:
%    \begin{macrocode}
  \global\expandafter\let
     \csname caption@\floattypesetup@id \endcsname
     \floattypesetup@caption@text
%    \end{macrocode}
%    Then |\counter@|\meta{type}:
%    \begin{macrocode}
  \global\expandafter\let
     \csname counter@\floattypesetup@id \endcsname
     \floattypesetup@numbered@id
%    \end{macrocode}
%    Then |\body@|\meta{type}:
%    \begin{macrocode}
  \global\expandafter\let
     \csname body@\floattypesetup@id \endcsname
     \floattypesetup@body@decls
 }
%
%
%
%
% \begin{macro}{\DeclareFloatSequenceClass}
%    A float sequence class is a list of float types for which the
%    placement algorithm should preserve call-out order even between
%    objects with different float type.
%
%    For each class we need a corresponding ``mark'' (needed by the
%    algorithm) and we need to record the class name in an |\@elt|
%    list.
%
%    Perhaps this declaration should be implicitly handled by
%    |\DeclareFloatType|. It would mean a bit more work for the latter
%    but less declarations in the document design!\footnote{Change one
%    day!}
%    \begin{macrocode}
\def\DeclareFloatSequenceClass#1{
%    \end{macrocode}
%    We probably have to check if that class is already
%    declared since in that case we have to leave out a couple of
%    actions. We assume that this is the case if a mark class is
%    already defined for it.\footnote{Do it properly!}
%    \begin{macrocode}
  \@ifundefined{mark@#1}
    {
     \DeclareMarkType{#1}
%    \end{macrocode}
%    Add this to the list of known classes.
%    \begin{macrocode}
     \@cons\float@classes@list{{#1}}
    }
    \ErrorAlreadyDefined
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\float@classes@list}
%    The list of float classes known in the system.
%    \begin{macrocode}
\let\float@classes@list\@empty
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\c@figure}
% \begin{macro}{\c@table}
%    Throw away good registers\ldots this is only for testing to allow
%    us using the OR together with classes like article that sets up
%    figure and table already\footnote{Clean up!}
%    \begin{macrocode}
\expandafter\ifx\csname c@figure \endcsname \relax
\else
  \let\c@figure\relax % thus new counter will be defined
  \let\c@table \relax
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
%
%
%
%
%
% \subsection{Float Placement Control Files}
%
% \begin{macro}{\perhaps@write@placements@to@fpl@file}
%    |\perhaps@write@placements@to@fpl@file| writes all float
%    placements (except for ``here'' floats) into the |fpl| in case we
%    are writing to this file.
%
%    By default, don't write fpl files.
%    \begin{macrocode}
\let\perhaps@write@placements@to@fpl@file\relax
\let\perhaps@write@to@fpl@file\@gobble
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\perhaps@write@to@fpl@file}
%    |\perhaps@write@to@fpl@file| writes its first argument to the
%    |fpl| in case we are writing to it.
%
%    By default, don't write fpl files.
%    \begin{macrocode}
\let\perhaps@write@to@fpl@file\@gobble
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\perhaps@write@placements@to@fpl@file@aux}
%    The format for a Float: line in an |fpl| file.  Only the sequence
%    number (|#7|) is currently used, the rest just helps a human
%    reader identify the float.
%    \begin{macrocode}
\def\perhaps@write@placements@to@fpl@file@aux#1#2#3#4#5#6#7{
  \@spaces\@spaces Float:~#7~(#6~#4)~[#3]^^J}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\savefloatplacements}
% Declaration to turn on writing of FPL files.
%    \begin{macrocode}
\def\savefloatplacements{
  \newwrite\fpl@file
  \immediate\openout\fpl@file\jobname.fpl
  \def\perhaps@write@to@fpl@file{
     \immediate\write\fpl@file
     }
  \def\perhaps@write@placements@to@fpl@file{
    \def\@elt{\expandafter
              \perhaps@write@placements@to@fpl@file@aux\the\toks}
    \perhaps@write@to@fpl@file{
     ^^JPage:~\the\absolute@page@number\space (\the\c@page)^^J
%    \end{macrocode}
%    
%    \begin{macrocode}
       \expandafter\@write@areas\used@areas\relax\relax\relax
    }
    \let\@elt\relax}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@write@areas}
%    |\@write@areas| loops through an area list (like |\used@areas|)
%    and writes lines for every float, provided that |\@elt| is
%    properly set up before. It is used inside a |\write| so needs to
%    be expandable!
%    \begin{macrocode}
\def\@write@areas#1#2#3{
    \ifx\relax#1
    \else
       \expandafter\ifx\csname area@#1#2#3\endcsname\@empty
       \else
         \@spaces Area:~#1#2#3^^J\csname area@#1#2#3\endcsname
       \fi
       \expandafter\@write@areas
    \fi}
%    \end{macrocode}
%    Alternate version that writes out all areas even if they don't
%    contain any floats.
%    \begin{macrocode}
\def\@write@areas#1#2#3{
    \ifx\relax#1
    \else
       \@spaces Area:~#1#2#3^^J\csname area@#1#2#3\endcsname
       \expandafter\@write@areas
    \fi}
%    \end{macrocode}
% \end{macro}   
%
%
%
%
% \begin{macro}{\readfloatplacements}
% Similar declaration to read FPC files. The file is read at this
%  point up to th efirst Page: line. and the output routine command
% |\float@placement@loop| is redefined to read the FPC info for each page.
%    \begin{macrocode}
\def\readfloatplacements{
  \newread\fpc@file
  \openin\fpc@file\jobname.fpc\relax
  \ifeof\fpc@file
    \PackageWarningNoLine{xo}
        {No~\jobname.fpc:~using~automatic~float~placement}
  \else
    \let\get@fpc@page@data\get@fpc@page@data@fpc
    \get@fpc@page@data
    \let\try@float@pages\relax
%    \end{macrocode}
%    Next line should go once we implement moving floats in and out of
%    ``here'' as then we need to read the file at a different
%    place!\footnote{Reimplement!}
%    \begin{macrocode}
    \let\float@placement@loop\fpc@float@placement@loop
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\fpc@float@placement@loop}
%    Version of |\try@float@pages| to use with float placement control file.
%    Should be moved to xo-or once it works.
%    \begin{macrocode}
\def\fpc@float@placement@loop{
%<*trace>
  \@tracepush{fpc@float@placement@loop}
%</trace>
%    \end{macrocode}
%    Don't think the the next line has any meaning, so
%    removed.\footnote{Old command only did set up best@trial, which
%    is later on set to relax anyway. Correct to remove?}
%    \begin{macrocode}
%  \initialise@best@trial
  \get@fpc@page@data
  \global\let\best@trial\relax
%    \end{macrocode}
%
%    \footnote{Do we have to set run@with@floats? Check!}
%    \begin{macrocode}
  \mark@restore@state{
    \unvcopy\@holdpg
    \setup@best@column@or
   }
%<*trace>
  \@tracepop{fpc@float@placement@loop}
%</trace>
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\next@fpc@page}
% The next page for which there is FPC data. Initial value has to be
% a number to |\ifnum|.
%    \begin{macrocode}
\let\next@fpc@page\m@ne
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\get@fpc@page@data}
%   
%    \begin{macrocode}
\let\get@fpc@page@data\relax
%    \end{macrocode}
% \end{macro}   
%
%
% \begin{macro}{\get@fpc@page@data@fpc}
% get one line of data from an FPC file, calls itself recursively
% so the effect of a call is to get all the lines for the current page
% up to and including the Page: line for the next page for which there
% is data.
%    \begin{macrocode}
\def\get@fpc@page@data@fpc{
%<*trace>
\@tracepush{get@fpc@page@data@fpc}
%</trace>
  \let\@nextfpc\relax
  \ifnum\next@fpc@page>\absolute@page@number
%<*trace>
    \tr@ce{No~ float~ control~ on~ page:~ \the\absolute@page@number}
%</trace>
  \else
    \ifeof\fpc@file
%<*trace>
      \tr@ce{fpc~ file~ended}
%</trace>
      \global\let\next@fpc@page\maxdimen
    \else
      \begingroup
      \endlinechar`\ %
      \catcode`\ 10\relax
      \global\read\fpc@file~to~\@gtempa
      \endgroup
      \let\@nextfpc\get@fpc@page@data
      \ifx\@gtempa\@empty
      \else
        \expandafter\parse@fpc\@gtempa\relax
      \fi
    \fi
  \fi
%<*trace>
\@tracepop{get@fpc@page@data@fpc}
%</trace>
  \@nextfpc
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{parse@fpc}
%    If float control files are being read, 
%    Read the section of the fpc file for this page
%    and directly assign floats to the specified areas
%    with no trials or checks.
%    \begin{macrocode}
\def\parse@fpc#1#2~#3~#4\relax{
  \ifx P#1
%<*trace>
\tr@ce{Next~page~control:~#3}
%</trace>
  \global\mathchardef\next@fpc@page#3\relax
  \let\@nextfpc\relax
  \else\ifx A#1
%<*trace>
\tr@ce{Area:~#3}
%</trace>
    \setup@this@area{#3}
    \let\@nextfpc\get@fpc@page@data
  \else\ifx F#1
    \ifx\this@area\fpc@here
%    \end{macrocode}
%    Should allow moving floats into and out of here status means
%    reading before the collecton OR, not after.\footnote{FIX, update,
%    extend --- whatever you want to call it.}
%    \begin{macrocode}
%<*trace>
\tr@ce{here~float}
%</trace>
    \else
%<*trace>
\tr@ce{not~here~float}
%</trace>
      \begingroup
        \count@#3\relax
        \global\let\this@float@box\relax
        \let\@elt\extract@float@by@number
        \@activelist
      \endgroup
%    \end{macrocode}
%    If a float number is specified and there is not a float of that
%    number in the active list, something has gone wrong, either we
%    haven't reached the float yet (possible if the new arrangement
%    results in the callout being on a later page than specified) or
%    we have already assigned this float (which is a bug, either in
%    this code, or in the fpc file.) Currently this condition is not
%    handled other than by |\ERROR|. If the float is found, assign it
%    to the current area (as set by an Area: line in the fpc file.
%    \begin{macrocode}
      \ifx\this@float@box\relax
%<*trace>
        \tr@ce{Float:~#3~not~found}
%</trace>
        \edef\fpc@list{\fpc@list#3,\this@area\relax}
        \show\fpc@list
      \else
%<*trace>
        \tr@ce{Float:~#3~is~\this@float@box}
%</trace>
%    \end{macrocode}
%    Before we add the float, let's do some sanity checks. We allow to
%    place a float into an area which is bigger than the float (spans
%    more columns) but we complain if the area is smaller.
%    \begin{macrocode}
        \ifnum \this@area@span@number < 
            \if!\this@span@number! 1\else  % big hack
                                   \this@span@number \fi
             \relax
          \PackageError{xo}
             {Float~ bigger~ than~ target~ area}
             {Float~\this@sequence@number\space spans ~
              \this@span@number\space columns,~ 
              but~ target~ area~ \this@area\space
              spans~ only~ \this@area@span@number\space
              columns.\MessageBreak
              Correct~ the~ data~ in~ file~ \jobname.fpc!
             }
        \fi
%    \end{macrocode}
%    We also check if the target area is allowed on the current page
%    (it could be the case that the page setup for that page doesn't
%    list it in its |area-list| key!
%    \begin{macrocode}
        \xin@\this@area
             \used@areas
        \ifin@\else
          \PackageError{xo}
             {Target~ area~ not~ available~ on~ current~ page}
             {Float~ \this@sequence@number\space was~ requested~ to~
              be~ placed~ into~ area~ \this@area,\MessageBreak
              but~ this~
              area~ is~ not~ available~ on~ page~ \thepage.
              \MessageBreak
              Correct~ the~ data~ in~ file~ \jobname.fpc!
             }
%    \end{macrocode}
%    If we can't put it into the requested area we have to put it
%    somewhere else. Otherwise a lot of code might break. So we simply
%    chose the first area in |\used@area|\footnote{Need a solution if
%    the page doesn't allow ``any'' floats! FIX!}
%    \begin{macrocode}
          \ifx\used@areas\@empty % we have a problem
            \RESOLVE
          \else
            \setup@this@area{\expandafter\@carcube\used@areas\@nil}
          \fi
        \fi
%    \end{macrocode}
%    Typeset and attach the caption and adjust the text size for the
%    current column.
%    \begin{macrocode}
        \append@caption@to@float
        \construct@and@test@col@hts
        \if@test
           \ERRORFloatAreaToLarge
        \fi
%    \end{macrocode}
%    We append the float to the area after the above column updates,
%    otherwise |\construct@and@test@col@hts| would incorrectly think
%    there is already a float present even if we add the first float
%    to an area.
%    \begin{macrocode}
        \let\@elt\relax
        \xdef\@freelist{\@freelist\@elt\this@float@box}
        \expandafter\@cons\csname area@\this@area\expandafter\endcsname
          \this@float@box
      \fi
    \fi
%    \end{macrocode}
%
%    Loop to next line.
%    \begin{macrocode}
    \let\@nextfpc\get@fpc@page@data
%    \end{macrocode}
% end of case on type of fpc line.
%    \begin{macrocode}
  \fi\fi\fi
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\fpc@here}
%   
%    \begin{macrocode}
\def\fpc@here{hhh}
%    \end{macrocode}
% \end{macro}   

% \begin{macro}{\fpc@list}
%   
%    \begin{macrocode}
\def\fpc@list{\relax}
%    \end{macrocode}
% \end{macro}   
%
%
% \begin{macro}{\get@float@number}
% could be known as |\@seventhofseven|.
%    \begin{macrocode}
\def\get@float@number#1#2#3#4#5#6#7{#7}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\extract@float@by@number}
% Find the float box that has the float with sequence number |\count@|.
%    \begin{macrocode}
\def\extract@float@by@number#1{
  \ifnum\expandafter\get@float@number\the\toks#1=\count@
    \def\@currbox{#1}
    \expandafter\update@this@float@structure\the\toks#1
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
% \endinput
\endinput
%
% $Log: xo-float.dtx,v $
% Revision 1.32  2000/08/11 07:14:11  latex3
% added header
%
% Revision 1.31  2000/08/11 06:48:24  latex3
% untabify
%
% Revision 1.30  2000/08/11 06:44:00  latex3
% fix typo in initialization
%
% Revision 1.29  2000/08/04 10:17:28  latex3
% separate out initialisation of here float
%
% Revision 1.28  2000/07/19 17:14:01  latex3
% deduce \this@class from \this@type instead of storing it on a per
% float basis
%
% Revision 1.27  2000/07/19 15:53:46  latex3
% introduced float sequence classes
% cleaned up parts of the code
% added further documentation
%
% Revision 1.26  2000/07/10 18:47:12  latex3
% macro name renaming
%
% Revision 1.25  2000/06/29 17:16:30  latex3
% introduced \setup@this@area
%
% Revision 1.24  2000/06/26 15:00:59  latex3
% docu update
%
% Revision 1.23  2000/06/22 20:07:00  latex3
% renamed some macros to get them more uniform
%
% Revision 1.22  2000/06/22 10:55:59  latex3
% Includeed part of David's code (formerly in xo-dpc.sty) for writing
% and reading fpl/fpc files. Not done is moving floats in and out of hhh
%
% Revision 1.21  2000/06/16 11:20:50  latex3
% rename \construct@and@test@col@height to \construct@and@test@col@ht
% rename \construct@and@test@col@heights to \construct@and@test@col@hts
% rename \cl@height1 to \@col@ht@1 (etc)
%
% Revision 1.20  2000/06/15 15:24:25  latex3
% implemented new semantics for area names
%
% Revision 1.19  2000/06/13 21:18:02  latex3
% add some trace guards
%
% Revision 1.18  2000/05/03 18:55:34  latex3
% pass \theCNT instead of \value{CNT} in the float data structure (we
% might need both one day)
%
% Revision 1.17  2000/04/21 19:11:39  latex3
% updated here float interface (needs fixing)
%
% Revision 1.16  2000/04/08 10:49:39  latex3
% first draft support for here floats
%
% Revision 1.15  2000/03/24 15:34:27  latex3
% version that starts supporting spans (still a hack yet)
%
% Revision 1.14  2000/03/22 15:30:28  latex3
% some normalisations of names
% started on spans (tmp version)
%
% Revision 1.13  2000/03/16 10:28:29  latex3
% partial and full flush working for the first time
%
% Revision 1.12  2000/03/05 19:40:07  latex3
% support multiple columns (6 max right now)
% moved some float init code into page setup
%
% Revision 1.11  2000/02/26 18:22:59  david
% interface to x-alloc and make changes due to
% deferred float pre-allocation
%
% Revision 1.10  2000/02/21 01:45:23  david
% documentation improvements
%
% Revision 1.9  2000/02/20 00:05:08  david
% use galley, don't discard it (get more pages that way)
%
% Revision 1.8  2000/02/19 23:16:19  david
% Use \construct@and@test@col@height before destroying
% \this@captioned@float, not after...
%
% Revision 1.7  2000/02/19 18:55:44  david
% reading fpc files
%
% Revision 1.6  2000/02/17 22:47:07  david
% *** empty log message ***
%
% Revision 1.5.1.1  2000/02/16  10:39:42  latex3
% 3cols support added
%
