% \iffalse meta-comment
%
% Copyright (C) 1993-2025
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
% -------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.txt'. See also `legal.txt' for additional
% information.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
% \iffalse
%%% From File: ltoutput.dtx
%<flafter>\ProvidesPackage{flafter}
%<fltrace>\ProvidesPackage{fltrace}
%<flafter,fltrace>       [2025/08/22 v1.4z
%<flafter>                  Standard LaTeX floats after reference (FMi)]
%<fltrace>                  Tracing LaTeX floats algorithm (FMi)]
%
%<*driver>
% \fi
\ProvidesFile{ltoutput.dtx}
             [2025/08/22 v1.4z LaTeX Kernel (Output Routine)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltoutput.dtx}
\title{\filename}
\date{\filedate}
\author{Leslie Lamport, Frank Mittelbach, Chris Rowley}
\begin{document}
 \MaintainedByLaTeXTeam{latex}
 \maketitle \tableofcontents
 \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
%
% \providecommand\hook[1]{\texttt{#1\DescribeHook[noprint]{#1}}}
% \providecommand\socket[1]{\texttt{#1\DescribeSocket[noprint]{#1}}}
% \providecommand\plug[1]{\texttt{#1\DescribePlug[noprint]{#1}}}
%
% \ProvideDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl}
% \ProvideDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl}
% \ProvideDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl}
%
%
% \iffalse
% LATEX VERSION 2e
% Copyright (C) 1992 Leslie Lamport
% Copyright (C) 1994-2000 Leslie Lamport, LaTeX Project
%
% LaTeX 2e kernel file for the output routine.
%
% Part of this file is the latest (not greatest, it still
% deserves its name) version of kludge.sty.
%
% It also contains a few enhancements and many changes (corrections
% and tidyings) to the float mechanism and other parts of the output
% routine.
%
% The tracing in the file at present is mainly to help in testing the
% code but it may well be developed into a full float tracing
% package one day.
%
% ============================
% \fi
%
% \changes{v1.1p}{1995/08/25}{Support autoloading feature (FMi).}
% \task{CAR}{Update documentation.}
% \changes{v1.0k}{1994/02/08}{Documentation and tasks tidied.}
% \changes{v1.0l}{1994/03/15}{Driver added and further tidying.}
% \changes{v1.0l}{1994/03/15}{Some boxmaxdepth settings removed.}
% \changes{v1.0l}{1994/03/15}{Added some warnings when page gets full of
% top floats.}
% \changes{v1.0l}{1994/03/15}{Removed duplicated code and corrected
% docstrip options.}
% \changes{v1.0m}{1994/04/24}{Removed some long lines and other
% aesthetic changes.}
% \changes{v1.0m}{1994/04/24}{Corrected unverbed commands in
% documentation.}
% \changes{v1.0m}{1994/04/24}{Changed \cs{@normalsize} to
% \cs{normalsize}.}
% \changes{v1.0m}{1994/04/24}{Warning messages changed/corrected.}
% \changes{v1.0n}{1994/04/30}{Added \cs{col@number}.}
% \changes{v1.0n}{1994/04/30}{Fixed bug from \cs{dblfigrule} with
% \cs{@topnewpage}.}
% \changes{v1.0n}{1994/04/30}{Documentation tidied.}
% \changes{v1.0n}{1994/04/30}{\cs{@activechar@warning} changed to an
% info message.}
% \changes{v1.0n}{1994/04/30}{Full of floats action improved.}
% \changes{v1.0n}{1994/04/30}{Empty column action added.}
% \changes{v1.0o}{1994/05/02}{Code of \cs{@resethfps} shortened.}
% \changes{v1.0p}{1994/05/12}{\cs{normalcolor}added in various
% places (DPC).}
% \changes{v1.0q}{1994/05/16}{Changed setting of accents (FMi).}
% \changes{v1.0s}{1994/05/20}{Added setting of \cs{protect}
% during \cs{shipout}.}
% \changes{v1.0t}{1994/05/22}{Changed warnings and infos to
% new commands.}
% \changes{v1.0u}{1994/05/23}{Added \cs{MessageBreak}.}
% \changes{v1.0u}{1994/05/23}{Changed resetting of \cs{protect} after
% shipout.}
% \changes{v1.0v}{1994/05/25}{Extra documentation.}
% \changes{v1.0w}{1994/06/01}{Tidied up typesetting.}
%
% \changes{v1.1f}{1994/11/14}{Removed old definition of \cs{@testfp}.}
% \changes{v1.1h}{1994/11/17}
%         {\cs{@tempa} to \cs{reserved@a}.}
% \changes{v1.1m}{1995/05/07}{Use \cs{hb@xt@}.}
% \changes{v1.2n}{2015/02/21}
%         {Removed autoload code}
%
% \MaybeStop{}
%
% \def \ie {i.e.~}
% \def \eg {e.g.~}
%
% \section{Output Routine and float handling}
%
%
%    \begin{macrocode}
%<*2ekernel>
\message{output,}
%    \end{macrocode}
%
% \subsection{Historical notes on the algorithm and commands}
%
%
% \begin{oldcomments}
%     ****************************************
%     *               OUTPUT                 *
%     ****************************************
%
%
%  PAGE LAYOUT PARAMETERS
%
%   \topmargin      : Extra space added to top of page.
%   @twoside        : boolean.  T if two-sided printing
%   \oddsidemargin  : IF @twoside = T
%                       THEN extra space added to left of odd-numbered
%                            pages.
%                       ELSE extra space added to left of all pages.
%   \evensidemargin : IF @twoside = T
%                       THEN extra space added to left of even-numbered
%                            pages.
%   \headheight     : height of head
%   \headsep        : separation between head and text
%   \footskip       : distance separation between baseline of last
%                     line of text and baseline of foot.
%                     Note difference between \footSKIP and \headSEP.
%   \textheight     : height of text on page, excluding head and foot
%   \textwidth      : width of printing on page
%   \columnsep      : IF @twocolumn = T
%                       THEN width of space between columns
%   \columnseprule  : IF @twocolumn = T
%                       THEN width of rule between columns (0 if none).
%   \columnwidth    : IF @twocolumn = T
%                       THEN (\textwidth - \columnsep)/2
%                       ELSE \textwidth
%                     It is set by the \twocolumn and
%                     \onecolumn commands.
%   \@textbottom    : Command executed at bottom of vbox holding text of
%                     page (including figures).  The \raggedbottom
%                     command almost \let's this to \vfil (actually sets
%                     it to \vskip \z@ plus.0001fil).
%                     Should have depth 0pt.
%
%   \@texttop       : Command executed at top of vbox holding text of
%                     page (including figures).  Used by letter style;
%                     can also be used to produce centered pages.
%                     Let to \relax by \raggedbottom and \flushbottom.
%
%   Page layout must initialize \@colht and \@colroom to \textheight.
%
%  PAGE STYLE PARAMETERS:
%
%   \floatsep       : Space left between floats.
%   \textfloatsep   : Space between last top float or first bottom float
%                     and the text.
%   \topfigrule     : Command to place rule (or whatever) between floats
%                     at top of page and text.  Executed in inner
%                     vertical mode right before the \textfloatsep skip
%                     separating the floats from the text.  Must occupy
%                     zero vertical space.  (See \footnoterule.)
%   \botfigrule     : Same as \topfigrule, but put after the
%                     \textfloatsep skip separating text from the
%                     floats at bottom of page.
%   \intextsep      : Space left on top and bottom of an in-text float.
%   \dblfloatsep    : Space between double-column floats.
%   \dbltextfloatsep : Space between top double-column floats
%                      and text.
%   \dblfigrule     : Similar to \topfigrule, but for double-column
%                     floats.
%   \@fptop         : Glue to go at top of float column -- must be 0pt +
%                     stretch
%   \@fpsep         : Glue to go between floats in a float column.
%   \@fpbot         : Glue to go at bottom of float column
%                       -- must be 0pt +
%                     stretch
%   \@dblfptop, \@dblfpsep, \@dblfpbot
%                   : Analogous for double-column float page in
%                     two-column format.
%
%  FOOTNOTES: As in PLAIN, footnotes use \insert\footins.
%
%  PAGE LAYOUT SWITCHES AND MACROS
%
%   @twocolumn      : Boolean.  T if two columns per page globally.
%
%  PAGE STYLE MACROS AND SWITCHES
%
%   \@oddhead        : IF @twoside = T
%                           THEN macro to generate head of odd-numbered
%                                pages.
%                           ELSE macro to generate head of all pages.
%   \@evenhead       : IF @twoside = T
%                           THEN macro to generate head of even-numbered
%                                pages.
%   \@oddfoot        : IF @twoside = T
%                           THEN macro to generate foot of odd-numbered
%                                pages.
%                           ELSE macro to generate foot of all pages.
%   \@evenfoot       : IF @twoside = T
%                           THEN macro to generate foot of even-numbered
%                                pages.
%   @specialpage    : boolean.  T if current page is to have a special
%                               format.
%  \@specialstyle  : If its value is  foo then
%                     IF @specialpage = T
%                       THEN the command \ps@foo is executed to
%                            temporarily reset the page style parameters
%                            before composing the current page.
%                            This command should execute only \def's and
%                            \edef's, making only local definitions.
%
%  FLOAT PLACEMENT PARAMETERS
%
% The following parameters are set by the macro \@floatplacement.
% When \@floatplacement is called,
% \@colht is the height of the page or column being built.  I.e.:
%         * For single-column page it equals \textheight.
%         * For double-column page it equals \textheight - height
%           of double-column floats on page.
% Note that some are set globally and some locally:
%    \@topnum  :=G Maximum number of floats allowed on the top of a
%                  column.
%    \@toproom :=G Maximum amount of top of column devoted to floats--
%                  excluding \textfloatsep separation below the floats
%                  and \floatsep separation between them.  For
%                  two-column output, should be computed as a function
%                  of \@colht.
%    \@botnum, \@botroom
%                : Analogous to above.
%    \@colnum  :=G Maximum number of floats allowed in a column,
%                  including in-text floats.
%    \@textmin :=L Minimum amount of text (excluding footnotes) that
%                  must appear on a text page.
%                     %% 27 Sep 85 : made local to
%                     %% \@addtocurcol and \@addtonextcol
%                  It is now also used locally in processing double
%                  floats.
%    \@fpmin   :=L Minimum height of floats in a float column.
%
% The macro \@dblfloatplacement sets the following parameters.
%    \@dbltopnum  :=G Maximum number of double-column floats allowed at
%                     the top of a two-column page.
%    \@dbltoproom :=G Maximum height of double-column floats allowed at
%                     top of two-column page.
%    \@fpmin      :=L Minimum height of floats in a float column.
% It should also perform the following local assignments where necessary
% -- i.e., where the new value differs from the old one:
%      \@fptop       :=L \@dblfptop
%      \@fpsep       :=L \@dblfpsep
%      \@fpbot       :=L \@dblfpbot
%
%  OUTPUT ROUTINE VARIABLES
%
%  \@colht : The total height of the current column.  In single column
%            style, it equals \textheight.  In two-column style, it is
%            \textheight minus the height of the double-column floats
%            on the current page.  MUST BE INITIALIZED TO \textheight.
%
%  \@colroom : The height available in the current column for text and
%              footnotes.  It equals \@colht minus the height of all
%              floats committed to the top and bottom of the current
%              column.
%
%  \@textfloatsheight : The total height of in-text floats on the
%                       current page.
%
%  \footins : Footnote insertion number.
%
%  \@maxdepth : Saved value of TeX's \maxdepth.  Must be set
%               when any routine sets \maxdepth.
%
%            CALLING THE OUTPUT ROUTINE
%            --------------------------
%
% The output routine is called either by TeX's normal page-breaking
% mechanism, or by a macro putting a penalty < or = -10000 in the output
% list.  In the latter case, the penalty indicates why the output
% routine was called, using the following code.
%
%   penalty   reason
%   -------   ------
%   -10000    \pagebreak
%             \newpage
%   -10001    \clearpage (\penalty -10000 \vbox{} \penalty -10001)
%   -10002    float insertion, called from horizontal mode
%   -10003    float insertion, called from vertical mode.
%   -10004    float insertion.
%
% Note: A float or marginpar puts the following sequence in the output
%       list:  (i) a penalty of -10004,
%             (ii) a null \vbox
%            (iii) a penalty of -10002 or -10003.
%       This solves two special problems:
%         1. If the float comes right after a \newpage or \clearpage,
%            then the first penalty is ignored, but the second one
%            invokes the output routine.
%         2. If there is a split footnote on the page, the second 'page'
%            puts out the rest of the footnote.
%
%             THE OUTPUT ROUTINE
%             ------------------
%
% FUNCTIONS USED IN THE OUTPUT ROUTINE:
%
% \@outputpage : Produces an output page with the contents of box
%              \@outputbox as the text part.
%              Also sets \@colht :=G \textheight.
%              The page style is determined as follows.
%                IF  @thispagestyle = true
%                  THEN  use \thispagestyle style
%                  ELSE  use ordinary page style.
%
% \@tryfcolumn\FLIST : Tries to form a float column composed of floats
%         from \FLIST (if nonempty) with the following parameters:
%                \@colht : height of box
%                \@fpmin : minimum height of floats in the box
%                \@fpsep : interfloat space
%                \@fptop : glue at top of box
%                \@fpbot : glue at bottom of box.
%              If it succeeds, then it does the following:
%                * \@outputbox :=L the composed float box.
%                * @fcolmade   :=G true
%                * \FLIST      :=G \FLIST - floats put in box
%                * \@freelist  :=G \@freelist + floats put in box
%              If it fails, then:
%                * @fcolmade :=G false
%           NOTE: BIT MUST BE A SINGLE TOKEN!
%
% \@makefcolumn \FLIST : Same as \@tryfcolumn except that it
%             fails to make a float column only if \FLIST is empty.
%             Otherwise, it makes a float column containing at least
%             the first box in \FLIST, disregarding \@fpmin.
%
% \@startcolumn :
%       Calls \@tryfcolumn\@deferlist.  If \@tryfcolumn returns with
%       (globally set) @fcolmade = false, then:
%                * Globally sets \@toplist and \@botlist to floats
%                  from \@deferlist to go at top and bottom of column,
%                  deleting them from \@deferlist.  It does
%                  this using \@colht as the total height, the page
%                  style parameters \@floatsep and \@textfloatsep, and
%                  the float placement parameters \@topnum, \@toproom,
%                  \@botnum, \@botroom, \@colnum and \textfraction.
%                * Globally sets \@colroom to \@colht minus the height
%                  of the added floats.
%
% \@startdblcolumn :
%      Calls \@tryfcolumn\@dbldeferlist{8}.  If \@tryfcolumn returns
%      with (globally set) @fcolmade = false, then:
%               * Globally sets \@dbltoplist to floats from
%                 \@dbldeferlist to go at top and bottom of column,
%                 deleting them from \@dbldeferlist.
%                 It does this using \textheight as the
%                 total height, and the parameters \@dblfloatsep, etc.
%               * Globally sets \@colht to \textheight minus the height
%                 of the added floats.
%
% \@combinefloats : Combines the text from box
%              \@outputbox with the floats from \@toplist and \@botlist,
%              putting the new box in \@outputbox.  It uses \floatsep
%              and \textfloatsep for the appropriate separations.
%              It puts the elements of \TOPLIST and \BOTLIST onto
%              \@freelist, and makes those lists null.
%
% \@makecol : Makes the contents of \box255 plus the accumulated
%              footnotes, plus the floats in \@toplist and \@botlist,
%              into a single column of height \@colht (unless the page
%              height has been locally changed), which it puts
%              into box \@outputbox.  It puts boxes in \@midlist back
%              onto \@freelist and restores \maxdepth.
%
% \@opcol : Outputs a column whose text is in box \@outputbox
%              If @twocolumn = false, then it calls \@outputpage,
%              sets \@colht :=G \textheight, and calls \@floatplacement.
%
%              If @twocolumn = true, then:
%                  If @firstcolumn = true, then it puts box \@outputbox
%                  into \@leftcolumn and sets @firstcolumn :=G false.
%
%                  If @firstcolumn = false, then it puts out the current
%                  two-column page, any possible two-column float pages,
%                  and determines \@dbltoplist for the next page.
%
%
%
%            USER COMMANDS THAT CALL OR AFFECT THE OUTPUT ROUTINE
%            ----------------------------------------------------
%
% \newpage == BEGIN \par\vfil\penalty -10000 END
%
% \clearpage == BEGIN \newpage
%                     \write -1{}    % Part of hack to make sure no
%                     \vbox{}        % \write's get lost.
%                     \penalty -10001
%               END
%
% \cleardoublepage == BEGIN \clearpage
%                           if @twoside = true and c@page is even
%                             then \hbox{} \newpage fi
%                     END
%
%
% \twocolumn[BOX] : starts a new page, changing to twocolumn setting
%     and puts BOX in a parbox of width \textwidth across the top.
%     Useful for full-width titles for double-column pages.
%     SURPRISE: The stretch from \@dbltextfloatsep will be inserted
%               between the BOX and the top of the two columns.
%
%
%            FLOAT-HANDLING MECHANISMS
%            -------------------------
%
% The float environment obtains an insertion number B from the
% \@freelist (see below for a description of list manipulation), puts
% the float into box B and sets \count B to a FLOAT SPECIFIER.  For
% a normal (not double-column) float, it then causes a page break
% in one of the following two ways:
%   - In outer hmode: \vadjust{\penalty -10002}
%   - In vmode :      \penalty -10003.
% For a double-column float, it puts B onto the \@dbldeferlist.
% The float specifier has two components:
%    * A PLACEMENT SPECIFICATION, describing where the float may
%      be placed.
%    * A TYPE, which is a power of two--e.g., figures might be
%      type 1 floats, tables type 2 floats, programs type 4 floats, etc.
% The float specifier is encoded as follows, where bit 0 is the least
% significant bit.
%
%  Bit    Meaning
%  ---    -------
%   0     1 iff the float may go where it appears in the text.
%   1     1 iff the float may go on the top of a page.
%   2     1 iff the float may go on the bottom of a page.
%   3     1 iff the float may go on a float page.
%   4     1 unless the PLACEMENT includes a !
%   5     1 iff a type 1 float
%   6     1 iff a type 2 float
%   etc.
%
%  A negative float specifier is used to indicate a marginal note.
%
%     MACROS AND DATA STRUCTURES FOR PROCESSING FLOATS
%     ------------------------------------------------
%
%  A FLOAT LIST consisting of the floats in boxes \boxa ... \boxN has
%  the form:
%         \@elt \boxa ... \@elt \boxN
%  where  \boxI is defined by
%         \newinsert\boxI
%  Normally, \@elt is \let to \relax.  A test can be performed on the
%  entire float list by locally \def'ing \@elt appropriately and
%  executing the list.
%  This is a lot more efficient than looping through the list.
%
%  The following macros are used for manipulating float lists.
%
%  \@next \CS \LIST {NONEMPTY}{EMPTY} ==  %% NOTE: ASSUME \@elt = \relax
%    BEGIN  assume that \LIST == \@elt \B1 ... \@elt \Bn
%           if n = 0
%             then  EMPTY
%             else  \CS    :=L \B1
%                   \LIST  :=G \@elt \B2 ... \@elt \Bn
%                   NONEMPTY
%           fi
%    END
%
%
%  \@bitor\NUM\LIST : Globally sets switch @test to the disjunction for
%         all I of bit  log2 \NUM of the float specifiers of all the
%         floats in \LIST.
%         I.e., @test is set to true iff there is at least one
%         float in \LIST having bit  log2 \NUM  of its float specifier
%         equal to 1.
%
%  Note: log2 [(\count I)/32] is the bit number corresponding to the
%  type of float I.  To see if there is any float in \LIST having
%  the same type as float I, you run \@bitor with
%    \NUM = [(\count I)/32] * 32.
%
% \@bitor\NUM\LIST ==
%   BEGIN
%      @test :=G false
%      { \@elt \CTR ==  if \NUM <> 0 then
%                          if \count\CTR / \NUM is odd
%                             then  @test := true       fi fi
%        \LIST
%      }
%   END
%
%
% \@cons\LIST\NUM : Globally sets \LIST := \LIST * \@elt \NUM
%
% \@cons\LIST\NUM ==
%   BEGIN {  \@elt == \relax
%            \LIST :=G \LIST \@elt \NUM
%         }
%
%  BOX LISTS FOR FLOAT-PLACEMENT ALGORITHMS
%
%    \@freelist     : List of empty boxes for placing new floats.
%    \@toplist      : List of floats to go at top of current column.
%    \@midlist      : List of floats in middle of current column.
%    \@botlist      : List of floats to go at bottom of current column.
%    \@deferlist    : List of floats to go after current column.
%    \@dbltoplist   : List of double-col. floats to go at top of current
%                     page.
%    \@dbldeferlist : List of double-column floats to go on subsequent
%                     pages.
%
%  FLOAT-PLACEMENT ALGORITHMS
%
%
%  \@addtobot : Tries to put insert \@currbox on \@botlist.
%               Called only when:
%                  * \ht BOX < \@colroom
%                  * type of \@currbox not on \@deferlist
%                  * \@colnum > 0
%                  * @insert = false
%               If it succeeds, then:
%                  * sets @insert true
%                  * decrements \@botroom by \ht BOX
%                  * decrements \@botnum and \@colnum by 1
%                  * decrements \@colroom by \ht BOX + either \floatsep
%                    or \textfloatsep, as appropriate.
%                  * sets \maxdepth to 0pt    % <-- as of 2025/06/01
%                                             %     no longer the case
%
%  \@addtotoporbot : Tries to put insert \@currbox on \@toplist or
%                    \@botlist.
%                    Called only under same conditions as \@addtobot.
%                    If it succeeds, then:
%                       * sets @insert true
%                       * decrements \@toproom or \@botroom by \ht BOX
%                       * decrements \@colnum and either \@topnum or
%                         \@botnum by 1
%                       * decrements \@colroom by \ht BOX + \floatsep
%                         or \textfloatsep, as appropriate.
%
% \@addtocurcol : Tries to add \@currbox to current column, setting
%                 @insert true if it succeeds, false otherwise.
%                 It will add \@currbox to top only if bit 0 of
%                 \count \@currbox is 0, and to the bottom only if
%                 bit 0 = 0 or an earlier float of the same type is
%                 put on the bottom.
%                 If the float is put in the text, then
%                 \penalty\interlinepenalty is put
%                 right after the float, before the following \vskip,
%                 and \outputpenalty :=L 0.
%
% \@addtonextcol : Tries to add \@currbox to the next column, setting
%                  @insert true if it succeeds, false otherwise.
%
% \@addtodblcol : Tries to add \@currbox to the next double-column page,
%                 adding it to \@dbltoplist if it succeeds and
%                 \@dbldeferlist if it fails.
%
%
%  \@addmarginpar ==
%   BEGIN
%     if \@currlist nonempty
%       then remove \@marbox from \@currlist
%            add \@marbox and \@currbox to \@freelist
%                 %% NOTE: \@currbox = left box
%       else LaTeX error: ?  %% shouldn't happen
%     fi
%     \@tempcnta := 1     %% 1 = right, -1 = left
%     if @twocolumn = true
%       then if @firstcolumn = true
%              then \@tempcnta := -1
%            fi
%       else if @mparswitch = true
%              then if count0 odd
%                     else \@tempcnta := -1
%                   fi
%            fi
%            if @reversemargin = true
%               then \@tempcnta := -\@tempcnta
%            fi
%     fi
%     if \@tempcnta < 0 then \box\@marbox :=G \box\@currbox
%     fi
%     \@tempdima   :=L maximum(\@mparbottom - \@pageht
%                                           + ht of \@marbox, 0)
%     if \@tempdima > 0 then LaTeX warning: 'marginpar moved' fi
%     \@mparbottom :=G \@pageht + \@tempdima + depth of \@marbox
%                          + \marginparpush
%     \@tempdima   :=L \@tempdima - ht of \@marbox
%     \box\@marbox :=G \box\@currbox
%                                \vbox { \vskip \@tempdima
%                                        \box\@marbox
%                                       }
%     height of \@marbox :=G depth of \@marbox :=G 0
%     \kern -\@pagedp
%     \nointerlineskip
%     \hbox{ if @tempcnta > 0 then \hskip \columnwidth
%                                 \hskip \marginparsep
%                            else \hskip -\marginparsep
%                                 \hskip -\marginparwidth
%            fi
%            \box\@marbox \hss
%          }
%     \nobreak
%     \nointerlineskip
%     \hbox{\vrule height 0 width 0 depth \@pagedp}
%   END
% \end{oldcomments}
%
%
%
% \subsection{Core definitions}
%
%   Floats and marginpars add a lot of dead cycles.
%    \begin{macrocode}
\maxdeadcycles = 100
%    \end{macrocode}
%
%    \begin{macrocode}
\let\@elt\relax
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@next#1#2#3#4{\ifx#2\@empty #4\else
   \expandafter\@xnext #2\@@#1#2#3\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@xnext \@elt #1#2\@@#3#4{\def#3{#1}\gdef#4{#2}}
%    \end{macrocode}
%
% \changes{v1.1v}{1996/07/26}{put \cs{global} into definition}
%    \begin{macrocode}
\def\@testfalse{\global\let\if@test\iffalse}
\def\@testtrue {\global\let\if@test\iftrue}
\@testfalse
%    \end{macrocode}
%
% \changes{v1.1v}{1996/07/26}{remove \cs{global} before \cs{@test...}}
%    \begin{macrocode}
\def\@bitor#1#2{\@testfalse {\let\@elt\@xbitor
   \@tempcnta #1\relax #2}}
%    \end{macrocode}
%    RmS 91/11/22: Added test for |\count#1 = 0|.
%                  Suggested by Chris Rowley.
%
%
% \changes{v1.1v}{1996/07/26}{remove \cs{global} before \cs{@test...}}
%    \begin{macrocode}
\def\@xbitor #1{\@tempcntb \count#1
   \ifnum \@tempcnta =\z@
   \else
     \divide\@tempcntb\@tempcnta
     \ifodd\@tempcntb \@testtrue\fi
   \fi}
%    \end{macrocode}
%
%
% \subsubsection{Definition of float boxes}
%
% 
% \changes{v1.3a}{2015/09/205}
%         {extended \cs{@freelist}}
% \changes{v2.3m}{2025/04/14}{Always use extended free list}
%    \begin{macrocode}
\let\@elt\newinsert
\def\@freelist{%
  \@elt\bx@A\@elt\bx@B\@elt\bx@C\@elt\bx@D\@elt\bx@E
  \@elt\bx@F\@elt\bx@G\@elt\bx@H\@elt\bx@I\@elt\bx@J
  \@elt\bx@K\@elt\bx@L\@elt\bx@M\@elt\bx@N
  \@elt\bx@O\@elt\bx@P\@elt\bx@Q\@elt\bx@R}
\@freelist
\def\reserved@a{%
  \@elt\bx@S\@elt\bx@T\@elt\bx@U\@elt\bx@V
  \@elt\bx@W\@elt\bx@X\@elt\bx@Y\@elt\bx@Z
  \@elt\bx@AA\@elt\bx@BB\@elt\bx@CC\@elt\bx@DD\@elt\bx@EE
  \@elt\bx@FF\@elt\bx@GG\@elt\bx@HH\@elt\bx@II\@elt\bx@JJ
  \@elt\bx@KK\@elt\bx@LL\@elt\bx@MM\@elt\bx@NN
  \@elt\bx@OO\@elt\bx@PP\@elt\bx@QQ\@elt\bx@RR
  \@elt\bx@SS\@elt\bx@TT\@elt\bx@UU\@elt\bx@VV
  \@elt\bx@WW\@elt\bx@XX\@elt\bx@YY\@elt\bx@ZZ}
\reserved@a
\def\@elt{\noexpand\@elt\noexpand}
\edef\@freelist{\@freelist\reserved@a}
\let\reserved@a\relax
\let\@elt\relax
%    \end{macrocode}
%
%    \begin{macrocode}
\gdef\@toplist{}
\gdef\@botlist{}
\gdef\@midlist{}
\gdef\@currlist{}
\gdef\@deferlist{}
\gdef\@dbltoplist{}
%    \end{macrocode}
% \changes{v1.2m}{2015/03/12}
%         {initialise \cs{@dbldeferlist} again}
%    The new algorithm stores page wide floats together with column floats
%    in a single |\@deferlist| list. We keep |\@dbldeferlist|
%    initialised  as empty so that packages that are testing for
%    deferred floats can use the same code for old or new float
%    handling.
%    \begin{macrocode}
\gdef\@dbldeferlist{}
%    \end{macrocode}
%
%
%
% \subsubsection{Page layout parameters}
%
% 
%    \begin{macrocode}
\newdimen\topmargin
\newdimen\oddsidemargin
\newdimen\evensidemargin
\let\@themargin=\oddsidemargin
\newdimen\headheight
\newdimen\headsep
\newdimen\footskip
\newdimen\textheight
\newdimen\textwidth
\newdimen\columnwidth
\newdimen\columnsep
\newdimen\columnseprule
\newdimen\marginparwidth
\newdimen\marginparsep
\newdimen\marginparpush
%    \end{macrocode}
%
% \begin{macro}{\AtBeginDvi}
% \changes{v1.1c}{1994/11/05}
%         {Added macro}
% \begin{macro}{\@begindvibox}
% \changes{v1.1c}{1994/11/05}
%         {Added macro}
% \changes{v1.1f}{1994/11/14}{Use normal box register: why a box?}
% \changes{v1.1l}{1995/04/24}{Add \cs{vbox} latex/1392}
% \changes{v1.4e}{2019/08/27}{Make \cs{AtBeginDvi} robust}
%
%    We use a box register in which to put
%    stuff that must appear before anything else in the
%    |.dvi| file.
%
%    The stuff in the box should not add any typeset material to the
%    page when it is unboxed.
%
%    This interface is no longer used. Instead a new one is inside
%    \texttt{ltshipout.dtx}. We only keep the box in case some old
%    code refers to it directly (or we do some rollback).
% \changes{v1.4f}{2020/08/21}{Integration of new hook management interface}
%    \begin{macrocode}
\newbox\@begindvibox
%\DeclareRobustCommand \AtBeginDvi [1]{%
%  \global \setbox \@begindvibox
%    \vbox{\unvbox \@begindvibox #1}%
%}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%  \begin{macro}{\@maxdepth}
%    This is not the right place to set this; it needs to be set in a
%    class/style file when |\maxdepth| is set.
%
%    Also, many settings to |\maxdepth| should be to |\@maxdepth|,
%    probably?
% \task{All}{Sort out maxdepth: both should be set in the class files.}
%    \begin{macrocode}
\newdimen\@maxdepth
\@maxdepth = \maxdepth
%    \end{macrocode}
%  \end{macro}
% \begin{macro}{\paperheight}
% \changes{v0.1a}{1993/11/23}{Register added}
% \begin{macro}{\paperwidth}
% \changes{v0.1a}{1993/11/23}{Register added}
%    New |\paper|\ldots\ registers.
%    \begin{macrocode}
\newdimen\paperheight
\newdimen\paperwidth
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\stockheight}
% \changes{v1.4j}{2022/08/20}{Register added}
% \begin{macro}{\stockwidth}
% \changes{v1.4j}{2022/08/20}{Register added}
%    New |\stock|\ldots\ registers.
%    \begin{macrocode}
\newdimen\stockheight
\newdimen\stockwidth
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@insert}
% \begin{macro}{\if@fcolmade}
% \begin{macro}{\if@specialpage}
% \begin{macro}{\if@firstcolumn}
% \begin{macro}{\if@twocolumn}
% \begin{macro}{\if@twoside}
% \begin{macro}{\if@reversemargin}
% \begin{macro}{\if@mparswitch}
% \begin{macro}{\col@number}
% \changes{v1.0n}{1994/04/30}{Added \cs{col@number}}
%    Local switches first:
%    \begin{macrocode}
\newif \if@insert
%    \end{macrocode}
%    These should definitely be global:
%    \begin{macrocode}
\newif \if@fcolmade
\newif \if@specialpage \@specialpagefalse
%    \end{macrocode}
%    These should be global but are not always set globally in other
%    files.
%    \begin{macrocode}
\newif \if@firstcolumn \@firstcolumntrue
\newif \if@twocolumn   \@twocolumnfalse
%    \end{macrocode}
%    Not sure about these: two questions.
%    Should things which must apply to a whole document be local or
%    global (they probably should be `preamble only' commands)?
%    Are these three such things?
%    \begin{macrocode}
\newif \if@twoside     \@twosidefalse
\newif \if@reversemargin \@reversemarginfalse
\newif \if@mparswitch  \@mparswitchfalse
%    \end{macrocode}
%    This counter has been imported from `multicol'.
%    \begin{macrocode}
\newcount \col@number
\col@number \@ne
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
%
% \subsubsection{Internal registers}
%
% 
%
%    \begin{macrocode}
\newcount\@topnum
\newdimen\@toproom
\newcount\@dbltopnum
\newdimen\@dbltoproom
\newcount\@botnum
\newdimen\@botroom
\newcount\@colnum
\newdimen\@textmin
\newdimen\@fpmin
\newdimen\@colht
\newdimen\@colroom
\newdimen\@pageht
\newdimen\@pagedp
\newdimen\@mparbottom \@mparbottom\z@
\newcount\@currtype
\newbox\@outputbox
\newbox\@leftcolumn
\newbox\@holdpg
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@thehead{\@oddhead} % initialization
\def\@thefoot{\@oddfoot}
%    \end{macrocode}
%
%
%
%
% \subsubsection{Page break commands}
%
%  \begin{macro}{\clearpage}
% \changes{v1.1r}{1995/10/11}{Added a check so that it does not lose
% the argument of \cs{twocolumn[...]}}
%
% The tests at the beginning are an experimental attempt to avoid a
% completely empty page after a |\twocolumn[...]|.  This prevents the
% text from the argument vanishing into a float box, never to be seen
% again.  We hope that it does not produce wrong formatting in other
% cases.
% \changes{v1.1v}{1996/07/26}{add number of missing percents}
%    \begin{macrocode}
\def\clearpage{%
  \ifvmode
    \ifnum \@dbltopnum =\m@ne
      \ifdim \pagetotal <\topskip
        \hbox{}%
      \fi
    \fi
  \fi
  \newpage
%    \end{macrocode}
%
%    After the above \cs{newpage} there may be some still unwritten
%    \cs{write}'s issued in the output routine and we need to make
%    sure that they are not lost when \cs{@doclearpage} produces float
%    pages. Therefore the following trick is applied: We add a
%    harmless \cs{write} followed by an empty \cs{vbox} and then call
%    the output routine again through a special penalty.  That
%    triggers \cs{@doclearpage} in the OR which splits off a
%    zero-sized chunk from box 255 (which should go up to, but not
%    including, the \cs{vbox}), then \cs{unvbox} that (which should
%    contain any \cs{write}'s, and then throw away the rest of 255
%    (which should just contain the \cs{vbox}).  That explains the
%    strange \cs{write}\texttt{-1\{\}}: that statement introduces a
%    necessary breakpoint so that the split is done before the
%    \cs{vbox}. If it would not be there and \emph{there are no real
%    \cs{write}'s}, then the split would grab the whole of 255 and so
%    would put the \cs{vbox} back on the page and we would end with an
%    extra page only containing that empty \cs{vbox}.
%
%    Deep breath---the above is my (Frank's) attempt of a slightly longer
%    version of Leslie's cryptic comment earlier in the file that
%    this \cs{write} is \enquote{part of a hack to make sure that no
%    \cs{write}'s are lost}.
%  
%    This \cs{write} needs to be non-immediate even if we are
%    supposedly already past the last page because it has to end up on
%    the page sent to the output routine if for some reason that
%    happens.
%  \changes{v1.4p}{2025/03/05}{Make sure this is a normal write in all
%    circumstances}
%    \begin{macrocode}
  \@@write\m@ne{}%
  \vbox{}%
  \penalty -\@Mi
}
%    \end{macrocode}
%
%  \changes{v1.4p}{2025/03/05}{A \LaTeXe{} name for \cs{write} in case
%    it gets changed after the last page}
%    \begin{macrocode}
\let\@@write\write
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\cleardoublepage}
%
%    \begin{macrocode}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
%</2ekernel>
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\onecolumn}
% \changes{v1.0n}{1994/04/30}{Added setting of \cs{col@number}}
%    \begin{macrocode}
%<*2ekernel|fltrace>
\def\onecolumn{%
  \clearpage
  \global\columnwidth\textwidth
  \global\hsize\columnwidth
  \global\linewidth\columnwidth
  \global\@twocolumnfalse
  \col@number \@ne
  \@floatplacement}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\newpage}
% \changes{v1.1x}{1996/09/29}{Checks for noskipsec and inlabel added}
% \changes{v1.1x}{1996/09/29}{Checks for noskipsec and inlabel added}
% \changes{v1.1y}{1996/09/30}{Checks for noskipsec and inlabel removed
%                 pending further tests}
% \changes{v1.1z}{1996/10/24}{Better checks for noskipsec and
%                 inlabel added, plus nobreak}
% \changes{v1.2a}{1996/10/25}{Reset all flags explicitly}
% \changes{v2.4a}{2017/04/11}{account for the depth of the last row of the page}
%    The two checks at the beginning ensure that an item label or
%    run-in section title immediately before a |\newpage| get printed
%    on the correct page, the one before the page break.
%
%    All three tests are largely to make error processing more robust;
%    that is why they all reset the flags explicitly, even when it
%    would appear that this would be done by a |\leavevmode|.
%    \begin{macrocode}
%</2ekernel|fltrace>
%<latexrelease>\IncludeInRelease{2025/06/01}%
%<latexrelease>                 {\newpage}{Check depth of page}%
%<*2ekernel|latexrelease|fltrace>
\def \newpage {%
  \if@noskipsec
    \ifx \@nodocument\relax
      \leavevmode
      \global \@noskipsecfalse
    \fi
  \fi
  \if@inlabel
    \leavevmode
    \global \@inlabelfalse
  \fi
  \if@nobreak \@nobreakfalse \everypar{}\fi
%    \end{macrocode}
%    The |\vfil| at the end of the macro before the break penalty will
%    normally result in the page being run short,  even with |\flushbottom|
%    in effect (in contrast to the behavior
%    of |\pagebreak|). However, if there
%    is some explicit stretch on the page, say, a |\vfill|, it has the undesired
%    side-effect, that the last line will not align at its baseline if it
%    contains characters going below the baseline, as the value of |\prevdepth|
%    is no longer taken into account by \TeX{}. So we have to back up by that amount
%    (or by |\maxdepth| if it is really huge), to mimic the normal behavior
%    without the |\newpage|.
%  
%    In 2017 this was fixed by doing the backing-up here. However, the
%    problem with that is that if the page contains footnotes the
%    \cs{skip}\cs{\footins} is measured from the baseline of the last
%    line and not (as on all other pages) from the bottom of the last
%    line. One can argue that measuring from the baseline is better,
%    but if that is done it should be done everywhere not just on some
%    pages.
%
%    Thus this backing up should only happen when there are no
%    footnotes. The problem is that, at the point when \cs{newpage} is
%    called, it is not known whether or not there are footnotes;
%    that is only determined in the output routine.  We have therefore
%    moved this code to the newly introduced output routine sockets.
%  \changes{v1.4q}{2025/03/20}{Remove skip added in 2.4a (footmisc/19)}
%  
%    An explicit \cs{par} token is required so that after environments
%    like lists \cs{par} is reset to its standard meaning and does not
%    suppress indentation on the next page.
%  \changes{v1.4x}{2025/04/13}{reinserted par token (github/1712)}
%    \begin{macrocode}
   \par
%  \ifdim\prevdepth>\z@
%     \vskip -%
%       \ifdim\prevdepth>\maxdepth
%         \maxdepth
%       \else
%         \prevdepth
%       \fi
%  \fi
  \vfil
  \penalty -\@M}
%</2ekernel|latexrelease|fltrace>
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{2017/04/15}%
%<latexrelease>                 {\newpage}{Check depth of page}%
%<latexrelease>\def \newpage {%
%<latexrelease>  \if@noskipsec
%<latexrelease>    \ifx \@nodocument\relax
%<latexrelease>      \leavevmode
%<latexrelease>      \global \@noskipsecfalse
%<latexrelease>    \fi
%<latexrelease>  \fi
%<latexrelease>  \if@inlabel
%<latexrelease>    \leavevmode
%<latexrelease>    \global \@inlabelfalse
%<latexrelease>  \fi
%<latexrelease>  \if@nobreak \@nobreakfalse \everypar{}\fi
%<latexrelease>  \par
%<latexrelease>  \ifdim\prevdepth>\z@
%<latexrelease>     \vskip -%
%<latexrelease>       \ifdim\prevdepth>\maxdepth
%<latexrelease>         \maxdepth
%<latexrelease>       \else
%<latexrelease>         \prevdepth
%<latexrelease>       \fi
%<latexrelease>  \fi
%<latexrelease>  \vfil
%<latexrelease>  \penalty -\@M}
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\newpage}{Check depth of page}%
%<latexrelease>\def \newpage {%
%<latexrelease>  \if@noskipsec
%<latexrelease>    \ifx \@nodocument\relax
%<latexrelease>      \leavevmode
%<latexrelease>      \global \@noskipsecfalse
%<latexrelease>    \fi
%<latexrelease>  \fi
%<latexrelease>  \if@inlabel
%<latexrelease>    \leavevmode
%<latexrelease>    \global \@inlabelfalse
%<latexrelease>  \fi
%<latexrelease>  \if@nobreak \@nobreakfalse \everypar{}\fi
%<latexrelease>  \par
%<latexrelease>  \vfil
%<latexrelease>  \penalty -\@M}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel|fltrace>
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@emptycol}
% \changes{v1.0n}{1994/04/30}{Empty column action added:
%                 \cs{@emptycol}}
%    It may be better to use an invisible rule rather than an empty
%    box here.
%    \begin{macrocode}
\def \@emptycol {\vbox{}\penalty -\@M}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\twocolumn}
%  \begin{macro}{\@topnewpage}
% \changes{v1.0f}{1993/12/05}{Commands changed}
% \changes{v1.0g}{1993/12/06}{\cs{@floatplacement} placement bug
% fixed}
% \changes{v1.0j}{1993/12/17}{check for vsize too small added}
% \changes{v1.2c}{1997/11/09}{Documentation of vsize check enhanced}
%    There are several bug fixes to the two-column stuff here.
%
% \changes{v1.0n}{1994/04/30}{Added setting of \cs{col@number}}
%    \begin{macrocode}
\def \twocolumn {%
  \clearpage
  \global\columnwidth\textwidth
  \global\advance\columnwidth-\columnsep
  \global\divide\columnwidth\tw@
  \global\hsize\columnwidth
  \global\linewidth\columnwidth
  \global\@twocolumntrue
  \global\@firstcolumntrue
  \col@number \tw@
%    \end{macrocode}
%    There is no reason to put a |\@dblfloatplacement| here since
%    |\@topnewpage| ignores these settings.
%    The |\@floatplacement| is needed in case this comes after some
%    changes.
% \changes{v1.0h}{1993/12/12}{braces removed}
%    \begin{macrocode}
  \@ifnextchar [\@topnewpage\@floatplacement
}
%    \end{macrocode}
%
%    Note that here, getting a box from the freelist can assume
%    success since this comes just after a |\clearpage|.
% \changes{v1.0n}{1994/04/30}{Added setting of \cs{col@number}}
% \changes{v1.1a}{1994/10/31}
%     {(DPC/CAR) Use \cs{color@begingroup} for colour}
% \changes{v1.1a}{1994/10/31}
%     {(DPC/CAR) Use \cs{normalcolor}}
% \changes{v1.1a}{1994/10/31}
%     {(DPC/CAR) Extra box added to remove colour resetting from vmode}
% \changes{v1.1b}{1994/11/05}
%         {Use new \cs{color@hbox} concept.}
% \changes{v1.1i}{1994/11/21}{Changed to \cs{color@vbox}}
% \changes{v1.1z}{1996/10/24}{Added \cs{@nodocument} to trap
%                  \cs{twocolumn} in the preamble}
%    \begin{macrocode}
\long\def \@topnewpage [#1]{%
  \@nodocument
  \@next\@currbox\@freelist{}{}%
  \global \setbox\@currbox
    \color@vbox
      \normalcolor
      \vbox {%
        \hsize\textwidth
        \@parboxrestore
        \col@number \@ne
        #1%
        \vskip -\dbltextfloatsep
             }%
    \color@endbox
%    \end{macrocode}
%    Added size test and warning message; perhaps we should use
%    an error message.
% \changes{v1.0l}{1994/03/15}{Corrected and amended warning message}
% \changes{v1.0m}{1994/04/24}{Warning message removed as it will be
% generated later}
%    \begin{macrocode}
  \ifdim \ht\@currbox>\textheight
    \ht\@currbox \textheight
  \fi
%    \end{macrocode}
%    This next line is not essential but it is more robust to make this
%    value non-zero, in case of weird errors.
%
%    This next bit is what is needed from |\@addtodblcol|, plus some
%    extra checks for error trapping.
%    \begin{macrocode}
  \global \count\@currbox \tw@
  \@tempdima -\ht\@currbox
  \advance \@tempdima -\dbltextfloatsep
  \global \advance \@colht \@tempdima
  \ifx \@dbltoplist \@empty
  \else
    \@latex@error{Float(s) lost}\@ehb
    \let \@dbltoplist \@empty
  \fi
  \@cons \@dbltoplist \@currbox
%    \end{macrocode}
%    This setting of |\@dbltopnum| is used only to change the
%    typesetting in\\ |\@combinedblfloats|.
%    \begin{macrocode}
  \global \@dbltopnum \m@ne
%<*trace>
    \fl@trace{dbltopnum set to -1 (= \the \@dbltopnum) (topnewpage)}%
%</trace>
%    \end{macrocode}
%    At points such as this we need to check that there is still a
%    minimal amount of room left on the page; this uses an arbitrary
%    small value at present; but note that this value is larger than
%    that used when checking that page is too full of normal floats.
%
%    If there is little room left we just force a page-break, OK?
%    This involves producing two empty columns.  The second empty
%    column may be produced by |\output|, in which case an extra,
%    misleading, warning will be generated, OK?  (This happens only
%    when there is too little room left on the page for any float.)
%    Otherwise (\ie if the size is such that it is allowed as a normal
%    float) the extra |\@emptycol| will be invoked in the second
%    column by the conditional code guarded by the |\if@firstcolumn|
%    test.
%
%    I now think that the cut-off point here should be |3\baselineskip|,
%    but we make it a bit less so that 3 lines of text will be
%    allowed, OK?
%
%    Since this happens only when there is nothing on the page but the
%    `top-box', the empty box should not cause any problem other than
%    some overfull box messages, which is not entirely misleading.
%
%    Here we need two page-ends since both columns need to be empty.
% \task{???}{Make it less arbitrary?}
% \changes{v1.0j}{1993/12/17}{Page room test added}
% \changes{v1.0l}{1994/03/15}{Warning added: it should be improved}
% \changes{v1.0m}{1994/04/24}{Message changed to give more info}
% \changes{v1.0n}{1994/04/30}{Message changed for Frank}
% \changes{v1.0n}{1994/04/30}{Empty column action added:
% \cs{@emptycol}}
% \changes{v1.0n}{1994/04/30}{Cut-off point changed to
% 3\cs{baselineskip}}
% \changes{v1.1t}{1996/05/24}{Cut-off point changed to
% 2.5\cs{baselineskip}}
%    \begin{macrocode}
  \ifdim \@colht<2.5\baselineskip
    \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
                too tall on page \thepage}%
    \@emptycol
    \if@firstcolumn
    \else
      \@emptycol
    \fi
  \else
    \global \vsize \@colht
    \global \@colroom \@colht
    \@floatplacement
  \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
%
% \section{The \LaTeX{} output routine}
%
% \subsection{Hooks and replaceable code blocks}
%
%    To support packages that want to augment aspects of the output
%    routine we offer a number of hooks (where several packages can
%    add code) as well as some sockets (that can only be changed by
%    one package or through options like those of the \pkg{footmisc}
%    package).
%
%
% \subsubsection{Output routine hooks}
%
%    \begin{description}
%
%    \item[\hook{build/page/before}, \hook{build/page/after}]
%       These two hooks enable packages to prepend or append code to
%       the page processing in the output routine. They are
%       implemented as mirrored hooks.
%
%       Technically, they are executed at the start and the end of the internal
%       \LaTeXe{} \cs{@outputpage} command, respectively.
%
%
%    \item[\hook{build/page/reset}]
%       Packages that set up special conventions for text in the main
%       galley (such as catcode changes, etc.)\ can use this hook to
%       undo these changes within the output routine, so that they
%       aren't applied to unrelated material, e.g., the text for
%       running header or footers.
%
%    \item[\hook{build/column/before}, \hook{build/column/after}]
%       These two hooks enable packages to prepend or append code to
%       the column processing in the output routine. They are
%       implemented as mirrored hooks.
%
%       Technically, they are executed at the start and the end of the internal
%       \LaTeXe{} \cs{@makecol} command, respectively.
%       
%    \end{description}
%
% \subsubsection{Replaceable code blocks (sockets)}
%
%    To cater for different layouts with respect to text, footnotes,
%    and bottom-floats placements there are  sockets for
%    now. They are sockets not hooks, because the overall layout can only be
%    controlled by one package, i.e., the last setting wins.
%
%    \begin{description}
%    \item[\socket{build/column/outputbox} (0 arguments)]
%
%      In code for this socket the \cs{@outputbox} (holding the
%      galley text for the current column or page) is augmented by
%      attaching floats and footnote areas together with appropriate
%      spacing.
%
%      Prior to calling the socket the output routine has already
%      decided which floats go into which area and which get deferred.
%      Therefore, the assumption is that the code in the socket attaches all
%      areas that contain floats. If this is not done, then the order
%      of floats is likely to be screwed up unless unused floats
%      are moved to the defer list in an appropriate way (for now we
%      don't offer any interface for that scenario). 
%
%      Before the code in the socket is run, any existing glue at the bottom
%      of the \cs{@outputbox} is removed and stored in a safe
%      place. If needed, it can be reinserted with one of the helper
%      commands.
%
%      To support setting this up the following helper commands are available:
%      \begin{description}
%      \item[\cs{@outputbox@append} (1 argument)]
%
%        \DescribeMacro[noprint]{@outputbox@append}
%
%        This general purpose command alters the \cs{@outputbox} box by
%        appending material to it.
%
%      \item[\cs{@outputbox@appendfil} (0 arguments)]
%
%        Append a \cs{vfil} to the \cs{@outputbox}. Based on the plug
%        in \socket{build/column/baselineattach} either measured from
%        the bottom or from the baseline of the last line in the box.
%
%      \item[\cs{@outputbox@appendfootnotes} (0 arguments)]
%
%        \DescribeMacro[noprint]{@outputbox@appendfootnotes}
%
%        This command appends the footnotes to the \cs{@outputbox} (if
%        there are any). If not, then it does nothing.
%
%      \item[\cs{@outputbox@attachfloats} (0 arguments)]
%      \item[\cs{@outputbox@attachtopfloats} (0 arguments)]
%      \item[\cs{@outputbox@attachbottomfloats} (0 arguments)]
%
%        \DescribeMacro[noprint]{@outputbox@attachfloats}
%        \DescribeMacro[noprint]{@outputbox@attachtopfloats}
%        \DescribeMacro[noprint]{@outputbox@attachbottomfloats}
%   
%        Attaching top and bottom floats can usually be done in one
%        go, but for special layouts we might want more control so we
%        provide also separate commands.
%
%      \item[\cs{@outputbox@reinsertbskip} (0 arguments)]
%
%        \DescribeMacro[noprint]{@outputbox@reinsertbskip}
%
%        Reinsert the bottom skip of the \cs{@outputbox} that was
%        saved before in \cs{@makecol}.   
%   
%      \item[Testing for existence of material]
%
%        \DescribeMacro[noprint]{@if@footnotes@TF}
%        \DescribeMacro[noprint]{@if@bottomfloats@TF}
%
%        There are a number of helpers to run conditional code
%        depending on whether or not there are footnotes or bottom
%        floats. They are \cs{@if@footnotes@TF} and
%        \cs{@if@bottomfloats@TF}
%        (names are likely to change).
%   
%      \end{description}
%
%      \task{fmi}{Decide on names for these helper commands. We could keep
%        them similar to the above (because they are only supposed to be
%        used by a few packages). However, we could alternatively use
%        CamelCase names, under the assumption that classes may also
%        directly define a plug for the socket, instead of loading a
%        support package such as \pkg{footmisc} (or in addition
%        to). --- decide}
%      
%      This socket cannot be empty but needs appropriate code; a set
%      of suitable plugs for it are already given in the kernel. These
%      are
%      \begin{description}
%      \item[\plug{space-footnotes-floats}]
%
%         After the galley text there is a vertical \cs{vfil}
%         followed by any footnotes followed by the bottom floats, if any.
%
%      \item[\plug{footnotes-space-floats}]
%
%         As before but the \cs{vfil} is between footnotes and floats.
%
%      \item[\plug{floats-space-footnotes}]
%
%         Floats are directly after the text, then a space and then
%         footnotes at the bottom.
%
%      \item[\plug{space-floats-footnotes}]
%
%         Both floats and footnotes are pushed to the bottom with
%         footnotes last.\footnote{There are two more permutations,
%         but neither of them has ever been requested so they aren't
%         set up by default --- doing that in a class would be trivial
%         though.}
%
%      \item[\plug{floats-footnotes}]
%
%         All excess space is distributed across the existing
%         glue on the page, e.g., within the text galley, the
%         separation between blocks, etc.
%         The order is text, floats, footnotes.
%
%      \item[\plug{footnotes-floats}]
%
%         As the previous one but floats and footnotes are
%         swapped. This is the \LaTeX{} default for newer document,
%         i.e., this plug is assigned to the socket when
%         \cs{DocumentMetadata} is used.
%
%      \item[\plug{footnotes-floats-legacy}]
%
%         As the previous one but \LaTeX{}'s bottom skip bug is not
%         corrected, i.e., in ragged bottom designs where footnotes
%         are supposed to be directly attached to the text, they suddenly
%         appear at the bottom of the page when the page is ended with
%         \cs{newpage} or \cs{clearpage}.
%         While this is clearly a bug, it was the case since the days
%         of \LaTeX~2.09; thus for
%         compatibility we continue to support this behavior.
%
%      \end{description}
%
%
%    \item[\socket{build/column/footnotes} (0 arguments)]
%
%       This socket is used to manipulate the footnote
%        material inside \cs{box}\cs{footins}. It if contains code, it
%        is supposed to do some processing of that box and then write
%        the result back into it (and nothing else!). By default it
%        does nothing, i.e., has the \plug{noop} assigned.
%
%       If (short) footnotes are run as a paragraph this socket gets
%         the plug \plug{para} assigned which is defined elsewhere. 
%
%    \item[\socket{build/column/baselineattach} (0 arguments)]
%
%       By default, footnotes are attached after the last line of text
%       by adding a \cs{vskip}\cs{skip}\cs{footins}, i.e., the space
%       is measured from the bottom of \cs{@outputbox} (plug
%       \plug{off}).  Bottom floats are attached in a similar way by
%       using \cs{vskip}\cs{textfloatsep}.
%
%       The socket can get the plug \plug{on} assigned, in which case
%       the skip starts at the baseline of the last line in
%       \cs{@outputbox}, if there is one; otherwise it starts still
%       from the bottom of the box.
%
%    \end{description}
%
% \subsubsection{Tagging sockets}
%
%  The following sockets are used to implement tagging. They are used
%  via \cs{UseTaggingSocket} which turns them off when tagging is
%  disabled.
%  For each of them a \plug{default} plug is implemented that holds the tagging code.
%
%    \begin{description}
%
%    \item[\socket{build/column/outputbox} (0 arguments)]
%       This socket is used to add any missing tagging structures to the
%       \cs{@outputbox} box, if necessary.
%
%    \item[\socket{build/column/footins} (0 arguments)]
%       This socket is used to add any missing tagging structures to
%       \cs{footins} box, if necessary.
%
%    \item[\socket{build/page/header} (2 arguments)]
%
%       This socket receives the content of the formatted page header
%       as its second argument and adds the necessary tagging around
%       it. The first argument is empty as no special setup is
%       necessary.
%
%    \item[\socket{build/page/footer} (2 arguments)]
%
%       This socket receives the content of the formatted page footer
%       as its second argument and adds the necessary tagging around
%       it. The first argument is empty as no special setup is
%       necessary.
%
%    \end{description}
%
%
%
%
%
% \subsubsection{Output routine commands}
%
%
%
%
%  \begin{macro}{\output}
% \changes{v1.0f}{1993/12/05}{Command changed}
%  \begin{macro}{\@specialoutput}
% \changes{v0.1c}{1993/11/23}{Command changed}
% \changes{v1.0f}{1993/12/06}{Unboxing of 255 added to rescue writes}
%    This needs some small adjustments.  We cannot
%    guarantee that the float mechanism will interact correctly with
%    this stuff, but that mechanism does not always work properly
%    with footnotes already.
%
%    RmS 91/09/29:
%
%    added reset of |\par| to the output routine.
%    This avoids problems when the output routine is
%    called within a list where |\par| may be a no-op.
%
%    \begin{macrocode}
\output {%
  \let \par \@@par
  \ifnum \outputpenalty<-\@M
    \@specialoutput
  \else
    \@makecol
    \@opcol
%    \end{macrocode}
%    Moved to |\@opcol|: |\@floatplacement|.
%    \begin{macrocode}
    \@startcolumn
%    \end{macrocode}
%    This loop could be replaced by an |\expandafter| tail
%    recursion in |\@startcolumn|.
%    \begin{macrocode}
    \@whilesw \if@fcolmade \fi
      {%
%<*trace>
       \fl@trace{PAGE: float \if@twocolumn column \else page \fi
                    completed}%
%</trace>
       \@opcol\@startcolumn}%
  \fi
  \ifnum \outputpenalty>-\@Miv
%    \end{macrocode}
%    At points such as this we need to check that there is still a
%    minimal amount of room left on the page; this uses an arbitrary
%    small value at present.  If there is little room left we just
%    force a page-break, OK?
%
%    This bit is essential only if a float has just been processed so
%    maybe it should be moved; but this is the natural place at which
%    to set the vsize and a test would need to be done anyway.  A
%    check has been added to ensure that there really has been a
%    change in the value of |\@colroom|.
%
%    Since this happens only when there is nothing on the page but
%    floats, the empty box should not cause any problem other than
%    some overfull box messages, which is not entirely misleading.
%
%    The twocolumn case does not need any extra code here since this
%    is the |\output| itself; in the second column there will still
%    not be enough room left so |\@emptycol| will be executed again
%    when the OR is called by the-page builder when it gets to the
%    penalty inserted by the first execution.  (The page-builder is
%    never invoked whilst the OR is being executed since it builds a
%    inner vlist; thus any conditional code for the two-column case
%    within |\output| may not get executed with the correct value of
%    |\if@firstcolumn|.
%
% \task{???}{Make it less arbitrary?}
% \changes{v1.0j}{1993/12/17}{Page room test added}
% \changes{v1.0m}{1994/04/24}{Message changed to give more info and
% `top' removed}
% \changes{v1.0n}{1994/04/30}{Extra empty column added for
% twocolumn case (wrong, see below)}
% \changes{v1.0n}{1994/04/30}{Extra empty column added for
% twocolumn case}
% \changes{v1.0n}{1994/04/30}{Empty column action added:
% \cs{@emptycol}}
% \changes{v1.0n}{1994/04/30}{Cut-off point changed to
% 2\cs{baselineskip}}
% \changes{v1.1t}{1996/05/24}{Cut-off point changed to
% 1.5\cs{baselineskip}}
% \changes{v1.1t}{1996/05/24}{Check that \cs{@colroom} is less
% than \cs{vsize}, indicating that a float has been added}
% \changes{v1.1u}{1996/05/25}{Correct the above check}
% \changes{v1.2c}{1997/11/09}{Remove incorrect code: only one
% \cs{@emptycol} is needed here}
%    \begin{macrocode}
    \ifdim \@colroom<1.5\baselineskip
      \ifdim \@colroom<\textheight
        \@latex@warning@no@line {Text page \thepage\space
                               contains only floats}%
        \@emptycol
%         \if@twocolumn
%           \if@firstcolumn
%           \else
%             \@emptycol
%           \fi
%         \fi
      \else
        \global \vsize \@colroom
      \fi
    \else
      \global \vsize \@colroom
    \fi
  \else
    \global \vsize \maxdimen
  \fi
}
%    \end{macrocode}
%
% \begin{oldcomments}
% CHANGES TO \@specialoutput:
% * \penalty\z@ changed to \penalty\interlinepenalty so \samepage
%   works properly with figure and table environments.
%   (Changed 23 Oct 86)
%
% * Definition of \@specialoutput changed 26 Feb 88 so \@pageht and
%   \@pagedp aren't changed for a marginal note.
%   (Change suggested by Chris Rowley.)
% \end{oldcomments}
%
%    \begin{macrocode}
\gdef\@specialoutput{%
   \ifnum \outputpenalty>-\@Mii
     \@doclearpage
   \else
     \ifnum \outputpenalty<-\@Miii
       \ifnum \outputpenalty<-\@MM \deadcycles \z@ \fi
       \global \setbox\@holdpg \vbox {\unvbox\@cclv}%
     \else
%    \end{macrocode}
%    Note that |\boxmaxdepth| should not be set here since we wish to
%    record the natural depth of the holdpg box.
%
%    This is changed so as to not lose anything, such as writes
%    and marks, which may get into box 255 and should be returned to
%    the list.  This should only happen when the first penalty in the
%    mechanism is discarded and therefore |\@holdpg| should always be
%    void in this case.  This can happen because a penalty is
%    discarded whenever there is no box on the list.
%
%    It was just: |\setbox\@tempboxa \box \@cclv|.
%
%    The last box which is removed is the box put there by the
%    double-penalty mechanism.  The |\unskip| then removes the
%    |\topskip| which is put there since the box is the first on the
%    page.
% \task{CAR/FMi}{Is it more efficient to check whether the holdpg box
% is void and then act accordingly?}
%    \begin{macrocode}
       \global \setbox\@holdpg \vbox{%
                      \unvbox\@holdpg
                      \unvbox\@cclv
%    \end{macrocode}
%    We must now remove the box added by the float mechanism and the
%    |\topskip| glue therefore added above it by \TeX.
%    \begin{macrocode}
                      \setbox\@tempboxa \lastbox
                      \unskip
                                     }%
%    \end{macrocode}
%    These two are needed as separate dimensions only by
%    |\@addmarginpar|; for other purposes we put the whole size into
%    |\@pageht| (see below).
%    \begin{macrocode}
       \@pagedp \dp\@holdpg
       \@pageht \ht\@holdpg
       \unvbox \@holdpg
       \@next\@currbox\@currlist{%
         \ifnum \count\@currbox>\z@
%    \end{macrocode}
%    Putting the whole size into |\@pageht| (see above).
%    \begin{macrocode}
           \advance \@pageht \@pagedp
           \ifvoid\footins \else
             \advance \@pageht \ht\footins
             \advance \@pageht \skip\footins
             \advance \@pageht \dp\footins
           \fi
           \ifvbox \@kludgeins
%    \end{macrocode}
%    We want to make the adjustment due to this insert only if the
%    non-star form is used.  The *-form will probably not work with
%    floats, but maybe it still could make some adjustment here even
%    so?
%    \begin{macrocode}
             \ifdim \wd\@kludgeins=\z@
               \advance \@pageht \ht\@kludgeins
%<*trace>
               \fl@trace {Extra size added: \the \ht\@kludgeins}%
%</trace>
             \fi
           \fi
%    \end{macrocode}
%    This version puts the inserts back just before the additional
%    material; it could be moved earlier, before unboxing the
%    page-so-far.  Neither is guaranteed not to put things on the wrong
%    page.  This version is similar to the original version.
%    \begin{macrocode}
           \@reinserts
           \@addtocurcol
         \else
           \@reinserts
           \@addmarginpar
         \fi
         }\@latexbug
%    \end{macrocode}
%    A 2e change: use |\addpenalty| instead of |\penalty| here.  Some
%    penalty is needed to create a potential break-point immediately
%    after the reinserts (or the marginal).  Otherwise there can be no
%    possibility to break here and this can cause the reinserts or the
%    marginal to appear on the next page (which is often incorrect).
%    However, if the nobreak flag is true, a |\nobreak| must be
%    correct.
% \changes{v1.1i}{1994/11/21}{Added \cs{if@nobreak} test}
% \changes{v1.1z}{1996/10/24}{Added \cs{nobreak} as appropriate}
%    \begin{macrocode}
       \ifnum \outputpenalty<\z@
         \if@nobreak
           \nobreak
         \else
           \addpenalty \interlinepenalty
         \fi
       \fi
     \fi
   \fi
}
%</2ekernel|fltrace>
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\@testwrongwidth}
% \begin{macro}{\f@depth}
% \changes{v1.2n}{2015/02/21}{macro added(latexrelease)}
%
% Test if the float box has the wrong width when trying to place it
% into some area. (Actually
% the test is for a conventional depth setting rather than for the
% width of the float. For that reason the box depth was explicitly
%   tailored when the float was created).
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{2015/01/01}%
%<latexrelease>                 {\@testwrongwidth}{float order in 2-column}%
%<*2ekernel|latexrelease|fltrace>
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@testwrongwidth #1{%
  \ifdim\dp#1=\f@depth
%<*trace>
    \fl@trace{\string#1
              \ifdim\f@depth=\z@ single \else double \fi
              column float -- ok}%
%</trace>
  \else
    \global\@testtrue
%<*trace>
    \fl@trace{\string#1
              \ifdim\f@depth=\z@ double \else single \fi
              column float -- wrong}%
%</trace>
  \fi}%
%    \end{macrocode}
%
% Normally looking for single column floats, which have zero depth.
%    \begin{macrocode}
\let\f@depth\z@
%    \end{macrocode}
%
%    \begin{macrocode}
%</2ekernel|latexrelease|fltrace>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\@testwrongwidth}{float order in 2-column}%
%<latexrelease>\let\@testwrongwidth\@undefined
%<latexrelease>\let\f@depth\@undefined
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%  \begin{macro}{\@doclearpage}
%  \task{CAR/FMi}{Investigate better float clearance}
%  \task{CAR/FMi}{Put non-boxes back in the `right place', or nowhere?}
%    This is a very much an emergency action, just dumping everything:
%    footnotes first then floats.  A more sophisticated version is
%    needed; but even more urgent is a bug-free version (see, for
%    example, pr/3528).
%
%    Also, it puts any left-over non-boxes (writes, specials, etc.) back
%    after any float pages created: this is a very bad bug since,
%    for example, a kludge insert will be in quite the wrong place
%    and, worse, be irremovable and uncancelable.
%
% \changes{v1.2n}{2015/01/14}{float order in 2-column (latexrelease)}
% All the remaining changes are replacing the double column defer list
% or inserting the extra test |\@testwrongwidth|\marg{box} at suitable
% places. That is at places where a box is taken off the deferlist.
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{2015/01/01}{\@doclearpage}%
%<latexrelease>                             {float order in 2-column}%
%<*2ekernel|latexrelease>
\def \@doclearpage {%
     \ifvoid\footins
%    \end{macrocode}
% \changes{v1.2n}{2015/01/14}{Empty kludgeins box if necessary, pr/3528}
%    \begin{macrocode}
       \ifvbox\@kludgeins
         {\setbox \@tempboxa \box \@kludgeins}%
%<*trace>
         \fl@trace {kludgeins box made void}%
%</trace>
       \fi
       \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
       \setbox\@tempboxa\box\@cclv
       \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
       \global \let \@toplist \@empty
       \global \let \@botlist \@empty
       \global \@colroom \@colht
       \ifx \@currlist\@empty
       \else
          \@latex@error{Float(s) lost}\@ehb
          \global \let \@currlist \@empty
       \fi
       \@makefcolumn\@deferlist
       \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
       \if@twocolumn
         \if@firstcolumn
%    \end{macrocode}
%
%    \begin{macrocode}
           \xdef\@deferlist{\@dbltoplist\@deferlist}%
%    \end{macrocode}
%
%    \begin{macrocode}
           \global \let \@dbltoplist \@empty
           \global \@colht \textheight
           \begingroup
              \@dblfloatplacement
%    \end{macrocode}
%
%    \begin{macrocode}
              \@makefcolumn\@deferlist
              \@whilesw\if@fcolmade \fi{\@outputpage
                                        \@makefcolumn\@deferlist}%
%    \end{macrocode}
%
%    \begin{macrocode}
           \endgroup
         \else
           \vbox{}\clearpage
         \fi
       \fi
%    \end{macrocode}
%    the next line is needed to avoid losing floats in certain
%    circumstances a single call to the original |\doclearpage|
%    will now no longer output all floats.
% \changes{v1.2b}{2000/09/24}{FMi: ensure \cs{doclearpage}
%     is called again until all floats are output.}
%    \begin{macrocode}
       \ifx\@deferlist\@empty \else\clearpage \fi
     \else
       \setbox\@cclv\vbox{\box\@cclv\vfil}%
       \@makecol\@opcol
       \clearpage
     \fi
}%
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}{\@doclearpage}%
%<latexrelease>                             {float order in 2-column}%
%<latexrelease>\def \@doclearpage {%
%<latexrelease>     \ifvoid\footins
%    \end{macrocode}
% \changes{v1.2l}{2004/02/07}{Empty kludgeins box if necessary, pr/3528}
%    We empty any left over kludge insert box here; this is a temporary fix.
%    It should perhaps be applied to one page of cleared floats, but
%    who cares?  The whole of this stuff needs completely redoing for
%    many such reasons.
%    \begin{macrocode}
%<latexrelease>       \ifvbox\@kludgeins
%<latexrelease>         {\setbox \@tempboxa \box \@kludgeins}%
%<*trace>
%<latexrelease>         \fl@trace {kludgeins box made void}%
%</trace>
%<latexrelease>       \fi
%<latexrelease>       \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
%<latexrelease>       \setbox\@tempboxa\box\@cclv
%<latexrelease>       \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
%    \end{macrocode}
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
%    \begin{macrocode}
%<latexrelease>       \global \let \@toplist \@empty
%<latexrelease>       \global \let \@botlist \@empty
%<latexrelease>       \global \@colroom \@colht
%<latexrelease>       \ifx \@currlist\@empty
%<latexrelease>       \else
%<latexrelease>          \@latexerr{Float(s) lost}\@ehb
%    \end{macrocode}
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
%    \begin{macrocode}
%<latexrelease>          \global \let \@currlist \@empty
%<latexrelease>       \fi
%<latexrelease>       \@makefcolumn\@deferlist
%<latexrelease>       \@whilesw\if@fcolmade \fi
%<latexrelease>                     {\@opcol\@makefcolumn\@deferlist}%
%<latexrelease>       \if@twocolumn
%<latexrelease>         \if@firstcolumn
%<latexrelease>           \xdef\@dbldeferlist{\@dbltoplist\@dbldeferlist}%
%    \end{macrocode}
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
%    \begin{macrocode}
%<latexrelease>           \global \let \@dbltoplist \@empty
%<latexrelease>           \global \@colht \textheight
%<latexrelease>           \begingroup
%<latexrelease>              \@dblfloatplacement
%<latexrelease>              \@makefcolumn\@dbldeferlist
%<latexrelease>              \@whilesw\if@fcolmade \fi
%<latexrelease>                    {\@outputpage\@makefcolumn\@dbldeferlist}%
%<latexrelease>           \endgroup
%<latexrelease>         \else
%<latexrelease>           \vbox{}\clearpage
%<latexrelease>         \fi
%<latexrelease>       \fi
%<latexrelease>     \else
%<latexrelease>       \setbox\@cclv\vbox{\box\@cclv\vfil}%
%<latexrelease>       \@makecol\@opcol
%<latexrelease>       \clearpage
%<latexrelease>     \fi
%<latexrelease>  }%
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\@opcol}
% \changes{v1.0f}{1993/12/05}{Command changed}
% \changes{v1.0f}{1993/12/05}{Hook added}
% \changes{v1.0j}{1993/12/17}{Hook removed}
%    Several changes in detail here.
%
%    \begin{macrocode}
%<*2ekernel|fltrace>
\def \@opcol {%
  \if@twocolumn
%    \end{macrocode}
% \changes{v1.ih}{2022/04/03}{Interface with new mark mechanism}
%    The funny-looking internal commands are interfacing with the new
%    marks mechanism. We make sure (elsewhere) that those are always
%    defined, even when we roll back, so here we add them
%    unconditionally. This still need turning into a hook or config
%    point eventually:
%    \begin{macrocode}
    \@expl@@@mark@update@dblcol@structures@@
    \@outputdblcol
  \else
    \@expl@@@mark@update@singlecol@structures@@ 
    \@outputpage
%<*trace>
    \fl@trace{PAGE: one column (float? see above) page completed}%
%</trace>
%    \end{macrocode}
%    Not needed since it comes after |\@outputpage|:
%    \begin{macrocode}
%   \global\@colht\textheight
  \fi
%    \end{macrocode}
%    These do not need to be done every time |\@opcol| is used: they
%    should be grouped together since they all need to be done at the
%    end of the non-special output routine, or at the end of a clearpage
%    one.
%    \begin{macrocode}
  \global \@mparbottom \z@ \global \@textfloatsheight \z@
  \@floatplacement
}
%</2ekernel|fltrace>
%    \end{macrocode}
%  \end{macro}
%
%
%    \begin{macrocode}
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2025/06/01}%
%<latexrelease>   {\@makecol}{\@makecol adding hooks/sockets}%
%    \end{macrocode}
%
%  \begin{macro}{\@makecol}
% \changes{v0.1c}{1993/11/23}{Command changed}
% \changes{v1.0b}{1993/11/29}{\cs{@makespecialcolbox} added}
% \changes{v1.4m}{2025/02/14}{Use sockets and hooks}
%
%    \cs{@makecol} is shortened a lot, basically all the hardwired
%    code in the middle has moved into a socket.
%    \begin{macrocode}
\def \@makecol {%
%    \end{macrocode}
%    A number of packages want to prepend code to \cs{@makecol}; this
%    is the hook for that:
%    \begin{macrocode}
  \UseHook {build/column/before}%
%    \end{macrocode}
%    Save away box 255 as \cs{@outputbox} to make it available for further adjustments.
%    \begin{macrocode}
  \setbox\@outputbox \box\@cclv
%    \end{macrocode}
%    The only real addition is the next command which either does
%    nothing or removes an infinite glue from the bottom of the
%    \cs{@outputbox}.
%    \begin{macrocode}
  \@outputbox@removebskip
%    \end{macrocode}
%    Now a kernel hook for tagging that adjusts the content of
%    \cs{@outputbox}, if necessary. At this point it just contains the material from
%    the galley.
%    \begin{macrocode}
  \UseTaggingSocket{build/column/outputbox}%
%    \end{macrocode}
%    When this code is run any ``here'' floats in the \cs{@outputbox}
%    are already handled, so we recycle their registers and put them
%    back to the \cs{@freelist}.
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
% \changes{v1.2k}{2003/12/16}{Ensure that \cs{@elt} has a defined
%                             state (pr/3586)}
%    \begin{macrocode}
  \let\@elt\relax
  \xdef\@freelist{\@freelist\@midlist}%
  \global \let \@midlist \@empty
%    \end{macrocode}
%    Here we have the configurable part. This socket is supposed to
%    add floats, footnotes and stretchable vertical space as
%    appropriate to the \cs{@outputbox}. It is used by packages such
%    as \pkg{footmisc} to implement different layout, e.g., footnotes
%    above or below bottom floats, etc.
%    \begin{macrocode}
  \UseSocket {build/column/outputbox}%
%    \end{macrocode}
%    Then we deal with any \cs{enlargethispage} or run the normal code
%    to build a column.
%    \begin{macrocode}
  \ifvbox\@kludgeins
     \@make@specialcolbox
  \else
     \@make@normalcolbox
  \fi
  \global \maxdepth \@maxdepth
%    \end{macrocode}
%    Finally, another hook for external packages or classes that want
%    to augment or alter the output routine by appending to \cs{@makecol}.
%    \begin{macrocode}
  \UseHook {build/column/after}%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@outputbox@depth}
% \changes{v1.4m}{2025/02/14}{Macro added}
%    We need to know the depth of \cs{@outputbox} once in a
%    while. Rather than using a temp dimen (as it was done in the
%    past), we give it a proper register.
%
%    The value of this register is only correct inside of
%    \cs{outputbox@append}, elsewhere you can't rely on it!
%    \begin{macrocode}
\newdimen\@outputbox@depth
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@make@normalcolbox}
% \changes{v1.4m}{2025/02/14}{Macro added}
%    Taken out of \cs{@makecol} for readability.
%
% \changes{v1.0l}{1994/03/15}{Removed boxmaxdepth setting.}
%    \begin{macrocode}
\def \@make@normalcolbox {%
   \setbox\@outputbox \vbox to\@colht {%
       \@texttop
       \@outputbox@depth \dp\@outputbox
       \unvbox \@outputbox
%    \end{macrocode}
%    The |\vskip -\@outputbox@depth@| ensures that the visible depth
%    of the box does not affect the placement of anything on the page.
%    Thus very deep pages will overprint the footer; but these should
%    have been prevented by suitable settings of the maxdepths at
%    appropriate times.
%
%    If |\@textbottom| ends with a box or rule of non-zero depth then
%    this skip adjustment should be done again after it.
%    \begin{macrocode}
       \vskip -\@outputbox@depth
       \@textbottom
      }%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@make@specialcolbox}
% \changes{v1.4m}{2025/02/14}{Macro added}
%    Make the colbox when \cs{enlargethispage} was used.
%    \begin{macrocode}
%</2ekernel|latexrelease>
%<*2ekernel|latexrelease|fltrace>
\def \@make@specialcolbox {%
%<*trace>
   \fl@trace{Kludgeins ht \the\ht\@kludgeins\space
                           dp \the\dp\@kludgeins\space
                           wd \the\wd\@kludgeins}%
%</trace>
   \@outputbox@append {\vskip-\@outputbox@depth}%
   \@tempdima \@colht
%    \end{macrocode}
%
%    \begin{macrocode}
   \ifdim \wd\@kludgeins>\z@
%    \end{macrocode}
%    Note that in this case (the *-version), the height of the
%    |\@kludgeins| box is not used since its value is somewhat
%    arbitrary: it need only be big enough to ensure that the
%    page-break is not taken prematurely.
%
%    Here we calculate how much vertical space needs to be added in
%    order to enable the column to fit into a box of size |\@colht|
%    using the best information we have about the amount of shrink
%    available (another thing which is known internally about a box,
%    but cannot be accessed at the \TeX{} level!).
%
%    This needs \TeX3 otherwise |\pageshrink| is zero anyway; it may
%    not be exactly the figure we wish as it is the total available
%    from the all the material collected before the page-break
%    decision is made.  It will, we think, always be an overestimate
%    of the actual shrink in the box; therefore this should always
%    force the shortest possible column with the possibility of an
%    overfull box.
%
%    This should work for both flush- and ragged-bottom setting since
%    it makes the contents no smaller than the size (|\@colht|) of the
%    box into which they are put.
%
%    Their should perhaps be an upper limit, of 0pt?, on the extra
%    space added to force shrinking.
%    \task{CAR}{Further investigation of kludge-* space}
%
%    \begin{macrocode}
     \advance \@tempdima -\ht\@outputbox
     \advance \@tempdima \pageshrink
%<*trace>
     \fl@trace {Natural ht of col: \the \ht\@outputbox}%
     \fl@trace {\string \@colht: \the \@colht}%
     \fl@trace {Pageshrink added: \the \pageshrink}%
     \fl@trace {Hence, space added: \the \@tempdima}%
%</trace>
     \setbox\@outputbox \vbox to \@colht {%
       \unvbox\@outputbox
       \vskip \@tempdima
       \@textbottom
       }%
%    \end{macrocode}
%    For the unstarred version, the final size of the page is
%    precisely specified.  Therefore, at least for the flush-bottom
%    case, we need to ensure that, visually, it has this size exactly.
%
%    Thus we calculate this size and set the material in a box of this
%    size, which is then put into a box of size |\@colht| with |\vss|
%    at the bottom.
%    \begin{macrocode}
   \else
     \advance \@tempdima -\ht\@kludgeins
%<*trace>
     \fl@trace {Natural ht of col: \the \ht\@outputbox}%
     \fl@trace {\string \@colht: \the \@colht}%
     \fl@trace {Extra size added: -\the \ht \@kludgeins}%
     \fl@trace {Hence, height of inner box: \the \@tempdima}%
     \fl@trace {Max? pageshrink available: \the \pageshrink}%
%</trace>
%    \end{macrocode}
%    This type of final packaging could be done always; this may
%    simplify all of this page-makeup.
%
%    It is not necessary to set |\boxmaxdepth| here since the
%    |\@outputbox| ends with glue.
% \changes{v1.0k}{1994/02/03}{correct mistakes in the documentation}
%    \begin{macrocode}
     \setbox \@outputbox \vbox to \@colht {%
       \vbox to \@tempdima {%
         \unvbox\@outputbox
         \@textbottom}%
       \vss}%
   \fi
   {\setbox \@tempboxa \box \@kludgeins}%
%<*trace>
     \fl@trace {kludgeins box made void}%
%</trace>
}
%</2ekernel|latexrelease|fltrace>
%<*2ekernel|latexrelease>
%    \end{macrocode}
%  \end{macro}
%
%    
%
%
%  \begin{macro}{\@outputbox@removebskip}
% \changes{v1.4m}{2025/02/14}{Macro added}
% \changes{v1.4m}{2025/02/14}{Finally fix bottom skip bug (from 2.09)}
%
%    This is really a bug fix for the kernel (from the 2.09 days) but
%    one we only make by default in new documents that are using
%    \cs{DocumentMetadata}.  If \cs{raggedbottom} is in force,
%    footnotes get attached to the main galley at a distance of
%    \cs{footskip} on all pages except on those that are ended by
%    \cs{newpage} or \cs{clearpage} where the \cs{vfil} from
%    \cs{newpage} pushes the footnotes to the very bottom.
%
%    This is kind of a weird difference to a page  ending with
%    \cs{pagebreak}---in that case the page is also run
%    short, but the footnotes are not pushed to the bottom.
%
%    In \pkg{footmisc} \cs{@outputbox@removebskip} is only applied when
%    \pkg{footmisc} is called with an option specifying the
%    footnote placement, i.e., not  in the default case.
%    In new documents we apply it always.
%  \changes{v1.4q}{2025/03/20}{Remove a `fil' bottom skip even if we
%    are in ragged bottom typesetting (footmisc/19)}
%    \begin{macrocode}
\def\@outputbox@removebskip{%
%    \end{macrocode}
%    In some special circumstances the \cs{@outputbox} might be
%    void. As \cs{@outputbox@append} below would change this, we
%    handle this case by leaving it unchanged,
%    because otherwise we can no longer detect that situation
%    (needed, for example, in \pkg{ftnright}). 
%    \begin{macrocode}
   \ifvoid \@outputbox
     \global\let\@outputbox@reinsertbskip\relax
   \else
%    \end{macrocode}
%    If it is not void then we drop the final skip at the end of \cs{@outputbox}
%    provided there is one and it has a glue stretch
%    order of 1 or more (i.e., contains a \texttt{fil} or \texttt{fill} part).
%    \begin{macrocode}
     \@outputbox@append{%
       \@tempskipa\lastskip
       \ifnum \gluestretchorder\@tempskipa>\z@
         \unskip
%    \end{macrocode}
%        
%  \begin{macro}{\@outputbox@reinsertbskip}
%    We also prepare for reinserting the skip we removed elsewhere on the page.
%    As we have to do this globally, we also need to
%    explicitly reset \cs{@outputbox@reinsertbskip} if we don't find any such glue.
%    \begin{macrocode}
         \xdef\@outputbox@reinsertbskip
             {%
%    \end{macrocode}
%    Everything is done inside \cs{@outputbox@append} so that a call
%    to \cs{@outputbox@reinsertbskip} will update the box. If there
%    are no footnotes and no bottom floats that still needs to be
%    attached we first backup by the depth of the
%    \cs{@outputbox} so that the skip we add starts from the baseline
%    of the last line inside (if there is one). As it is a
%    \texttt{fil}, \texttt{fill}, or \texttt{filll} glue this normally
%    makes no differences, but if the box itself contains a fill skip
%    of higher order our fill is ignored and text is pushed to the
%    bottom of the page. In that case and without backing up first,
%    the last line would not be with its baseline on the bottom, but
%    slightly too high if it has characters with descenders.
%  \changes{v1.4r}{2025/03/25}{Back out the depth if we have no
%    footnotes and no bottom floats (footmisc/19)}
%    \begin{macrocode}
               \noexpand\@outputbox@append{%
                 \noexpand\@if@footnotes@TF
                     {}%
                     {%
                      \noexpand\@if@bottomfloats@TF
                         {}%
                         {\noexpand\@backup@outputbox@depth}%
                     }%
                 \vskip\the\@tempskipa}}%
       \else
         \global\let\@outputbox@reinsertbskip\relax
       \fi
     }%
  \fi
}
%    \end{macrocode}
%    We need a trivial top-level definition for
%    \cs{@outputbox@reinsertbskip} in case the first page has no
%    bottom glue and the command gets called.
%    \begin{macrocode}
\let \@outputbox@reinsertbskip \relax
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
%
%  \begin{macro}{\@backup@outputbox@depth}
%    In some places we have to make the depth of the \cs{@outputbox}
%    zero by backing up by its current depth. This is done by
%    \cs{@backup@outputbox@depth}. The macro can only be used inside
%    of \cs{@outputbox@append} (or after you have manually set the
%    \cs{@outputbox@depth} to the right value).
%
%    If the depth is zero, there is no point in doing anything, and if
%    the depth is negative it must have been deliberately set to this
%    value, so in this case we also do not back up and change it.
%
%    If it is positive we back up by the minimum of
%    \cs{@outputbox@depth} and \cs{maxdepth}, i.e., if the depth is
%    unusually large we do not perform a full backup.
%
%  \changes{v1.4r}{2025/03/25}{Macro added (footmisc/19)}
%    \begin{macrocode}
\def\@backup@outputbox@depth{%
%  \typeout{--> @backup@outputbox@depth : \the \@outputbox@depth}%
  \ifdim\@outputbox@depth>\z@
    \vskip -%
      \ifdim\@outputbox@depth>\maxdepth
        \maxdepth
      \else
        \@outputbox@depth
      \fi
%    \end{macrocode}
%    After the skip was added the depth of the box will become zero
%    but this is not immediately reflected in
%    \cs{@outputbox@depth}. Thus, if there is further code in the same
%    \cs{@outputbox@append} testing the register it would make a wrong
%    conclusion. We therefore set it locally to zero.
%    \begin{macrocode}
    \@outputbox@depth\z@    
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
% \subsection{The output routine configuration components}
%
%    Here we provide the comands that are used to define code for the
%    socket \socket{build/column/outputbox}. The all manipulate the
%    \cs{@outputbox} box in one way or another.
%
%
%  \begin{macro}{\@outputbox@append}
% \changes{v1.4m}{2025/02/14}{Macro added}
%
%    This general purpose command alters the \cs{@outputbox} box by
%    appending material to it. As this is a box typesetting operation
%    we make sure that the last line of the box reflects the true
%    depth of the last line (in case that is needed later). We also
%    expose the current depth of \cs{@outputbox} as
%    \cs{@outputbox@depth} before unboxing so that its value can be
%    used by \verb=#1= if wanted.
%    \begin{macrocode}
\def\@outputbox@append #1{%
   \setbox\@outputbox \vbox {%
%    \end{macrocode}
%    This |\boxmaxdepth| setting is to ensure that  deep footnotes
%    do not overwrite the footer (on account of the negative skip
%    added later): it should use |\@maxdepth| otherwise the change is
%    pointless when there are footnotes.
%
%    But see also its use when combining floats.
% \changes{v1.0l}{1994/03/15}{\cs{maxdepth} changed to \cs{@maxdepth}}
%    \begin{macrocode}
     \boxmaxdepth \@maxdepth
     \@outputbox@depth\dp\@outputbox      % if needed in #1
     \unvbox \@outputbox
     #1%
   }%
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%  \begin{macro}{\@outputbox@appendfil}
%    Append a \cs{vfil} to the \cs{@outputbox}. Depending on the plug
%    in the \socket{build/column/baselineattach} either from the
%    bottom of the box or the baseline of the last line.
%    \begin{macrocode}
\def\@outputbox@appendfil{\@outputbox@append
  {\UseSocket{build/column/baselineattach}\vfil}}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@outputbox@appendfootnotes}
% \changes{v1.4m}{2025/02/14}{Macro added}
%
%    This command appends the footnotes to the \cs{@outputbox} (if
%    there are any). If not, then it does nothing.
%    \begin{macrocode}
\def\@outputbox@appendfootnotes {%
   \ifvoid\footins \else
%    \end{macrocode}
%    Handling split footnotes need further work so this is for the
%    moment just  a dummy that does nothing. It might vanish and get
%    replaced by a socket eventually.  
% \task{fmi}{The code for handling split footnotes will get revised as part
%      of socket handling  in the future}
%    \begin{macrocode}
     \@makecol@handlesplitfootnotes
%    \end{macrocode}
%
%    The following socket can be used to manipulate the material in
%    \cs{footins} box, for example, if the footnotes are to be presented
%    all together in a single paragraph. By default it does nothing.
%    \begin{macrocode}
     \UseSocket{build/column/footnotes}%
%    \end{macrocode}
%    Then the footnotes are appended:
%    \begin{macrocode}
     \@outputbox@append{%
%    \end{macrocode}
%    First we call a socket which controls whether or not we back up by the depth
%    of the \cs{@outputbox} so that the skip that seperates the
%    footnotes from the text starts at the baseline
%    of the last text line.
%  \changes{v1.4q}{2025/03/20}{Add experimental socket for baseline
%    attachment of footnotes -- subject to change (footmisc/19)}
%    \begin{macrocode}
       \UseSocket{build/column/baselineattach}%
       \vskip \skip\footins
%    \end{macrocode}
%    The next socket adjusts the tagging of the \cs{footins} box, if necessary.
%    \begin{macrocode}
       \UseTaggingSocket{build/column/footins}%
%    \end{macrocode}
%
%    \begin{macrocode}
       \color@begingroup
         \normalcolor
         \footnoterule
%    \end{macrocode}
%    Support for \pkg{pdfcolfoot}; eventually this can go once color
%    is properly supported. The csname is constructed in case the command
%    is not defined, i.e., the package not loaded.
%  \task{fmi}{Fix when no longer needed}       
%    \begin{macrocode}
         \csname pdfcolfoot@current\endcsname
         \unvbox \footins
       \color@endgroup
      }%
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@makecol@handlesplitfootnotes}
%    For future extensions \ldots
%    \begin{macrocode}
\let \@makecol@handlesplitfootnotes \@empty
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@outputbox@attachfloats}
% \changes{v1.4m}{2025/02/14}{Macro added}
%  \begin{macro}{\@outputbox@attachtopfloats}
% \changes{v1.4m}{2025/02/14}{Macro added}
%  \begin{macro}{\@outputbox@attachbottomfloats}
% \changes{v1.4m}{2025/02/14}{Macro added}
%    Attaching top and bottom floats can usually be done in one go,
%    but for special layouts we might want more control so we provide
%    also separate commands.
%
%    The next command was called \cs{@combinefloats} in the past.
%    \begin{macrocode}
\def \@outputbox@attachfloats {%
    \@outputbox@attachtopfloats
    \@outputbox@attachbottomfloats
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def \@outputbox@attachtopfloats {%
  \ifx \@toplist\@empty \else \@cflt \fi
}
%    \end{macrocode}
%    Before we append the bottom floats we run the
%    \socket{build/column/baselineattach} so that the
%    \cs{textfloatsep} is measured from the baseline if that is desired.
%  \changes{v1.4s}{2025/03/29}{Add socket (footmisc/19)}
%    \begin{macrocode}
\def \@outputbox@attachbottomfloats {%
  \ifx \@botlist\@empty \else
    \@outputbox@append{\UseSocket{build/column/baselineattach}}%
    \@cflb
  \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%
% The next three conditionals might be useful when setting up running
% headers and footers so perhaps they should be change to CamelCase
% names. For now they are internal.
%
%  \begin{macro}{\@if@flushbottom@TF}
% \changes{v1.4m}{2025/02/14}{Macro added}
%    Test for \cs{flushbottom} (currently not used).
%    \begin{macrocode}
\def\@if@flushbottom@TF{%
  \ifx\@textbottom\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@if@footnotes@TF}
% \changes{v1.4m}{2025/02/14}{Macro added}
%    Test if footnotes are present on the current page or column and
%    not yet added to the \cs{@outputbox}.
%    \begin{macrocode}
\def\@if@footnotes@TF{%
  \ifvoid\footins
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@if@bottomfloats@TF}
% \changes{v1.4m}{2025/02/14}{Macro added}
%    Test if bottom floats are around and not yet added to the
%    \cs{@outputbox}.
%    \begin{macrocode}
\def\@if@bottomfloats@TF{%
  \ifx \@botlist\@empty
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%
%
%
%
% \changes{v1.4m}{2025/02/14}{Use sockets and hooks in OR}
%
%  \begin{socketdecl}{build/column/outputbox}
% \changes{v1.4m}{2025/02/14}{Socket added}
%    We have one socket that is supposed to augment the \cs{@outputbox}
%    by attaching floats and footnotes with appropriate spacing.
%    \begin{macrocode}
\NewSocket{build/column/outputbox}{0}
%    \end{macrocode}
%  \end{socketdecl}
%
%
%    The following plugs are available for
%    this socket:
%
%  \begin{plugdecl}{space-footnotes-floats}
%    After the galley text there is a vertical \cs{vfil} followed by
%    any footnotes followed by the bottom floats, if any.
%    \begin{macrocode}
\NewSocketPlug {build/column/outputbox}{space-footnotes-floats} {%
  \@if@footnotes@TF
      {\@outputbox@appendfil}%
      {\@if@bottomfloats@TF
        {\@outputbox@appendfil}%
        {\@outputbox@reinsertbskip}%
      }%
  \@outputbox@appendfootnotes
  \@outputbox@attachfloats
}
%    \end{macrocode}
%  \end{plugdecl}
%
%  \begin{plugdecl}{footnotes-space-floats}
%    As before but the \cs{vfil} is between footnotes and floats.
%    \begin{macrocode}
\NewSocketPlug {build/column/outputbox}{footnotes-space-floats} {%
  \@outputbox@appendfootnotes
  \@if@bottomfloats@TF
      {\@outputbox@appendfil}%
      {\@outputbox@reinsertbskip}%
  \@outputbox@attachfloats
}
%    \end{macrocode}
%  \end{plugdecl}
%
%  \begin{plugdecl}{floats-space-footnotes}
%    Floats immediately after the galley text and footnotes at the bottom.
%    \begin{macrocode}
\NewSocketPlug {build/column/outputbox}{floats-space-footnotes} {%
  \@outputbox@attachfloats
  \@if@footnotes@TF
      {\@outputbox@appendfil}%
      {\@outputbox@reinsertbskip}%
  \@outputbox@appendfootnotes
}
%    \end{macrocode}
%  \end{plugdecl}
%
%  \begin{plugdecl}{space-floats-footnotes}
%         Both floats and footnotes are pushed to the bottom with
%         footnotes last.\footnote{There are two more
%         permutations, but neither of them has ever been requested so
%         they aren't set up by default --- doing that in a class
%         would be trivial though.}
%    \begin{macrocode}
\NewSocketPlug {build/column/outputbox}{space-floats-footnotes} {%
  \@if@bottomfloats@TF
      {\@outputbox@appendfil}%
      {\@if@footnotes@TF
         {\@outputbox@appendfil}%
         {\@outputbox@reinsertbskip}}%
  \@outputbox@attachfloats
  \@outputbox@appendfootnotes
}
%    \end{macrocode}
%  \end{plugdecl}
%
%
%
%  \begin{plugdecl}{floats-footnotes}
%         All excess space has to be distributed across the existing
%         glue on the page, e.g., within the text galley, the
%         separation between blocks, etc.
%         The order is text, floats, footnotes.
%    \begin{macrocode}
\NewSocketPlug {build/column/outputbox}{floats-footnotes} {%
  \@outputbox@attachfloats
  \@outputbox@appendfootnotes
%    \end{macrocode}
%    We do reinsert the bottom skip from \cs{newpage} if it
%    was taken out earlier. This is, strictly speaking, not necessary
%    in most cases, but it is a \cs{vfil} while \cs{raggedbottom} is
%    only generating \verb=\vspace{0pt plus .0001fil}=, so if you have
%    several \cs{vfil} on the page before the \cs{newpage} you would
%    alter the space distribution if one is taken out.
%    \begin{macrocode}
  \@outputbox@reinsertbskip
}
%    \end{macrocode}
%
%  \end{plugdecl}
%
%  \begin{plugdecl}{footnotes-floats}
%    \begin{macrocode}
\NewSocketPlug {build/column/outputbox}{footnotes-floats} {%
  \@outputbox@appendfootnotes
  \@outputbox@attachfloats
  \@outputbox@reinsertbskip
}
%    \end{macrocode}
%    The \texttt{footnote-floats} plug implements the layout used by
%    \LaTeX{} but with the bottom skip bug corrected. This will be
%    the default when \cs{DocumentMetadata} is used; it can be
%    overwritten either through \pkg{footmisc} or by assigning any of
%    the other plugs (or by coding yet another plug for the socket).
%  \end{plugdecl}
%
%  \begin{plugdecl}{footnotes-floats-legacy}
%    This implements the 2.09 layout (including its bottom skip bug).
%    \begin{macrocode}
\NewSocketPlug {build/column/outputbox}{footnotes-floats-legacy} {%
%    \end{macrocode}
%    In the legacy case we don't really want to take out the bottom
%    skip, but rather than altering \cs{@outputbox@removebskip} in
%    \cs{makecol} to do nothing, which we would then have to undo in
%    every other layout, we immediately reinsert the dropped skip
%    again.
%
%    In the legacy case there is, however, one other thing that needs
%    doing: if there was a \cs{vfil} at the bottom of the page (e.g.,
%    from \cs{newpage}) and there are no footnotes, then we need to back up
%    by the depth of the last line in the page box. Otherwise you
%    might end up with incorrect alignment if there is a higher-order
%    fill on the page (e.g., \cs{vfill}) that pushes the text material
%    to the bottom, since in such cases the depth will not be taken into
%    account by \TeX{}.
%    
%    This is done automatically by \cs{@outputbox@reinsertbskip} as
%    long as there are no footnotes waiting to be placed.
%    If there are footnotes, the operation is not done because by
%    default the \cs{skip}\cs{footins} separation is measured from the
%    bottom of the line not from the baseline.
%    But if the user has asked to change this behavior we should honor
%    it and that is done by putting the experimental socket
%    \socket{build/column/baselineattach} in which performs the
%    backing up if desired. This should happen only if footnotes are
%    actually present, so we test for this. Otherwise, there may be
%    bottom floats and the \cs{textfloatsep} should be measured
%    from the bottom of the last line and if not then any necessary
%    back up is done by \cs{@outputbox@reinsertbskip}.
%  
%    Note that after this code has backed up, the depth of
%    \cs{@outputbox} will be zero as there is a skip at its bottom. So
%    even if the same code is executed a second time (in
%    \cs{@outputbox@reinsertbskip} or in
%    \cs{@outputbox@appendfootnotes}) it will not alter the box further.
%  
%  \changes{v1.4r}{2025/03/25}{Add support for attaching footnotes
%    with a skip starting at the baseline of the last text line (footmisc/19)}
%    \begin{macrocode}
  \@if@footnotes@TF
    {\@outputbox@append{%
        \UseSocket{build/column/baselineattach}}%
    }{%
%    \end{macrocode}
%    If there are no footnotes but there are bottom floats we execute
%    the socket \socket{build/column/baselineattach} so that
%    \cs{textfloatsep} is measured from the baseline if that is being
%    asked for.
%  \changes{v1.4s}{2025/03/29}{Add socket (footmisc/19)}
%    \begin{macrocode}
      \@if@bottomfloats@TF
        {\@outputbox@append{%
            \UseSocket{build/column/baselineattach}}%
        }{}%
    }%
  \@outputbox@reinsertbskip
  \@outputbox@appendfootnotes
  \@outputbox@attachfloats
}
%    \end{macrocode}
%    The \texttt{footnote-floats-legacy} plug is the default used by
%    \LaTeX{} when \cs{DocumentMetadata} is not used; it can be
%    overwritten
%    either through \pkg{footmisc} or
%    by assigning any of the other plugs (or by coding yet another
%    plug for the socket).
%    \begin{macrocode}
\AssignSocketPlug {build/column/outputbox}{footnotes-floats-legacy}
%    \end{macrocode}
%  \end{plugdecl}
%
%
%
%
%  \begin{socketdecl}{build/column/footnotes}
%
%    The socket allowing the manipulation of \cs{footins} box
%    (result needs to be moved back in there). Used when footnotes are
%    reformatted into a single paragraph by the
%    \texttt{para} option of \pkg{footmisc}. By default it does nothing.
%    \begin{macrocode}
\NewSocket{build/column/footnotes}{0}
%    \end{macrocode}
%  \end{socketdecl}
%
%
%  \begin{socketdecl}{build/column/baselineattach}
%
%  \changes{v1.4q}{2025/03/20}{Add experimental socket for baseline
%    attachment of footnotes -- subject to change (footmisc/19)}
%
%    Socket that allows backing up by the depth of the
%    outputbox (but not more than \cs{maxdepth}  before attaching any
%    footnotes or floats.
%    \begin{macrocode}
\NewSocket{build/column/baselineattach}{0}
%    \end{macrocode}
%  \end{socketdecl}
%
%  \begin{plugdecl}{on}
%    \begin{macrocode}
\NewSocketPlug {build/column/baselineattach}{on} {%
%    \end{macrocode}
%    We do nothing if the depth is not positive, and we never back up
%    by more than \cs{maxdepth}.
%  \changes{v1.4r}{2025/03/25}{ (footmisc/19)}
%    \begin{macrocode}
  \@backup@outputbox@depth
}
%    \end{macrocode}
%  \end{plugdecl}
%
%  \begin{plugdecl}{off}
%    The \plug{off} plug is actually identical to the \plug{noop} plug
%    which is automatically made available; but offering that it under
%    the name \plug{off} makes the interface a bit nicer.
%    \begin{macrocode}
\NewSocketPlug {build/column/baselineattach}{off}{}
%    \end{macrocode}
%    This feature is not turned on by default to preserve the behavior
%    of old documents.
%    With new documents using \cs{DocumentMetadata} it may become the
%    default.
%    \begin{macrocode}
\AssignSocketPlug {build/column/baselineattach}{off}
%    \end{macrocode}
%  \end{plugdecl}
%
%
%
%
%
%
%
%
% \begin{hookdecl}{build/page/before,
%                  build/page/after}
% \changes{v1.4m}{2025/02/14}{Hook added}
%    Hooks at the start and end of \cs{@outputpage} for use by packages.
%    \begin{macrocode}
\NewMirroredHookPair{build/page/before}{build/page/after}
%    \end{macrocode}
% \end{hookdecl}
%
%
%
% \begin{hookdecl}{build/page/reset}
% \changes{v1.4m}{2025/02/14}{Hook added}
%    Hook in \cs{@outputpage} to reset special galley conventions
%    within the output routine. \LaTeX{} does a lot of resetting in
%    front of this hook, so by default it is empty. They are not made
%    part of the hook (which would have been possible) to ensure that
%    the kernel resets always come first and can be overwritten without the
%    need to apply hook rules unnecessarily.
%    \begin{macrocode}
\NewHook {build/page/reset}
%    \end{macrocode}
% \end{hookdecl}
%
%
%
% \begin{hookdecl}{build/column/before,build/column/after}
% \changes{v1.4m}{2025/02/14}{Hook added}
%    Hooks at the start and end of \cs{@makecol} for use by packages.
%    \begin{macrocode}
\NewMirroredHookPair{build/column/before}{build/column/after}
%    \end{macrocode}
% \end{hookdecl}
%
%
%
%    \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>   {\@makecol}{\@makecol adding hooks/sockets}%
%<latexrelease>
%<latexrelease>\gdef \@makecol {%
%<latexrelease>   \ifvoid\footins
%<latexrelease>     \setbox\@outputbox \box\@cclv
%<latexrelease>   \else
%<latexrelease>     \setbox\@outputbox \vbox {%
%<latexrelease>       \boxmaxdepth \@maxdepth
%<latexrelease>       \unvbox \@cclv
%<latexrelease>       \vskip \skip\footins
%<latexrelease>       \color@begingroup
%<latexrelease>         \normalcolor
%<latexrelease>         \footnoterule
%<latexrelease>         \unvbox \footins
%<latexrelease>       \color@endgroup
%<latexrelease>       }%
%<latexrelease>   \fi
%<latexrelease>   \let\@elt\relax
%<latexrelease>   \xdef\@freelist{\@freelist\@midlist}%
%<latexrelease>   \global \let \@midlist \@empty
%<latexrelease>   \@combinefloats
%<latexrelease>   \ifvbox\@kludgeins
%<latexrelease>     \@makespecialcolbox
%<latexrelease>   \else
%<latexrelease>     \setbox\@outputbox \vbox to\@colht {%
%<latexrelease>       \@texttop
%<latexrelease>       \dimen@ \dp\@outputbox
%<latexrelease>       \unvbox \@outputbox
%<latexrelease>       \vskip -\dimen@
%<latexrelease>       \@textbottom
%<latexrelease>       }%
%<latexrelease>   \fi
%<latexrelease>   \global \maxdepth \@maxdepth
%<latexrelease>}
%<latexrelease>
%<latexrelease>\gdef \@makespecialcolbox {%
%<latexrelease>   \setbox\@outputbox \vbox {%
%<latexrelease>     \@texttop
%<latexrelease>     \dimen@ \dp\@outputbox
%<latexrelease>     \unvbox\@outputbox
%<latexrelease>     \vskip-\dimen@
%<latexrelease>     }%
%<latexrelease>   \@tempdima \@colht
%<latexrelease>   \ifdim \wd\@kludgeins>\z@
%<latexrelease>     \advance \@tempdima -\ht\@outputbox
%<latexrelease>     \advance \@tempdima \pageshrink
%<latexrelease>     \setbox\@outputbox \vbox to \@colht {%
%<latexrelease>       \unvbox\@outputbox
%<latexrelease>       \vskip \@tempdima
%<latexrelease>       \@textbottom
%<latexrelease>       }%
%<latexrelease>   \else
%<latexrelease>     \advance \@tempdima -\ht\@kludgeins
%<latexrelease>     \setbox \@outputbox \vbox to \@colht {%
%<latexrelease>       \vbox to \@tempdima {%
%<latexrelease>         \unvbox\@outputbox
%<latexrelease>         \@textbottom}%
%<latexrelease>       \vss}%
%<latexrelease>   \fi
%<latexrelease>   {\setbox \@tempboxa \box \@kludgeins}%
%<latexrelease>}
%<latexrelease>
%<latexrelease> \let \@make@normalcolbox \@undefined
%<latexrelease> \let \@make@specialcolbox \@undefined
%<latexrelease> \let \@outputbox@removebskip \@undefined
%<latexrelease> \let \@outputbox@reinsertbskip \@undefined
%<latexrelease>
%<latexrelease> \let \@outputbox@append \@undefined
%<latexrelease> \let \@outputbox@appendfootnotes \@undefined
%<latexrelease> \let \@outputbox@attachfloats \@undefined
%<latexrelease> \let \@outputbox@attachtopfloats \@undefined
%<latexrelease> \let \@outputbox@attachbottomfloats \@undefined
%<latexrelease>
%    \end{macrocode}
%    If we roll back we also need to restore this definition.
%    \begin{macrocode}
%<latexrelease> \def \@combinefloats {%
%<latexrelease>    \ifx \@toplist\@empty \else \@cflt \fi
%<latexrelease>    \ifx \@botlist\@empty \else \@cflb \fi
%<latexrelease> }
%<latexrelease>
%<latexrelease> \let \@if@flushbottom@TF \@undefined
%<latexrelease> \let \@if@footnotes@TF \@undefined
%<latexrelease> \let \@if@bottomfloats@TF \@undefined
%<latexrelease>
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
%
%  \begin{macro}{\@reinserts}
% \changes{v1.0e}{1993/12/01}{Command added}
%    This is the code which reinserts the inserts.  It puts them all
%    in one place; this can make some of them come out on the wrong
%    page.
%    It has been put into a separate macro to expedite experimentation.
%    \begin{macrocode}
\gdef \@reinserts{%
  \ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
  \ifvbox\@kludgeins\insert\@kludgeins
                      {\unvbox\@kludgeins}\fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%
%  \begin{macro}{\@texttop}
%  \begin{macro}{\@textbottom}
%    These do nothing as a default.
%    \begin{macrocode}
\let \@texttop \relax
\let \@textbottom \relax
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\@resetactivechars}
%  \begin{macro}{\@activechar@info}
%
% \changes{v1.0n}{1994/04/30}{\cs{@activechar@warning} changed to
% \cs{@activechar@info}}
% RmS 93/09/06:
% added hook to protect against certain active characters in the
% output routine. Default checks are for active space and end-of-line.
% \changes{v1.0u}{1994/05/23}{Added \cs{MessageBreak}}
%    \begin{macrocode}
\def\@activechar@info #1{%
      \@latex@info@no@line {Active #1 character found while
                            output routine is active
                            \MessageBreak
                            This may be a bug in a package file
                            you are using}%
}
%    \end{macrocode}
%
%    Do not put any spaces in this next bit!
% \changes{1.2f}{1999/10/09}{Reset definition of active prime
%    character (used in math mode)}
%    \begin{macrocode}
\begingroup
\obeylines\obeyspaces%
\catcode`\'\active%
\gdef\@resetactivechars{%
\def^^M{\@activechar@info{EOL}\space}%
\def {\@activechar@info{space}\space}%
\let'\active@math@prime}%
\endgroup
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\@outputpage}
% \changes{v1.0f}{1993/12/05}{Command changed}
%  \begin{macro}{\@shipoutsetup}
% \changes{v1.0f}{1993/12/05}{Command added}
% \changes{v1.1s}{1995/11/10}{Command removed}
%  \begin{macro}{\@writesetup}
% \changes{v1.1s}{1995/11/10}{Command removed}
% \changes{v1.1o}{1995/07/21}{Command added}
% \changes{v1.0f}{1993/12/05}{\cs{@startpagehook} added}
% \changes{v1.0j}{1993/12/17}{---and then removed}
% \changes{v1.0p}{1994/05/12}{\cs{normalcolor}added}
% \changes{v1.0s}{1994/05/20}{Added setting of \cs{protect}
%                    during \cs{shipout}.}
% \changes{v1.0u}{1994/05/23}{Changed resetting of \cs{protect} after
% shipout to use \cs{aftergroup}}
% \changes{v1.1b}{1994/11/05}
%         {Use new \cs{color@hbox} concept.}
% \changes{v1.1b}{1994/11/05}
%         {Change protect settings for new-style, protect-free
%         aux-files.}
% \changes{v1.1c}{1994/11/05}
%         {Add new \cs{AtBeginDvi} concept}
% \changes{v1.1e}{1994/11/10}
%         {Modify \cs{protect} setting}
% \changes{v1.1f}{1994/11/14}
%         {Modify new \cs{AtBeginDvi} concept}
% \changes{v1.1o}{1995/07/21}
%         {New, experimental, versions: need in-lining}
% \changes{v1.1s}{1995/11/10}{In-lined}
% \changes{v1.1w}{1996/09/21}{Added \cs{@parboxrestore} and made
%     consequent deletions: wait for the howls of protest}
% \changes{v1.4m}{2025/02/14}{Hooks and sockets added}
%
%    The |\color@hbox| hooks here are used to avoid putting just a
%    colour special into an otherwise empty box (in a header or
%    footer).  These boxes are often set to be completely empty and so
%    adding a special produces a very underfull box message.
%
%    There has been extensive tidying up of the old code here;
%    including the removal of a level of grouping.
%
%    The setting of |\protect| immediately before the |\shipout|
%    is needed so that protected commands within |\write|s are
%    handled correctly.
%
%    Within shipout's vbox it is reset to its default value, |\relax|.
%
%    Resetting it to its default value after the shipout has been
%    completed (and the contents of the writes have been expanded)
%    must be done by use of |\aftergroup|.
%    This is because it must have the value |\relax|
%    before macros coming from other uses of |\aftergroup| within
%    this box are expanded.
%
%    Putting this into the |\aftergroup| token list does not affect
%    the definition used in expanding the |\write|s because the
%    aftergroup token list is only constructed when popping the
%    save-stack, it is not expanded until after the shipout is
%    completed.
%
%    Question: should things from an |\aftergroup| within the shipped
%    out box be executed in the environment set up for the writes, or
%    after it finishes?
%
%    A lot of this code has been in-lined to prevent mis-use of
%    internal commands as hooks.
%    \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2025/06/01}%
%<latexrelease>  {\@outputpage}{Use new mark mechanism}%
%<*2ekernel|latexrelease>
%    \end{macrocode}
%    Temp definition to vanish again when something is offered by the backend:
%    \begin{macrocode}
\protected \def \pdfannot@link@on@@  { \csname pdfannot_link_on:\endcsname }
\protected \def \pdfannot@link@off@@ { \csname pdfannot_link_off:\endcsname }
%    \end{macrocode}
%
%    \begin{macrocode}
\def \@outputpage {%
%    \end{macrocode}
%    We start with a hook available to packages that want to prepend
%    code to \cs{@outputpage}.
%    \begin{macrocode}
  \UseHook {build/page/before}%
%    \end{macrocode}
% The |\endgroup| is put in by |\aftergroup|.
%    \begin{macrocode}
\begingroup
%    \end{macrocode}
%    Now all the set-up stuff has been in-lined for Frank.
%
%    First the stuff for the writes.
%
%    From here on was orginially in the command |\@writesetup|.
%
%    RmS 93/08/19: Redefined accents to allow changes in font encoding;
%    but exactly why was this needed?
%
% \changes{v1.3c}{2017/03/10}{Reset \cs{language}}
% Reset |\language| to the value current at |\begin{document}|.
% In particular this ensures that a pagebreak in |verbatim| does not
% prevent hyphenation in the page head.
%    \begin{macrocode}
  \language\document@default@language
%    \end{macrocode}
%
%    Now a few more resets for things that may have changed during
%    galley processing. We start with resetting some active character definitions.
%    \begin{macrocode}
  \@resetactivechars
%    \end{macrocode}
%    Then we deal with catcodes that might got altered by
%    \texttt{verbatim} or similar environments and reset them to
%    standard values. 
%  \changes{v1.4o}{2025/02/25}{Reset various catcodes to their default
%      values in case a pagebreak occurs while a special catcode scheme
%      is in force (gh/600)}
%  \changes{v1.4y}{2025/06/07}{Reset catcode of CR (gh/1766)}
%  \changes{v1.4y}{2025/06/08}{Reset catcode of TAB (gh/1766)}
%  \changes{v1.4z}{2025/08/22}{Don't use \cs{nfss@catcodes} + updates,
%                but spell everything out explicitly}
%    \begin{macrocode}
   \catcode`\\\z@
   \catcode`\{\@ne
   \catcode`\}\tw@
   \catcode`\$\thr@@
   \catcode`\&4\relax
   \catcode`\^^M5\relax
   \catcode`\#6\relax
   \catcode`\^7\relax
   \catcode`\_8\relax
   \catcode`\ 10\relax
   \catcode`\^^I10\relax
   \@makeother\<%
   \@makeother\>%
   \@makeother\*%
   \@makeother\.%
   \@makeother\-%
   \@makeother\/%
   \@makeother\[%
   \@makeother\]%
   \@makeother\`%
   \@makeother\'%
   \@makeother\"%
   \catcode`\~13\relax
   \catcode`\%14\relax
%    \end{macrocode}
%    If a page break happens between the start of a list and its first
%    item then |@newlist| will be true and this will mess up any list
%    that is used in the header or footer of the page. So we have to
%    reset that flag.
% \changes{v1.2h}{2000/07/19}
%  {Reset and restore \cs{@if@newlist} for internal/3231}
% \changes{v1.2j}{2001/01/07}
%  {And do it in the right macro! (pr/3286)}
%    \begin{macrocode}
  \global\let\@@if@newlist\if@newlist
  \global\@newlistfalse
%    \end{macrocode}
%
% \changes{v1.0q}{1994/05/16}{Changed setting of accents (FMi):
%     with the new encoding setup they can use \cs{let}.
%     It could also use the new internal commands?}
% \changes{v1.1l}{1995/04/24}{Reset \cmd\\ latex/1451 (DPC)}
%    This next hook replaces the following:
%    \begin{verbatim}
%      \let\-\@dischyph
%      \let\'\@acci\let\`\@accii\let\=\@acciii
%      \let\\\@normalcr
%      \let\par\@@par %% 15 Sep 87 (this was once inside the box)
%    \end{verbatim}
%    and it does more than they did; in particular it sets:
%    \begin{verbatim}
%      \parindent\z@
%      \parskip\z@skip
%      \everypar{}%
%      \leftskip\z@skip
%      \rightskip\z@skip
%      \parfillskip\@flushglue
%      \lineskip\normallineskip
%      \baselineskip\normalbaselineskip
%      \sloppy
%    \end{verbatim}
%
%    \begin{macrocode}
  \@parboxrestore
%    \end{macrocode}
%    \ldots\ to here was in the command |\@writesetup|.
%
%    Hook to allow adding resets local to the output routine processing, e.g.,
%    in \cs{write} or running headers/footers, for packages that set
%    up special conventions in the main galley that should not leak
%    into the page production just because a page break happens in the
%    middle of such an environment.
%    \begin{macrocode}
  \UseHook {build/page/reset}%
%    \end{macrocode}
%    
%    The following definition of \cs{protect} is the one active during
%    the \cs{write} statement that migrate out of the \cs{shipout}
%    box, so even though it is immediately changed below (inside
%    \cs{shipout} it still has to be here!
%  \changes{v1.4z}{2025/08/22}{Move setting of \cs{protect} after all hooks
%             so that only the \cs{write} statements are affected (gh/1845)}
%    \begin{macrocode}
  \let \protect \noexpand
%    \end{macrocode}
%
%    \begin{macrocode}
  \shipout \vbox{%
%    \end{macrocode}
%    Inside the \cs{shipout} box we have a different setting for \cs{protect}.
%    \begin{macrocode}
    \set@typeset@protect
    \aftergroup \endgroup
%    \end{macrocode}
%    Once the \cs{shipout} boxs ends \cs{protect} is again
%    \cs{noexpand} which is correct for any \cs{write} statements, but
%    once they are processed we want to get back to the following setting:
%    \begin{macrocode}
    \aftergroup \set@typeset@protect
%    \end{macrocode}
%
%    Now the setup inside the shipped out box; this should contain all
%    the stuff that could only affect typesetting; other stuff may need
%    to be reset for the writes also.
%
%    From here \ldots\ was in the command |\@shipoutsetup|.
%    \begin{macrocode}
  \if@specialpage
    \global \@specialpagefalse
    \@nameuse {ps@\@specialstyle}%
  \fi
  \if@twoside
    \ifodd\count\z@
      \let \@thehead \@oddhead
      \let \@thefoot \@oddfoot
      \let \@themargin \oddsidemargin
    \else
      \let \@thehead \@evenhead
      \let \@thefoot \@evenfoot
      \let \@themargin \evensidemargin
    \fi
  \fi
%    \end{macrocode}
%
%    The rest was always inside the box.
%
%    RmS 91/08/15: added this line:
%    \begin{macrocode}
  \reset@font
%    \end{macrocode}
%    RmS 93/08/06 Added |\lineskiplimit=0pt| to guard against it being
%              nonzero: e.g. by |\offinterlineskip| being in effect.
%
%    There are probably lots of other things that may need resetting.
%
%    \begin{macrocode}
  \normalsize
%    \end{macrocode}
% Reset the space factors.
% \changes{v1.2b}{1997/04/14}
%     {Call \cs{normalsfcodes} (from patch file) latex/2404}
%    \begin{macrocode}
  \normalsfcodes
%    \end{macrocode}
%
% Reset these here (previously reset separately for head and foot)
% \changes{v1.2b}{1997/04/14}
%     {Move \cs{label} and \cs{index} (from patch file)}
% \changes{v1.4l}{2025/01/21}{Support extended syntax
%            for \cs{label}, \cs{index}, and \cs{glossary} (gh/311)}
%  \changes{v1.4m}{2025/01/23}
%     {Make \cs{label}, \cs{index} and \cs{glossary} truely invisible
%    when typesetting (gh/1638)}
%    \begin{macrocode}
  \let \label \@gobble@with@sphack@om
  \let \index \@gobble@with@sphack@som
  \let \glossary \@gobble@with@sphack@om
%    \end{macrocode}
%
%    \begin{macrocode}
  \baselineskip \z@skip
  \lineskip \z@skip
  \lineskiplimit \z@
%    \end{macrocode}
%    \ldots\ to here was in the command |\@shipoutsetup|.
%    \begin{macrocode}
    \@begindvi
    \vskip \topmargin
    \moveright\@themargin \vbox {%
      \setbox\@tempboxa \vbox to\headheight {%
        \vfil
%    \end{macrocode}
%    Tagging socket that receives the header in its second argument to
%    surround the  header with appropriate tagging structures (first
%    argument is unused). If tagging is disabled it returns the
%    content of the second argument.
%    \begin{macrocode}
        \pdfannot@link@off@@
        \UseTaggingSocket{build/page/header}{}%
          {
            \color@hbox
              \normalcolor
              \hb@xt@ \textwidth {\@thehead }%
            \color@endbox
          }
        \pdfannot@link@on@@
      }
      \dp \@tempboxa \z@
      \box \@tempboxa
      \vskip \headsep
      \box \@outputbox
      \baselineskip \footskip
%    \end{macrocode}
%    Tagging socket that receives the footer in its second argument to
%    surround the  footer with appropriate tagging structures (first
%    argument is unused). If tagging is disabled it returns the
%    content of the second argument.
%    \begin{macrocode}
      \pdfannot@link@off@@
      \UseTaggingSocket{build/page/footer}{}%
         {
            \color@hbox
               \normalcolor
               \hb@xt@ \textwidth {\@thefoot }%
             \color@endbox
         }
      \pdfannot@link@on@@
      }
    }
%    \end{macrocode}
%   |\endgroup| now inserted by |\aftergroup|
%
% Restore |\if@newlist|
%    \begin{macrocode}
  \global \let \if@newlist \@@if@newlist
%    \end{macrocode}
%
%    \begin{macrocode}
  \global \@colht \textheight
  \stepcounter{page}%
%    \end{macrocode}
%    Another hook for packages that want to append material to \cs{@outputpage}.
%    \begin{macrocode}
   \UseHook {build/page/after}%
}
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%    
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{2017/04/15}%
%<latexrelease>  {\@outputpage}{Reset language for hyphenation}%
%<latexrelease>\def\@outputpage{%
%<latexrelease>\begingroup
%<latexrelease>  \let \protect \noexpand
%<latexrelease>  \language\document@default@language
%<latexrelease>  \@resetactivechars
%<latexrelease>  \global\let\@@if@newlist\if@newlist
%<latexrelease>  \global\@newlistfalse
%<latexrelease>  \@parboxrestore
%<latexrelease>  \shipout \vbox{%
%<latexrelease>    \set@typeset@protect
%<latexrelease>    \aftergroup \endgroup
%<latexrelease>    \aftergroup \set@typeset@protect
%<latexrelease>  \if@specialpage
%<latexrelease>    \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
%<latexrelease>  \fi
%<latexrelease>  \if@twoside
%<latexrelease>    \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
%<latexrelease>         \let\@themargin\oddsidemargin
%<latexrelease>    \else \let\@thehead\@evenhead
%<latexrelease>       \let\@thefoot\@evenfoot \let\@themargin\evensidemargin
%<latexrelease>    \fi
%<latexrelease>  \fi
%<latexrelease>  \reset@font
%<latexrelease>  \normalsize
%<latexrelease>  \normalsfcodes
%<latexrelease>  \let\label\@gobble
%<latexrelease>  \let\index\@gobble
%<latexrelease>  \let\glossary\@gobble
%<latexrelease>  \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
%<latexrelease>    \@begindvi
%<latexrelease>    \vskip \topmargin
%<latexrelease>    \moveright\@themargin \vbox {%
%<latexrelease>      \setbox\@tempboxa \vbox to\headheight{%
%<latexrelease>        \vfil
%<latexrelease>        \color@hbox
%<latexrelease>          \normalcolor
%<latexrelease>          \hb@xt@\textwidth{\@thehead}%
%<latexrelease>        \color@endbox
%<latexrelease>        }%
%<latexrelease>      \dp\@tempboxa \z@
%<latexrelease>      \box\@tempboxa
%<latexrelease>      \vskip \headsep
%<latexrelease>      \box\@outputbox
%<latexrelease>      \baselineskip \footskip
%<latexrelease>      \color@hbox
%<latexrelease>        \normalcolor
%<latexrelease>        \hb@xt@\textwidth{\@thefoot}%
%<latexrelease>      \color@endbox
%<latexrelease>      }%
%<latexrelease>    }%
%<latexrelease>  \global\let\if@newlist\@@if@newlist
%<latexrelease>  \global \@colht \textheight
%<latexrelease>  \stepcounter{page}%
%    \end{macrocode}
%    It is now clear that this does something useful (in the old mark
%    mechanism), thanks to Pieter van Oostrum pointing this out.  It
%    is needed because a float page is made without using TeX's
%    page-builder; thus the output routine is never called so the
%    marks are not updated.
%    \begin{macrocode}
%<latexrelease>  \let\firstmark\botmark
%<latexrelease>}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%    
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>  {\@outputpage}{Reset language for hyphenation}%
%<latexrelease>\def\@outputpage{%
%<latexrelease>\begingroup
%<latexrelease>  \let \protect \noexpand
%<latexrelease>  \@resetactivechars
%<latexrelease>  \global\let\@@if@newlist\if@newlist
%<latexrelease>  \global\@newlistfalse
%<latexrelease>  \@parboxrestore
%<latexrelease>  \shipout \vbox{%
%<latexrelease>    \set@typeset@protect
%<latexrelease>    \aftergroup \endgroup
%<latexrelease>    \aftergroup \set@typeset@protect
%<latexrelease>  \if@specialpage
%<latexrelease>    \global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
%<latexrelease>  \fi
%<latexrelease>  \if@twoside
%<latexrelease>    \ifodd\count\z@
%<latexrelease>         \let\@thehead\@oddhead \let\@thefoot\@oddfoot
%<latexrelease>         \let\@themargin\oddsidemargin
%<latexrelease>    \else \let\@thehead\@evenhead
%<latexrelease>       \let\@thefoot\@evenfoot \let\@themargin\evensidemargin
%<latexrelease>    \fi
%<latexrelease>  \fi
%<latexrelease>  \reset@font
%<latexrelease>  \normalsize
%<latexrelease>  \normalsfcodes
%<latexrelease>  \let\label\@gobble
%<latexrelease>  \let\index\@gobble
%<latexrelease>  \let\glossary\@gobble
%<latexrelease>  \baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
%<latexrelease>    \@begindvi
%<latexrelease>    \vskip \topmargin
%<latexrelease>    \moveright\@themargin \vbox {%
%<latexrelease>      \setbox\@tempboxa \vbox to\headheight{%
%<latexrelease>        \vfil
%<latexrelease>        \color@hbox
%<latexrelease>          \normalcolor
%<latexrelease>          \hb@xt@\textwidth{\@thehead}%
%<latexrelease>        \color@endbox
%<latexrelease>        }%
%<latexrelease>      \dp\@tempboxa \z@
%<latexrelease>      \box\@tempboxa
%<latexrelease>      \vskip \headsep
%<latexrelease>      \box\@outputbox
%<latexrelease>      \baselineskip \footskip
%<latexrelease>      \color@hbox
%<latexrelease>        \normalcolor
%<latexrelease>        \hb@xt@\textwidth{\@thefoot}%
%<latexrelease>      \color@endbox
%<latexrelease>      }%
%<latexrelease>    }%
%<latexrelease>  \global\let\if@newlist\@@if@newlist
%<latexrelease>  \global \@colht \textheight
%<latexrelease>  \stepcounter{page}%
%<latexrelease>  \let\firstmark\botmark
%<latexrelease>}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\@begindvi}
% \changes{v1.1c}{1994/11/05}
%         {Added macro}
% \changes{v1.1f}{1994/11/14}{Use normal box register: why a box?}
%
%    This unboxes stuff that must appear before anything else in the
%    |.dvi| file, then returns that box register to the free list and
%    cancels itself.
%
%    The stuff in the box should not add any typeset material to the
%    page.
%    \begin{macrocode}
\def \@begindvi{%
  \unvbox \@begindvibox
  \global\let \@begindvi \@empty
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
%
%
% \subsubsection{Dealing with floats}
%
%
%
% \begin{macro}{\@combinefloats}
% \changes{v1.4m}{2025/02/14}{Macro got a new name}
%    Old name for what is now called \cs{@outputbox@attachfloats};
%    kept to support legacy packages.
%    \begin{macrocode}
\let \@combinefloats \@outputbox@attachfloats
%    \end{macrocode}
% \end{macro}
%
%

% \begin{macro}{\@cflt}
% \changes{v1.0h}{1993/12/12}{name changed}
% \begin{macro}{\@cflb}
%    The |\boxmaxdepth| setting here was not made local to
%    a box so was dangerous.  It is needed only within the box made
%    by |\@cflt| (and not normally even there), so it has been
%    moved there; this also agrees with the original pseudocode.
%
% \changes{v1.0h}{1993/12/12}{boxmaxdepth setting moved}
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
%    \begin{macrocode}
\def \@cflt{%
    \let \@elt \@comflelt
    \setbox\@tempboxa \vbox{}%
    \@toplist
    \setbox\@outputbox \vbox{%
                             \boxmaxdepth \maxdepth
                             \unvbox\@tempboxa
                             \vskip -\floatsep
                             \topfigrule
                             \vskip \textfloatsep
                             \unvbox\@outputbox
                             }%
    \let\@elt\relax
    \xdef\@freelist{\@freelist\@toplist}%
    \global\let\@toplist\@empty
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def \@cflb {%
    \let\@elt\@comflelt
    \setbox\@tempboxa \vbox{}%
    \@botlist
    \setbox\@outputbox \vbox{%
                             \unvbox\@outputbox
                             \vskip \textfloatsep
                             \botfigrule
                             \unvbox\@tempboxa
                             \vskip -\floatsep
                             }%
    \let\@elt\relax
    \xdef\@freelist{\@freelist\@botlist}%
    \global \let \@botlist\@empty
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
% \begin{macro}{\@comflelt}
% \begin{macro}{\@comdblflelt}
% \begin{macro}{\@combinedblfloats}
%
%    \begin{macrocode}
\def\@comflelt#1{\setbox\@tempboxa
      \vbox{\unvbox\@tempboxa\box #1\vskip\floatsep}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@comdblflelt#1{\setbox\@tempboxa
      \vbox{\unvbox\@tempboxa\box #1\vskip\dblfloatsep}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def \@combinedblfloats{%
  \ifx \@dbltoplist \@empty
  \else
    \setbox\@tempboxa \vbox{}%
    \let \@elt \@comdblflelt
    \@dbltoplist
    \let \@elt \relax
    \xdef \@freelist {\@freelist\@dbltoplist}%
    \global\let \@dbltoplist \@empty
    \setbox\@outputbox \vbox to\textheight
%    \end{macrocode}
%
%    The setting of |\boxmaxdepth| here has no effect since the
%    |\@outputbox| should already have depth zero.  Even so, it would
%    have no effect on the layout of the page.
% \changes{v1.0l}{1994/03/15}{Removed boxmaxdepth setting.}
%    \begin{macrocode}
      {%
       \unvbox\@tempboxa\vskip-\dblfloatsep
%    \end{macrocode}
%    Here we need different typesetting if the top float comes from
%    |\@topnewpage|.
% \changes{v1.0n}{1994/04/30}{Removed rule in topnewpage case}
%    \begin{macrocode}
       \ifnum \@dbltopnum>\m@ne
         \dblfigrule
       \fi
       \vskip \dbltextfloatsep
%    \end{macrocode}
%    If pdf links are present in the galley and those links get broken
%   across pages they have to end up being on the same level of boxing
%   (even if not actually in the same structure) due to some engine
%   restrictions in pdf\TeX\ and Lua\TeX. We therefore unbox
%   |\@outputbox| here (which only contains a single |\hbox|) so that
%   this case has the same boxing level as a normal twocolumn page
%   without top floats.
% \changes{v1.4d}{2018/11/28}{Unbox \cs{@outputbox} to preserve boxing
%   level (github/94)}
%    \begin{macrocode}
       \unvbox\@outputbox
       }%
  \fi
}
%</2ekernel>
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%
%  \begin{macro}{\@startcolumn}
% \changes{v1.0f}{1993/12/05}{Command changed}
%  \begin{macro}{\@startdblcolumn}
% \changes{v1.0f}{1993/12/05}{Command changed}
%
%    We could combine (most of) these two into |\@startcol <list>|.
%    Note that |\@xstartcol| was only used once (\ie in
%    |\@startcolumn|); it has therefore been removed.  This is not quite
%    as efficient but it now has the same structure as
%    |\@startdblcolumn|.
%
%    The empty-list test has been moved to |\@tryfcolumn|.
%
%    \begin{macrocode}
%<*2ekernel|fltrace>
\def \@startcolumn {%
  \global \@colroom \@colht
  \@tryfcolumn \@deferlist
  \if@fcolmade
%<*trace>
    \fl@trace{PAGE: float \if@twocolumn column \else page \fi
                completed}%
%</trace>
  \else
%    \end{macrocode}
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
%    \begin{macrocode}
    \begingroup
      \let \reserved@b \@deferlist
      \global \let \@deferlist \@empty
      \let \@elt \@scolelt
      \reserved@b
    \endgroup
  \fi
}
%    \end{macrocode}
%
%    This one does not need to set |\@colht|.
%
% \changes{v1.2n}{2015/01/14}{float order in 2-column (latexrelease)}
%    \begin{macrocode}
%</2ekernel|fltrace>
%<latexrelease|fltrace>\IncludeInRelease{2015/01/01}%
%<latexrelease|fltrace>  {\@startdblcolumn}{float order in 2-column}%
%<*2ekernel|latexrelease|fltrace>
\def \@startdblcolumn {%
  \@tryfcolumn \@deferlist
  \if@fcolmade
%<fltrace>    \fl@trace{PAGE: double float page completed}%
  \else
    \begingroup
      \let \reserved@b \@deferlist
      \global \let \@deferlist \@empty
      \let \@elt \@sdblcolelt
      \reserved@b
    \endgroup
  \fi
}%
%</2ekernel|latexrelease|fltrace>
%<latexrelease|fltrace>\EndIncludeInRelease
%<latexrelease|fltrace>\IncludeInRelease{0000/00/00}%
%<latexrelease|fltrace>  {\@startdblcolumn}{float order in 2-column}%
%<latexrelease|fltrace>\def \@startdblcolumn {%
%    \end{macrocode}
% Not needed since this always comes after |\@outputpage|:
%    \begin{macrocode}
%<latexrelease|fltrace>% \global \@colht \textheight
%<latexrelease|fltrace>  \@tryfcolumn \@dbldeferlist
%<latexrelease|fltrace>  \if@fcolmade
%<*trace>
%<latexrelease|fltrace>    \fl@trace{PAGE: double float page completed}%
%</trace>
%<latexrelease|fltrace>  \else
%    \end{macrocode}
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
%    \begin{macrocode}
%<latexrelease|fltrace>    \begingroup
%<latexrelease|fltrace>      \let \reserved@b \@dbldeferlist
%<latexrelease|fltrace>      \global \let \@dbldeferlist \@empty
%<latexrelease|fltrace>      \let \@elt \@sdblcolelt
%<latexrelease|fltrace>      \reserved@b
%<latexrelease|fltrace>    \endgroup
%<latexrelease|fltrace>  \fi
%<latexrelease|fltrace>}%
%<latexrelease|fltrace>\EndIncludeInRelease
%<*2ekernel|fltrace>
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\@tryfcolumn}
% \changes{v1.0f}{1993/12/05}{Command changed}
%    Now tests if its list is empty before any further exertion.
%
%    \begin{macrocode}
\def \@tryfcolumn #1{%
  \global \@fcolmadefalse
  \ifx #1\@empty
  \else
%<*trace>
     \fl@trace{PAGE: try float \if@twocolumn column/page\else page\fi
                  ---\string #1}%
     \fl@trace{----- \string #1: #1}%
%</trace>
%    \end{macrocode}
% \changes{v1.0h}{1993/12/12}{defs changed to lets}
%    \begin{macrocode}
    \xdef\@trylist{#1}%
    \global \let \@failedlist \@empty
    \begingroup
      \let \@elt \@xtryfc \@trylist
    \endgroup
    \if@fcolmade
      \@vtryfc #1%
    \fi
  \fi
}
%</2ekernel|fltrace>
%    \end{macrocode}
%
%  \end{macro}
%
%    \begin{macrocode}
%<*2ekernel>
%    \end{macrocode}
%
% \begin{macro}{\@scolelt}
%    \begin{macrocode}
\def\@scolelt#1{\def\@currbox{#1}\@addtonextcol}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sdblcolelt}
%    \begin{macrocode}
\def\@sdblcolelt#1{\def\@currbox{#1}\@addtodblcol}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@vtryfc}
% \changes{v1.2d}{1997/11/19}{Reindent code, to be understandable(DPC).}
%    \begin{macrocode}
\def\@vtryfc #1{%
  \global\setbox\@outputbox\vbox{}%
  \let\@elt\@wtryfc
  \@flsucceed
  \global\setbox\@outputbox \vbox to\@colht{%
    \vskip \@fptop
    \vskip -\@fpsep
    \unvbox \@outputbox
    \vskip \@fpbot}%
  \let\@elt\relax
  \xdef #1{\@failedlist\@flfail}%
  \xdef\@freelist{\@freelist\@flsucceed}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@wtryfc}
%    \begin{macrocode}
\def\@wtryfc #1{%
  \global\setbox\@outputbox\vbox{%
    \unvbox\@outputbox
    \vskip\@fpsep
    \box #1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xtryfc}
% \changes{v1.1v}{1996/07/26}{remove \cs{global} before \cs{@test...}}
% \changes{v1.2n}{2015/01/14}{float order in 2-column (latexrelease)}
%    \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2015/01/01}{\@xtryfc}%
%<latexrelease>                             {float order in 2-column}%
%<*2ekernel|latexrelease>
\def\@xtryfc #1{%
  \@next\reserved@a\@trylist{}{}%
  \@currtype \count #1%
  \divide\@currtype\@xxxii
  \multiply\@currtype\@xxxii
  \@bitor \@currtype \@failedlist
  \@testfp #1%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@testwrongwidth #1%
%    \end{macrocode}
%
%    \begin{macrocode}
  \ifdim \ht #1>\@colht
     \@testtrue
  \fi
  \if@test
    \@cons\@failedlist #1%
  \else
    \@ytryfc #1%
  \fi}%
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}{\@xtryfc}%
%<latexrelease>                             {float order in 2-column}%
%<latexrelease>\def\@xtryfc #1{%
%<latexrelease>  \@next\reserved@a\@trylist{}{}%
%<latexrelease>  \@currtype \count #1%
%<latexrelease>  \divide\@currtype\@xxxii
%<latexrelease>  \multiply\@currtype\@xxxii
%<latexrelease>  \@bitor \@currtype \@failedlist
%<latexrelease>  \@testfp #1%
%<latexrelease>  \ifdim \ht #1>\@colht
%<latexrelease>    \@testtrue
%<latexrelease>  \fi
%<latexrelease>  \if@test
%<latexrelease>    \@cons\@failedlist #1%
%<latexrelease>  \else
%<latexrelease>    \@ytryfc #1%
%<latexrelease>  \fi}%
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ytryfc}
%    \begin{macrocode}
\def\@ytryfc #1{%
  \begingroup
    \gdef\@flsucceed{\@elt #1}%
    \global\let\@flfail\@empty
    \@tempdima\ht #1%
    \let\@elt\@ztryfc
    \@trylist
    \ifdim \@tempdima >\@fpmin
      \global\@fcolmadetrue
    \else
      \@cons\@failedlist #1%
    \fi
  \endgroup
  \if@fcolmade
    \let\@elt\@gobble
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ztryfc}
% \changes{v1.1v}{1996/07/26}{remove \cs{global} before \cs{@test...}}
% \changes{v1.2n}{2015/01/14}{float order in 2-column (latexrelease)}
%    \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2015/01/01}{@ztryfc}%
%<latexrelease>                             {float order in 2-column}%
%<*2ekernel|latexrelease>
\def\@ztryfc #1{%
  \@tempcnta\count #1%
  \divide\@tempcnta\@xxxii
  \multiply\@tempcnta\@xxxii
  \@bitor \@tempcnta {\@failedlist \@flfail}%
  \@testfp #1%
%    \end{macrocode}
%
% not in fixfloats?
%    \begin{macrocode}
  \@testwrongwidth #1%
%    \end{macrocode}
%
%    \begin{macrocode}
  \@tempdimb\@tempdima
  \advance\@tempdimb\ht #1%
  \advance\@tempdimb\@fpsep
  \ifdim \@tempdimb >\@colht
    \@testtrue
  \fi
  \if@test
    \@cons\@flfail #1%
  \else
    \@cons\@flsucceed #1%
    \@tempdima\@tempdimb
  \fi}%
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}{@ztryfc}%
%<latexrelease>                             {float order in 2-column}%
%<latexrelease>\def\@ztryfc #1{%
%<latexrelease>  \@tempcnta \count#1%
%<latexrelease>  \divide\@tempcnta\@xxxii
%<latexrelease>  \multiply\@tempcnta\@xxxii
%<latexrelease>  \@bitor \@tempcnta {\@failedlist \@flfail}%
%<latexrelease>  \@testfp #1%
%<latexrelease>  \@tempdimb\@tempdima
%<latexrelease>  \advance\@tempdimb \ht#1%
%<latexrelease>  \advance\@tempdimb\@fpsep
%<latexrelease>  \ifdim \@tempdimb >\@colht
%<latexrelease>    \@testtrue
%<latexrelease>  \fi
%<latexrelease>  \if@test
%<latexrelease>    \@cons\@flfail #1%
%<latexrelease>  \else
%<latexrelease>    \@cons\@flsucceed #1%
%<latexrelease>    \@tempdima\@tempdimb
%<latexrelease>  \fi}%
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
% \end{macro}
%
%
% The major changes for float suppression and the changes to the float
% mechanism to make it conform to the documentation are in these next
% macros.
%
%  \begin{macro}{\@addtobot}
% \changes{v1.0f}{1993/12/05}{Command changed}
%    Lots of changes.
%
%    \begin{macrocode}
%<*2ekernel|fltrace>
\def \@addtobot {%
%<*trace>
   \fl@trace{***Start addtobot}%
%</trace>
   \@getfpsbit 4\relax
%<*trace>
   \fl@trace{fpstype \ifodd \@tempcnta OK \else not \fi bot:
                                                     \the \@fpstype}%
%</trace>
   \ifodd \@tempcnta
     \@flsetnum \@botnum
     \ifnum \@botnum>\z@
       \@tempswafalse
       \@flcheckspace \@botroom \@botlist
       \if@tempswa
%    \end{macrocode}
%  \changes{v1.4r}{2025/03/25}{Don't set \cs{maxdepth}
%       to zero any more (footmisc/19)}
%    \begin{macrocode}
%         \global \maxdepth \z@
         \@flupdates \@botnum \@botroom \@botlist
%<*trace>
         \fl@trace{colroom (after-bot) = \the \@colroom}%
         \fl@trace{colnum (after-bot) = \the \@colnum}%
         \fl@trace{botnum (after-bot) = \the \@botnum}%
         \fl@trace{***Success: bot}%
%</trace>
         \@inserttrue
       \fi
%<*trace>
     \else
       \fl@trace{Fail: botnum = \the \@botnum:
                                  fpstype \the \@fpstype=ORD?}%
       \ifnum \@fpstype<\sixt@@n
         \fl@trace{ERROR: !b float not successful (addtobot)}%
       \fi
%</trace>
     \fi
   \fi
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@addtotoporbot}
% \changes{v1.0f}{1993/12/05}{Command changed}
%    Lots of changes.
%
%    \begin{macrocode}
\def \@addtotoporbot {%
%<*trace>
   \fl@trace{***Start addtotoporbot}%
%</trace>
   \@getfpsbit \tw@
%<*trace>
   \fl@trace{fpstype \ifodd \@tempcnta OK \else not \fi top:
                                                     \the \@fpstype}%
%</trace>
   \ifodd \@tempcnta
     \@flsetnum \@topnum
     \ifnum \@topnum>\z@
       \@tempswafalse
       \@flcheckspace \@toproom \@toplist
       \if@tempswa
         \@bitor\@currtype{\@midlist\@botlist}%
%<*trace>
           \fl@trace{(mid+bot)list: \@midlist, \@botlist:
                              (addtotoporbot-before)}%
%</trace>
         \if@test
%<*trace>
         \fl@trace{type already on list: mid or bot---sent to addtobot}%
%</trace>
         \else
          \@flupdates \@topnum \@toproom \@toplist
%<*trace>
          \fl@trace{colroom (after-top) = \the \@colroom}%
          \fl@trace{colnum (after-top) = \the \@colnum}%
          \fl@trace{topnum (after-top) = \the \@topnum}%
          \fl@trace{***Success: top}%
%</trace>
          \@inserttrue
         \fi
       \fi
%<*trace>
     \else
       \fl@trace{Fail: topnum = \the \@topnum: fpstype
                                            \the \@fpstype=ORD?}%
       \ifnum \@fpstype<\sixt@@n
         \fl@trace{ERROR: !t float not successful (addtotoporbot)}%
       \fi
%</trace>
     \fi
   \fi
   \if@insert
   \else
%<*trace>
     \fl@trace{sent to addtobot (addtotoporbot)}%
%</trace>
     \@addtobot
   \fi
}
%</2ekernel|fltrace>
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@addtocurcol}
% \changes{v1.0f}{1993/12/05}{Command changed}
% \task{CAR}{Add rules around h floats for FMi}
% \task{CAR}{Investigate pagebreak option possibilities}
%    Lots of changes.
%
% \changes{v1.2n}{2015/01/14}{float order in 2-column (latexrelease)}
%    \begin{macrocode}
%<latexrelease|fltrace|flafter>\IncludeInRelease{2025/06/01}%
%<latexrelease|fltrace|flafter>  {\@addtocurcol}{float order in 2-column}%
%<*2ekernel|latexrelease|fltrace|flafter>
\def \@addtocurcol {%
%<*trace>
  \fl@trace{***Start addtocurcol}%
%</trace>
   \@insertfalse
   \@setfloattypecounts
   \ifnum \@fpstype=8
%<*trace>
     \fl@trace{fpstype !p only (addtocurcol): \the \@fpstype = 8?}%
%</trace>
   \else
     \ifnum \@fpstype=24
%<*trace>
       \fl@trace{fpstype p only (addtocurcol): \the \@fpstype = 24?}%
%</trace>
     \else
       \@flsettextmin
%    \end{macrocode}
% This is a new adjustment which is quite a major change in
% functionality; but it implements the documentation.
% Note that |\@reqcolroom| will include the whole of the
% page-so-far, and hence includes |\@textfloatsheight| of floats,
% so before comparing it with |\@textmin|, we add this to
% |\@textmin| also.
%    \begin{macrocode}
%<*trace>
       \fl@trace{textfloatsheight (before) = \the \@textfloatsheight}%
%</trace>
       \advance \@textmin \@textfloatsheight
       \@reqcolroom \@pageht
%    \end{macrocode}
% This line must be removed since |\@specialoutput| changed.
%    \begin{macrocode}
%       \advance \@reqcolroom \@pagedp
%<*trace>
       \fl@trace{textmin + textfloatsheight: \the \@textmin}%
       \fl@trace{page-so-far: \the \@reqcolroom}%
%</trace>
       \ifdim \@textmin>\@reqcolroom
         \@reqcolroom \@textmin
%<*trace>
         \fl@trace{ORD? textmin being used}%
%</trace>
       \fi
       \advance \@reqcolroom \ht\@currbox
%    \end{macrocode}
%    We save the current value of \cs{@reqcolroom} so that we can
%    return to this value later, in case a test fails that may have added
%    something to it.
%  \changes{v1.4n}{2025/01/29}{Save current value of \cs{@reqcolroom} (gh/1645)}
%    \begin{macrocode}
       \saved@reqcolroom \@reqcolroom
%<*trace>
       \fl@trace{float size = \the \ht \@currbox (addtocurcol)}%
       \fl@trace{colroom = \the \@colroom (addtocurcol)}%
       \fl@trace{reqcolroom = \the \@reqcolroom (addtocurcol)}%
%</trace>
       \ifdim \@colroom>\@reqcolroom
         \@flsetnum \@colnum
         \ifnum \@colnum>\z@
           \@bitor\@currtype\@deferlist
%    \end{macrocode}
%    We need to defer the float also if its width
%    doesn't fit.
% \changes{v1.2n}{2000/09/24}{FMi: test for wide float was
%    in wrong place}
%    \begin{macrocode}
          \@testwrongwidth\@currbox
%    \end{macrocode}
%
%    \begin{macrocode}
%<*trace>
           \fl@trace{deferlist: \@deferlist: (addtocurcol-before)}%
%</trace>
           \if@test
%<*trace>
             \fl@trace{type already on list: defer (addtocurcol)}%
%</trace>
           \else
             \@bitor\@currtype\@botlist
%<*trace>
           \fl@trace{botlist: \@botlist: (addtocurcol-before)}%
%</trace>
             \if@test
%<*trace>
               \fl@trace{type already on list: bot---sent to addtobot}%
%</trace>
               \@addtobot
             \else
%<*trace>
               \fl@trace{fpstype \ifodd \@tempcnta OK \else not \fi
                      here: \the \@fpstype}%
%</trace>
               \ifodd \count\@currbox
                 \advance \@reqcolroom \intextsep
                 \ifdim \@colroom>\@reqcolroom
                   \global \advance \@colnum \m@ne
                   \global \advance \@textfloatsheight \ht\@currbox
%    \end{macrocode}
% This may sometimes give an overestimate.
%    \begin{macrocode}
                   \global \advance \@textfloatsheight 2\intextsep
                   \@cons \@midlist \@currbox
%<*trace>
                 \fl@trace{***Success: here}%
                 \fl@trace{textfloatsheight (after-here) =
                      \the \@textfloatsheight}%
                 \fl@trace{colnum (after-here) = \the \@colnum}%
%</trace>
%    \end{macrocode}
%
% CHANGE TO |\@addtocurcol|:
%
% |\penalty\z@| changed to |\penalty\interlinepenalty| so |\samepage|
% works properly with figure and table environments.
% (Changed 23 Oct 86)
%
% There is also an |\addpenalty\interlinepenalty| above.
%
% Although it is best to use |\addvspace| in case two h floats come
% together, this makes other spacing more difficult to adjust; whereas
% if a user specifies two h floats together then they can more easily
% get the spacing correct by ad hoc commands.
%
% It is necessary to adjust for the addition of |\parskip| here in
% case the float is added between paragraphs (\ie when in vertical
% mode).
%
% If the nobreak switch is true we need to reset it and clear
% |\everypar| since the float may not reset the flag and cannot reset
% the |\everypar| globally.
% \changes{v1.0l}{1994/03/15}{Changed \cs{addvspace} to \cs{vskip}}
% \changes{v1.1i}{1994/11/21}
%   {Added \cs{if@nobreak} test before float box}
% \changes{v1.1z}{1996/10/24}{Added \cs{nobreak}, etc as appropriate}
%
% Typesetting starts here (we are in vertical mode).
%    \begin{macrocode}
                   \if@nobreak
                     \nobreak
                     \@nobreakfalse
                     \everypar{}%
                   \else
                     \addpenalty \interlinepenalty
                   \fi
                   \vskip \intextsep
                   \box\@currbox
                   \penalty\interlinepenalty
                   \vskip\intextsep
                   \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
%    \end{macrocode}
% Typesetting ends here.
%    \begin{macrocode}
                   \outputpenalty \z@
                   \@inserttrue
%<*trace>
                 \else
                   \fl@trace{Fail---no room at 2nd test of colroom
                                 (addtocorcol \string\intextsep)}%
%</trace>
                 \fi
               \fi
               \if@insert
               \else
%    \end{macrocode}
%   Next set of docstrip guards are a bit weird, essentially
%   |\@addtotoporbot| ends up inside the kernel and the
%   \texttt{fltrace} package and |\@addtobot| shows up in the
%   \texttt{flafter} package. Guess that could have been done a bit
%   more obvious :-)
%    \begin{macrocode}
%<*2ekernel|fltrace|latexrelease>
%<*trace>
                 \fl@trace{not here: sent to addtotoporbot}%
%</trace>
                 \@addtotoporbot
%</2ekernel|fltrace|latexrelease>
%<*!2ekernel&!fltrace&!latexrelease>
%<*trace>
                 \fl@trace{not here: sent to addtobot}%
%</trace>
                 \@addtobot
%</!2ekernel&!fltrace&!latexrelease>
               \fi
             \fi
           \fi
%<*trace>
         \else
           \fl@trace{Fail: colnum = \the \@colnum:
                        fpstype \the \@fpstype=ORD?}%
           \ifnum \@fpstype<\sixt@@n
             \fl@trace{ERROR: BANG float not successful (addtocurcol)}%
           \fi
%</trace>
         \fi
%<*trace>
       \else
         \fl@trace{Fail---no room: fl box ht: \the \ht \@currbox
                                                     (addtocurcol)}%
%</trace>
       \fi
     \fi
   \fi
   \if@insert
   \else
     \@resethfps
%<*trace>
     \fl@trace{put on deferlist (addtocurcol)}%
%</trace>
     \@cons\@deferlist\@currbox
%<*trace>
     \fl@trace{deferlist: \@deferlist: (addtocurcol-after)}%
%</trace>
   \fi
}%
%</2ekernel|latexrelease|fltrace|flafter>
%<latexrelease|fltrace|flafter>\EndIncludeInRelease
%    \end{macrocode}
%    The rollback code is rather complicated as it has to account for
%    the fact that we roll back not just the kernel but also the
%    packages \pkg{flafter} and \pkg{fltrace}.
%    \begin{macrocode}
%<latexrelease|fltrace|flafter>\IncludeInRelease{2015/01/01}%
%<latexrelease|fltrace|flafter>  {\@addtocurcol}{float order in 2-column}%
%<latexrelease|fltrace|flafter>\def \@addtocurcol {%
%<*trace>
%<latexrelease|fltrace|flafter>  \fl@trace{***Start addtocurcol}%
%</trace>
%<latexrelease|fltrace|flafter>   \@insertfalse
%<latexrelease|fltrace|flafter>   \@setfloattypecounts
%<latexrelease|fltrace|flafter>   \ifnum \@fpstype=8
%<*trace>
%<latexrelease|fltrace|flafter>     \fl@trace{fpstype !p only (addtocurcol): \the \@fpstype = 8?}%
%</trace>
%<latexrelease|fltrace|flafter>   \else
%<latexrelease|fltrace|flafter>     \ifnum \@fpstype=24
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{fpstype p only (addtocurcol): \the \@fpstype = 24?}%
%</trace>
%<latexrelease|fltrace|flafter>     \else
%<latexrelease|fltrace|flafter>       \@flsettextmin
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{textfloatsheight (before) = \the \@textfloatsheight}%
%</trace>
%<latexrelease|fltrace|flafter>       \advance \@textmin \@textfloatsheight
%<latexrelease|fltrace|flafter>       \@reqcolroom \@pageht
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{textmin + textfloatsheight: \the \@textmin}%
%<latexrelease|fltrace|flafter>       \fl@trace{page-so-far: \the \@reqcolroom}%
%</trace>
%<latexrelease|fltrace|flafter>       \ifdim \@textmin>\@reqcolroom
%<latexrelease|fltrace|flafter>         \@reqcolroom \@textmin
%<*trace>
%<latexrelease|fltrace|flafter>         \fl@trace{ORD? textmin being used}%
%</trace>
%<latexrelease|fltrace|flafter>       \fi
%<latexrelease|fltrace|flafter>       \advance \@reqcolroom \ht\@currbox
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{float size = \the \ht \@currbox (addtocurcol)}%
%<latexrelease|fltrace|flafter>       \fl@trace{colroom = \the \@colroom (addtocurcol)}%
%<latexrelease|fltrace|flafter>       \fl@trace{reqcolroom = \the \@reqcolroom (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>       \ifdim \@colroom>\@reqcolroom
%<latexrelease|fltrace|flafter>         \@flsetnum \@colnum
%<latexrelease|fltrace|flafter>         \ifnum \@colnum>\z@
%<latexrelease|fltrace|flafter>           \@bitor\@currtype\@deferlist
%<latexrelease|fltrace|flafter>          \@testwrongwidth\@currbox
%<*trace>
%<latexrelease|fltrace|flafter>           \fl@trace{deferlist: \@deferlist: (addtocurcol-before)}%
%</trace>
%<latexrelease|fltrace|flafter>           \if@test
%<*trace>
%<latexrelease|fltrace|flafter>             \fl@trace{type already on list: defer (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>           \else
%<latexrelease|fltrace|flafter>             \@bitor\@currtype\@botlist
%<*trace>
%<latexrelease|fltrace|flafter>           \fl@trace{botlist: \@botlist: (addtocurcol-before)}%
%</trace>
%<latexrelease|fltrace|flafter>             \if@test
%<*trace>
%<latexrelease|fltrace|flafter>               \fl@trace{type already on list: bot---sent to addtobot}%
%</trace>
%<latexrelease|fltrace|flafter>               \@addtobot
%<latexrelease|fltrace|flafter>             \else
%<*trace>
%<latexrelease|fltrace|flafter>               \fl@trace{fpstype \ifodd \@tempcnta OK \else not \fi
%<latexrelease|fltrace|flafter>                      here: \the \@fpstype}%
%</trace>
%<latexrelease|fltrace|flafter>               \ifodd \count\@currbox
%<latexrelease|fltrace|flafter>                 \advance \@reqcolroom \intextsep
%<latexrelease|fltrace|flafter>                 \ifdim \@colroom>\@reqcolroom
%<latexrelease|fltrace|flafter>                   \global \advance \@colnum \m@ne
%<latexrelease|fltrace|flafter>                   \global \advance \@textfloatsheight \ht\@currbox
%<latexrelease|fltrace|flafter>                   \global \advance \@textfloatsheight 2\intextsep
%<latexrelease|fltrace|flafter>                   \@cons \@midlist \@currbox
%<*trace>
%<latexrelease|fltrace|flafter>                 \fl@trace{***Success: here}%
%<latexrelease|fltrace|flafter>                 \fl@trace{textfloatsheight (after-here) =
%<latexrelease|fltrace|flafter>                      \the \@textfloatsheight}%
%<latexrelease|fltrace|flafter>                 \fl@trace{colnum (after-here) = \the \@colnum}%
%</trace>
%<latexrelease|fltrace|flafter>                   \if@nobreak
%<latexrelease|fltrace|flafter>                     \nobreak
%<latexrelease|fltrace|flafter>                     \@nobreakfalse
%<latexrelease|fltrace|flafter>                     \everypar{}%
%<latexrelease|fltrace|flafter>                   \else
%<latexrelease|fltrace|flafter>                     \addpenalty \interlinepenalty
%<latexrelease|fltrace|flafter>                   \fi
%<latexrelease|fltrace|flafter>                   \vskip \intextsep
%<latexrelease|fltrace|flafter>                   \box\@currbox
%<latexrelease|fltrace|flafter>                   \penalty\interlinepenalty
%<latexrelease|fltrace|flafter>                   \vskip\intextsep
%<latexrelease|fltrace|flafter>                   \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
%<latexrelease|fltrace|flafter>                   \outputpenalty \z@
%<latexrelease|fltrace|flafter>                   \@inserttrue
%<*trace>
%<latexrelease|fltrace|flafter>                 \else
%<latexrelease|fltrace|flafter>                   \fl@trace{Fail---no room at 2nd test of colroom
%<latexrelease|fltrace|flafter>                                 (addtocorcol \string\intextsep)}%
%</trace>
%<latexrelease|fltrace|flafter>                 \fi
%<latexrelease|fltrace|flafter>               \fi
%<latexrelease|fltrace|flafter>               \if@insert
%<latexrelease|fltrace|flafter>               \else
%<*trace>
%<fltrace|latexrelease>                 \fl@trace{not here: sent to addtotoporbot}%
%</trace>
%<fltrace|latexrelease>                 \@addtotoporbot
%<*trace>
%<flafter>                 \fl@trace{not here: sent to addtobot}%
%</trace>
%<flafter>                 \@addtobot
%<latexrelease|fltrace|flafter>               \fi
%<latexrelease|fltrace|flafter>             \fi
%<latexrelease|fltrace|flafter>           \fi
%<*trace>
%<latexrelease|fltrace|flafter>         \else
%<latexrelease|fltrace|flafter>           \fl@trace{Fail: colnum = \the \@colnum:
%<latexrelease|fltrace|flafter>                        fpstype \the \@fpstype=ORD?}%
%<latexrelease|fltrace|flafter>           \ifnum \@fpstype<\sixt@@n
%<latexrelease|fltrace|flafter>             \fl@trace{ERROR: BANG float not successful (addtocurcol)}%
%<latexrelease|fltrace|flafter>           \fi
%</trace>
%<latexrelease|fltrace|flafter>         \fi
%<*trace>
%<latexrelease|fltrace|flafter>       \else
%<latexrelease|fltrace|flafter>         \fl@trace{Fail---no room: fl box ht: \the \ht \@currbox
%<latexrelease|fltrace|flafter>                                                     (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>       \fi
%<latexrelease|fltrace|flafter>     \fi
%<latexrelease|fltrace|flafter>   \fi
%<latexrelease|fltrace|flafter>   \if@insert
%<latexrelease|fltrace|flafter>   \else
%<latexrelease|fltrace|flafter>     \@resethfps
%<*trace>
%<latexrelease|fltrace|flafter>     \fl@trace{put on deferlist (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>     \@cons\@deferlist\@currbox
%<*trace>
%<latexrelease|fltrace|flafter>     \fl@trace{deferlist: \@deferlist: (addtocurcol-after)}%
%</trace>
%<latexrelease|fltrace|flafter>   \fi
%<latexrelease|fltrace|flafter>}%
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease|fltrace|flafter>\EndIncludeInRelease
%<latexrelease|fltrace|flafter>\IncludeInRelease{0000/00/00}%
%<latexrelease|fltrace|flafter>  {\@addtocurcol}{float order in 2-column}%
%<latexrelease|fltrace|flafter>\def \@addtocurcol {%
%<*trace>
%<latexrelease|fltrace|flafter>  \fl@trace{***Start addtocurcol}%
%</trace>
%<latexrelease|fltrace|flafter>   \@insertfalse
%<latexrelease|fltrace|flafter>   \@setfloattypecounts
%<latexrelease|fltrace|flafter>   \ifnum \@fpstype=8
%<*trace>
%<latexrelease|fltrace|flafter>     \fl@trace{fpstype !p only (addtocurcol):
%<latexrelease|fltrace|flafter>                            \the \@fpstype = 8?}%
%</trace>
%<latexrelease|fltrace|flafter>   \else
%<latexrelease|fltrace|flafter>     \ifnum \@fpstype=24
%<*trace>
%<latexrelease|fltrace|flafter>      \fl@trace{fpstype p only (addtocurcol):
%<latexrelease|fltrace|flafter>                           \the \@fpstype = 24?}%
%</trace>
%<latexrelease|fltrace|flafter>     \else
%<latexrelease|fltrace|flafter>       \@flsettextmin
%    \end{macrocode}
% This is a new adjustment which is quite a major change in
% functionality; but it implements the documentation.
% Note that |\@reqcolroom| will include the whole of the
% page-so-far, and hence includes |\@textfloatsheight| of floats,
% so before comparing it with |\@textmin|, we add this to
% |\@textmin| also.
%    \begin{macrocode}
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{textfloatsheight (before) =
%<latexrelease|fltrace|flafter>                        \the \@textfloatsheight}%
%</trace>
%<latexrelease|fltrace|flafter>       \advance \@textmin \@textfloatsheight
%<latexrelease|fltrace|flafter>       \@reqcolroom \@pageht
%    \end{macrocode}
% This line must be removed since |\@specialoutput| changed.
%    \begin{macrocode}
%       \advance \@reqcolroom \@pagedp
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{textmin + textfloatsheight:
%<latexrelease|fltrace|flafter>                                 \the \@textmin}%
%<latexrelease|fltrace|flafter>       \fl@trace{page-so-far: \the \@reqcolroom}%
%<latexrelease|fltrace|flafter>
%</trace>
%<latexrelease|fltrace|flafter>       \ifdim \@textmin>\@reqcolroom
%<latexrelease|fltrace|flafter>         \@reqcolroom \@textmin
%<*trace>
%<latexrelease|fltrace|flafter>         \fl@trace{ORD? textmin being used}%
%</trace>
%<latexrelease|fltrace|flafter>       \fi
%<latexrelease|fltrace|flafter>       \advance \@reqcolroom \ht\@currbox
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{float size =
%<latexrelease|fltrace|flafter>               \the \ht \@currbox (addtocurcol)}%
%<latexrelease|fltrace|flafter>       \fl@trace{colroom =
%<latexrelease|fltrace|flafter>                   \the \@colroom (addtocurcol)}%
%<latexrelease|fltrace|flafter>       \fl@trace{reqcolroom =
%<latexrelease|fltrace|flafter>                \the \@reqcolroom (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>       \ifdim \@colroom>\@reqcolroom
%<latexrelease|fltrace|flafter>         \@flsetnum \@colnum
%<latexrelease|fltrace|flafter>         \ifnum \@colnum>\z@
%<latexrelease|fltrace|flafter>           \@bitor\@currtype\@deferlist
%<*trace>
%<latexrelease|fltrace|flafter>           \fl@trace{deferlist:
%<latexrelease|fltrace|flafter>              \@deferlist: (addtocurcol-before)}%
%</trace>
%<latexrelease|fltrace|flafter>           \if@test
%<*trace>
%<latexrelease|fltrace|flafter>             \fl@trace{type already on list:
%<latexrelease|fltrace|flafter>                            defer (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>           \else
%<latexrelease|fltrace|flafter>             \@bitor\@currtype\@botlist
%<*trace>
%<latexrelease|fltrace|flafter>           \fl@trace{botlist: \@botlist:
%<latexrelease|fltrace|flafter>                           (addtocurcol-before)}%
%</trace>
%<latexrelease|fltrace|flafter>             \if@test
%<*trace>
%<latexrelease|fltrace|flafter>               \fl@trace{type already on list:
%<latexrelease|fltrace|flafter>                         bot---sent to addtobot}%
%</trace>
%<latexrelease|fltrace|flafter>               \@addtobot
%<latexrelease|fltrace|flafter>             \else
%<*trace>
%<latexrelease|fltrace|flafter>               \fl@trace{fpstype
%<latexrelease|fltrace|flafter>               \ifodd \@tempcnta OK \else not \fi
%<latexrelease|fltrace|flafter>               here: \the \@fpstype}%
%</trace>
%<latexrelease|fltrace|flafter>               \ifodd \count\@currbox
%<latexrelease|fltrace|flafter>                 \advance \@reqcolroom \intextsep
%<latexrelease|fltrace|flafter>                 \ifdim \@colroom>\@reqcolroom
%<latexrelease|fltrace|flafter>                  \global \advance \@colnum \m@ne
%<latexrelease|fltrace|flafter>                  \global \advance
%<latexrelease|fltrace|flafter>                   \@textfloatsheight\ht\@currbox
%    \end{macrocode}
% This may sometimes give an overestimate.
%    \begin{macrocode}
%<latexrelease|fltrace|flafter>                  \global \advance
%<latexrelease|fltrace|flafter>                   \@textfloatsheight 2\intextsep
%<latexrelease|fltrace|flafter>                   \@cons \@midlist \@currbox
%<*trace>
%<latexrelease|fltrace|flafter>                 \fl@trace{***Success: here}%
%<latexrelease|fltrace|flafter>                 \fl@trace{textfloatsheight
%<latexrelease|fltrace|flafter>                      (after-here) =
%<latexrelease|fltrace|flafter>                      \the \@textfloatsheight}%
%<latexrelease|fltrace|flafter>                 \fl@trace{colnum (after-here) =
%<latexrelease|fltrace|flafter>                          \the \@colnum}%
%</trace>
%    \end{macrocode}
%
% CHANGE TO |\@addtocurcol|:
%
% |\penalty\z@| changed to |\penalty\interlinepenalty| so |\samepage|
% works properly with figure and table environments.
% (Changed 23 Oct 86)
%
% There is also an |\addpenalty\interlinepenalty| above.
%
% Although it is best to use |\addvspace| in case two h floats come
% together, this makes other spacing more difficult to adjust; whereas
% if a user specifies two h floats together then they can more easily
% get the spacing correct by ad hoc commands.
%
% It is necessary to adjust for the addition of |\parskip| here in
% case the float is added between paragraphs (\ie when in vertical
% mode).
%
% If the nobreak switch is true we need to reset it and clear
% |\everypar| since the float may not reset the flag and cannot reset
% the |\everypar| globally.
% \changes{v1.0l}{1994/03/15}{Changed \cs{addvspace} to \cs{vskip}}
% \changes{v1.1i}{1994/11/21}
%   {Added \cs{if@nobreak} test before float box}
% \changes{v1.1z}{1996/10/24}{Added \cs{nobreak}, etc as appropriate}
%
% Typesetting starts here (we are in vertical mode).
%    \begin{macrocode}
%<latexrelease|fltrace|flafter>                   \if@nobreak
%<latexrelease|fltrace|flafter>                     \nobreak
%<latexrelease|fltrace|flafter>                     \@nobreakfalse
%<latexrelease|fltrace|flafter>                     \everypar{}%
%<latexrelease|fltrace|flafter>                   \else
%<latexrelease|fltrace|flafter>                     \addpenalty\interlinepenalty
%<latexrelease|fltrace|flafter>                   \fi
%<latexrelease|fltrace|flafter>                   \vskip \intextsep
%<latexrelease|fltrace|flafter>                   \box\@currbox
%<latexrelease|fltrace|flafter>                   \penalty\interlinepenalty
%<latexrelease|fltrace|flafter>                   \vskip\intextsep
%<latexrelease|fltrace|flafter>                   \ifnum\outputpenalty
%<latexrelease|fltrace|flafter>                               <-\@Mii \vskip
%<latexrelease|fltrace|flafter>                        -\parskip\fi
%    \end{macrocode}
% Typesetting ends here.
%    \begin{macrocode}
%<latexrelease|fltrace|flafter>                   \outputpenalty \z@
%<latexrelease|fltrace|flafter>                   \@inserttrue
%<*trace>
%<latexrelease|fltrace|flafter>                 \else
%<latexrelease|fltrace|flafter>  \fl@trace{Fail---no room at 2nd test of colroom
%<latexrelease|fltrace|flafter>                (addtocorcol \string\intextsep)}%
%</trace>
%<latexrelease|fltrace|flafter>                 \fi
%<latexrelease|fltrace|flafter>               \fi
%<latexrelease|fltrace|flafter>               \if@insert
%<latexrelease|fltrace|flafter>               \else
%    \end{macrocode}
%   Next set of docstrip guards are a bit weird, essentially
%   |\@addtotoporbot| ends up inside the kernel and the
%   \texttt{fltrace} package and |\@addtotoporbot| shows up in the
%   \texttt{flafter} package. Guess that could have been done a bit
%   more obvious :-)
%    \begin{macrocode}
%<*2ekernel|fltrace>
%<*trace>
%<latexrelease|fltrace|flafter>      \fl@trace{not here: sent to addtotoporbot}%
%</trace>
%<latexrelease|fltrace|flafter>                 \@addtotoporbot
%</2ekernel|fltrace>
%<*!2ekernel&!autoload&!fltrace>
%<*trace>
%<latexrelease|fltrace|flafter>       \fl@trace{not here: sent to addtobot}%
%</trace>
%<latexrelease|fltrace|flafter>                 \@addtobot
%</!2ekernel&!autoload&!fltrace>
%<latexrelease|fltrace|flafter>               \fi
%<latexrelease|fltrace|flafter>             \fi
%<latexrelease|fltrace|flafter>           \fi
%<*trace>
%<latexrelease|fltrace|flafter>         \else
%<latexrelease|fltrace|flafter>         \fl@trace{Fail: colnum = \the \@colnum:
%<latexrelease|fltrace|flafter>                    fpstype \the \@fpstype=ORD?}%
%<latexrelease|fltrace|flafter>         \ifnum \@fpstype<\sixt@@n
%<latexrelease|fltrace|flafter>  \fl@trace{ERROR: BANG float not successful
%<latexrelease|fltrace|flafter>                                  (addtocurcol)}%
%<latexrelease|fltrace|flafter>           \fi
%</trace>
%<latexrelease|fltrace|flafter>         \fi
%<*trace>
%<latexrelease|fltrace|flafter>       \else
%<latexrelease|fltrace|flafter>         \fl@trace{Fail---no room: fl box ht:
%<latexrelease|fltrace|flafter>               \the \ht \@currbox (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>       \fi
%<latexrelease|fltrace|flafter>     \fi
%<latexrelease|fltrace|flafter>   \fi
%<latexrelease|fltrace|flafter>   \if@insert
%<latexrelease|fltrace|flafter>   \else
%<latexrelease|fltrace|flafter>     \@resethfps
%<*trace>
%<latexrelease|fltrace|flafter>     \fl@trace{put on deferlist (addtocurcol)}%
%</trace>
%<latexrelease|fltrace|flafter>     \@cons\@deferlist\@currbox
%<*trace>
%<latexrelease|fltrace|flafter>     \fl@trace{deferlist: \@deferlist:
%<latexrelease|fltrace|flafter>                          (addtocurcol-after)}%
%</trace>
%<latexrelease|fltrace|flafter>   \fi
%<latexrelease|fltrace|flafter>  }%
%<latexrelease|fltrace|flafter>\EndIncludeInRelease
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@addtonextcol}
% \changes{v1.0f}{1993/12/05}{Command changed}
%    Lots of changes.
%
% \changes{v1.2n}{2015/01/14}{float order in 2-column (latexrelease)}
% \changes{v1.4b}{2017/12/17}{fix doc guards}
%    \begin{macrocode}
%<latexrelease|fltrace>\IncludeInRelease{2025/06/01}
%<latexrelease|fltrace>  {\@addtonextcol}{float order in 2-column}%
%<*2ekernel|latexrelease|fltrace>
\def\@addtonextcol{%
  \begingroup
%<*trace>
   \fl@trace{***Start addtonextcol}%
%</trace>
   \@insertfalse
   \@setfloattypecounts
   \ifnum \@fpstype=8
%<*trace>
     \fl@trace{fpstype not curcol: \the \@fpstype = 8?}%
%</trace>
   \else
     \ifnum \@fpstype=24
%<*trace>
       \fl@trace{fpstype not curcol: \the \@fpstype = 24?}%
%</trace>
     \else
       \@flsettextmin
%<*trace>
       \fl@trace{text-so-far: 0pt (top of col)}%
%</trace>
       \@reqcolroom \ht\@currbox
%<*trace>
       \fl@trace{float size: \the \@reqcolroom (addtonextcol)}%
%</trace>
       \advance \@reqcolroom \@textmin
%    \end{macrocode}
%    
%  \changes{v1.4n}{2025/01/29}{Save current value of \cs{@reqcolroom} (gh/1645)}
%    \begin{macrocode}
       \saved@reqcolroom \@reqcolroom
%<*trace>
       \fl@trace{colroom = \the \@colroom (addtonextcol)}%
       \fl@trace{reqcolroom = \the \@reqcolroom (addtonextcol)}%
%</trace>
       \ifdim \@colroom>\@reqcolroom
         \@flsetnum \@colnum
         \ifnum\@colnum>\z@
            \@bitor\@currtype\@deferlist
%<*trace>
            \fl@trace{deferlist: \@deferlist: (addtonextcol-before)}%
%</trace>
%    \end{macrocode}
%
%    \begin{macrocode}
            \@testwrongwidth\@currbox
%    \end{macrocode}
%
%    \begin{macrocode}
            \if@test
%<*trace>
              \fl@trace{type already on list: defer (addtonextcol)}%
%</trace>
            \else
%<*trace>
              \fl@trace{sent to addtotoporbot (addtonextcol)}%
%</trace>
              \@addtotoporbot
            \fi
         \fi
%<*trace>
       \else
         \fl@trace{Fail---no room: fl box ht: \the \ht \@currbox
                                                  (addtonextcol)}%
%</trace>
       \fi
     \fi
   \fi
   \if@insert
   \else
%<*trace>
     \fl@trace{put back on deferlist (addtonextcol)}%
%</trace>
     \@cons\@deferlist\@currbox
%<*trace>
     \fl@trace{deferlist: \@deferlist: (addtonextcol-after)}%
%</trace>
   \fi
%<*trace>
  \fl@trace{End of addtonextcol -- locally counts:}%
  \fl@trace{col: \the\@colnum. top: \the \@topnum. bot: \the \@botnum.}%
%</trace>
  \endgroup
%<*trace>
 \fl@trace{End of addtonextcol -- globally counts:}%
 \fl@trace{col: \the\@colnum. top: \the \@topnum. bot: \the \@botnum.}%
%</trace>
}%
%</2ekernel|latexrelease|fltrace>
%<latexrelease|fltrace>\EndIncludeInRelease
%    \end{macrocode}
%    
%    \begin{macrocode}
%<latexrelease|fltrace>\IncludeInRelease{2015/01/01}
%<latexrelease|fltrace>  {\@addtonextcol}{float order in 2-column}%
%<latexrelease|fltrace>\def\@addtonextcol{%
%<latexrelease|fltrace>  \begingroup
%<*trace>
%<latexrelease|fltrace>   \fl@trace{***Start addtonextcol}%
%</trace>
%<latexrelease|fltrace>   \@insertfalse
%<latexrelease|fltrace>   \@setfloattypecounts
%<latexrelease|fltrace>   \ifnum \@fpstype=8
%<*trace>
%<latexrelease|fltrace>     \fl@trace{fpstype not curcol: \the \@fpstype = 8?}%
%</trace>
%<latexrelease|fltrace>   \else
%<latexrelease|fltrace>     \ifnum \@fpstype=24
%<*trace>
%<latexrelease|fltrace>       \fl@trace{fpstype not curcol: \the \@fpstype = 24?}%
%</trace>
%<latexrelease|fltrace>     \else
%<latexrelease|fltrace>       \@flsettextmin
%<*trace>
%<latexrelease|fltrace>       \fl@trace{text-so-far: 0pt (top of col)}%
%</trace>
%<latexrelease|fltrace>       \@reqcolroom \ht\@currbox
%<*trace>
%<latexrelease|fltrace>       \fl@trace{float size: \the \@reqcolroom (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>       \advance \@reqcolroom \@textmin
%<*trace>
%<latexrelease|fltrace>       \fl@trace{colroom = \the \@colroom (addtonextcol)}%
%<latexrelease|fltrace>       \fl@trace{reqcolroom = \the \@reqcolroom (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>       \ifdim \@colroom>\@reqcolroom
%<latexrelease|fltrace>         \@flsetnum \@colnum
%<latexrelease|fltrace>         \ifnum\@colnum>\z@
%<latexrelease|fltrace>            \@bitor\@currtype\@deferlist
%<*trace>
%<latexrelease|fltrace>            \fl@trace{deferlist: \@deferlist: (addtonextcol-before)}%
%</trace>
%<latexrelease|fltrace>            \@testwrongwidth\@currbox
%<latexrelease|fltrace>            \if@test
%<*trace>
%<latexrelease|fltrace>              \fl@trace{type already on list: defer (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>            \else
%<*trace>
%<latexrelease|fltrace>              \fl@trace{sent to addtotoporbot (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>              \@addtotoporbot
%<latexrelease|fltrace>            \fi
%<latexrelease|fltrace>         \fi
%<*trace>
%<latexrelease|fltrace>       \else
%<latexrelease|fltrace>         \fl@trace{Fail---no room: fl box ht: \the \ht \@currbox
%<latexrelease|fltrace>                                                  (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>       \fi
%<latexrelease|fltrace>     \fi
%<latexrelease|fltrace>   \fi
%<latexrelease|fltrace>   \if@insert
%<latexrelease|fltrace>   \else
%<*trace>
%<latexrelease|fltrace>     \fl@trace{put back on deferlist (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>     \@cons\@deferlist\@currbox
%<*trace>
%<latexrelease|fltrace>     \fl@trace{deferlist: \@deferlist: (addtonextcol-after)}%
%</trace>
%<latexrelease|fltrace>   \fi
%<*trace>
%<latexrelease|fltrace>  \fl@trace{End of addtonextcol -- locally counts:}%
%<latexrelease|fltrace>  \fl@trace{col: \the\@colnum. top: \the \@topnum. bot: \the \@botnum.}%
%</trace>
%<latexrelease|fltrace>  \endgroup
%<*trace>
%<latexrelease|fltrace> \fl@trace{End of addtonextcol -- globally counts:}%
%<latexrelease|fltrace> \fl@trace{col: \the\@colnum. top: \the \@topnum. bot: \the \@botnum.}%
%</trace>
%<latexrelease|fltrace>}%
%<latexrelease|fltrace>\EndIncludeInRelease
%    \end{macrocode}
%    
%    \begin{macrocode}
%<latexrelease|fltrace>\IncludeInRelease{0000/00/00}%
%<latexrelease|fltrace>  {\@addtonextcol}{float order in 2-column}%
%<latexrelease|fltrace>\def\@addtonextcol{%
%<latexrelease|fltrace>  \begingroup
%<*trace>
%<latexrelease|fltrace>   \fl@trace{***Start addtonextcol}%
%</trace>
%<latexrelease|fltrace>   \@insertfalse
%<latexrelease|fltrace>   \@setfloattypecounts
%<latexrelease|fltrace>   \ifnum \@fpstype=8
%<*trace>
%<latexrelease|fltrace>     \fl@trace{fpstype not curcol:
%<latexrelease|fltrace>                    \the \@fpstype = 8?}%
%</trace>
%<latexrelease|fltrace>   \else
%<latexrelease|fltrace>     \ifnum \@fpstype=24
%<*trace>
%<latexrelease|fltrace>       \fl@trace{fpstype not curcol:
%<latexrelease|fltrace>                       \the \@fpstype = 24?}%
%</trace>
%<latexrelease|fltrace>     \else
%<latexrelease|fltrace>       \@flsettextmin
%<*trace>
%<latexrelease|fltrace>       \fl@trace{text-so-far: 0pt (top of col)}%
%</trace>
%<latexrelease|fltrace>       \@reqcolroom \ht\@currbox
%<*trace>
%<latexrelease|fltrace>       \fl@trace{float size:
%<latexrelease|fltrace>               \the \@reqcolroom (addtonextcol)}%
%<latexrelease|fltrace>
%</trace>
%<latexrelease|fltrace>       \advance \@reqcolroom \@textmin
%<*trace>
%<latexrelease|fltrace>       \fl@trace{colroom =
%<latexrelease|fltrace>                  \the \@colroom (addtonextcol)}%
%<latexrelease|fltrace>       \fl@trace{reqcolroom =
%<latexrelease|fltrace>               \the \@reqcolroom (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>       \ifdim \@colroom>\@reqcolroom
%<latexrelease|fltrace>         \@flsetnum \@colnum
%<latexrelease|fltrace>         \ifnum\@colnum>\z@
%<latexrelease|fltrace>            \@bitor\@currtype\@deferlist
%<*trace>
%<latexrelease|fltrace>            \fl@trace{deferlist: \@deferlist:
%<latexrelease|fltrace>                          (addtonextcol-before)}%
%</trace>
%<latexrelease|fltrace>            \if@test
%<*trace>
%<latexrelease|fltrace>              \fl@trace{type already on list:
%<latexrelease|fltrace>                           defer (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>            \else
%<*trace>
%<latexrelease|fltrace>              \fl@trace{sent to addtotoporbot
%<latexrelease|fltrace>                                 (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>              \@addtotoporbot
%<latexrelease|fltrace>            \fi
%<latexrelease|fltrace>         \fi
%<*trace>
%<latexrelease|fltrace>       \else
%<latexrelease|fltrace>         \fl@trace{Fail---no room: fl box ht:
%<latexrelease|fltrace>              \the \ht \@currbox (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>       \fi
%<latexrelease|fltrace>     \fi
%<latexrelease|fltrace>   \fi
%<latexrelease|fltrace>   \if@insert
%<latexrelease|fltrace>   \else
%<*trace>
%<latexrelease|fltrace>     \fl@trace{put back on deferlist
%<latexrelease|fltrace>                                (addtonextcol)}%
%</trace>
%<latexrelease|fltrace>     \@cons\@deferlist\@currbox
%<*trace>
%<latexrelease|fltrace>     \fl@trace{deferlist: \@deferlist:
%<latexrelease|fltrace>                           (addtonextcol-after)}%
%</trace>
%<latexrelease|fltrace>   \fi
%<*trace>
%<latexrelease|fltrace>   \fl@trace{End of addtonextcol --
%<latexrelease|fltrace>                             locally counts:}%
%<latexrelease|fltrace>   \fl@trace{col: \the \@colnum.
%<latexrelease|fltrace>      top: \the \@topnum. bot: \the \@botnum.}%
%</trace>
%<latexrelease|fltrace>  \endgroup
%<*trace>
%<latexrelease|fltrace>  \fl@trace{End of addtonextcol --
%<latexrelease|fltrace>                           globally counts:}%
%<latexrelease|fltrace>  \fl@trace{col: \the \@colnum.
%<latexrelease|fltrace>        top: \the \@topnum. bot: \the \@botnum.}%
%</trace>
%<latexrelease|fltrace>}%
%<latexrelease|fltrace>\EndIncludeInRelease
%    \end{macrocode}
%
%  \end{macro}
%
%  \begin{macro}{\@addtodblcol}
% \changes{v1.0f}{1993/12/05}{Command changed}
%    Lots of changes.
%
% \changes{v1.2n}{2015/01/14}{float order in 2-column (latexrelease)}
%    \begin{macrocode}
%<latexrelease|fltrace>\IncludeInRelease{2015/01/01}%
%<latexrelease|fltrace>  {\@addtodblcol}{float order in 2-column}%
%<*2ekernel|latexrelease|fltrace>
\def\@addtodblcol{%
  \begingroup
%<*trace>
  \fl@trace{***Start addtodblcol}%
%</trace>
   \@insertfalse
   \@setfloattypecounts
   \@getfpsbit \tw@
%<*trace>
   \fl@trace{fpstype \ifodd \@tempcnta OK \else not \fi dbltop:
                                                     \the \@fpstype}%
%</trace>
   \ifodd\@tempcnta
     \@flsetnum \@dbltopnum
     \ifnum \@dbltopnum>\z@
       \@tempswafalse
       \ifdim \@dbltoproom>\ht\@currbox
         \@tempswatrue
%<*trace>
         \fl@trace{Space OK: \@dbltoproom =
                \the \@dbltoproom > \the \ht \@currbox
                                         (dbltoproom)}%
%</trace>
       \else
%<*trace>
         \fl@trace{fpstype: \the \@fpstype (addtodblcol)}%
%</trace>
         \ifnum \@fpstype<\sixt@@n
%<*trace>
           \fl@trace{BANG float ignoring \@dbltoproom}%
           \fl@trace{\@spaces \@dbltoproom = \the \@dbltoproom.
                           Ht float: \the \ht \@currbox-BANG}%
%</trace>
%    \end{macrocode}
% Need to check that there is room on the page, using the local value
% of |\@textmin| to make the necessary adjustment to |\@dbltoproom|.
%    \begin{macrocode}
           \advance \@dbltoproom \@textmin
%<*trace>
           \fl@trace{Local value of texmin: \the\@textmin}%
           \fl@trace{\@spaces space on page = \the \@dbltoproom.
                           Ht float: \the \ht \@currbox-BANG}%
%</trace>
           \ifdim \@dbltoproom>\ht\@currbox
             \@tempswatrue
%<*trace>
             \fl@trace{Space OK BANG: space on page =
                         \the \@dbltoproom > \the \ht \@currbox}%
           \else
             \fl@trace{fpstype: \the \@fpstype}%
             \fl@trace{Fail---no room dbltoproom-BANG?:}%
             \fl@trace{\@spaces space on page = \the \@dbltoproom.
                           Ht float: \the \ht \@currbox}%
%</trace>
           \fi
           \advance \@dbltoproom -\@textmin
%<*trace>
         \else
           \fl@trace{fpstype: \the \@fpstype}%
           \fl@trace{Fail---no room dbltoproom-ORD?:}%
           \fl@trace{\@spaces \@dbltoproom = \the \@dbltoproom.
                           Ht float: \the \ht \@currbox}%
%</trace>
         \fi
       \fi
       \if@tempswa
           \@bitor \@currtype \@deferlist
%<*trace>
           \fl@trace{(dbl)deferlist: \@deferlist: (before)}%
%</trace>
%    \end{macrocode}
%
% not in fixfloats?
%    \begin{macrocode}
          \@testwrongwidth\@currbox
%    \end{macrocode}
%
%    \begin{macrocode}
           \if@test
%<*trace>
              \fl@trace{type already on list: (dbl)defer}%
%</trace>
           \else
              \@tempdima -\ht\@currbox
              \advance\@tempdima
                -\ifx \@dbltoplist\@empty \dbltextfloatsep \else
                                          \dblfloatsep \fi
              \global \advance \@dbltoproom \@tempdima
              \global \advance \@colht \@tempdima
              \global \advance \@dbltopnum \m@ne
              \@cons \@dbltoplist \@currbox
%<*trace>
              \fl@trace{dbltopnum (after) = \the \@dbltopnum}%
              \fl@trace{***Success: dbltop}%
%</trace>
              \@inserttrue
           \fi
       \fi
%<*trace>
     \else
       \fl@trace{Fail: dbltopnum = \the \@dbltopnum: fpstype
                                                  \the \@fpstype=ORD?}%
       \ifnum \@fpstype<\sixt@@n
         \fl@trace{ERROR: !t float not successful (addtodblcol)}%
       \fi
%</trace>
     \fi
   \fi
   \if@insert
   \else
%<*trace>
     \fl@trace{put on deferlist}%
%</trace>
     \@cons\@deferlist\@currbox
%<*trace>
     \fl@trace{(dbl)deferlist: \@deferlist: (after)}%
%</trace>
   \fi
%<*trace>
   \fl@trace{End of addtodblcol -- locally count:}%
   \fl@trace{ dbltop: \the \@dbltopnum.}%
%</trace>
  \endgroup
%<*trace>
  \fl@trace{End of addtodblcol -- globally count:}%
  \fl@trace{dbltop: \the \@dbltopnum.}%
%</trace>
}%
%</2ekernel|latexrelease|fltrace>
%<latexrelease|fltrace>\EndIncludeInRelease
%<latexrelease|fltrace>\IncludeInRelease{0000/00/00}%
%<latexrelease|fltrace>  {\@addtodblcol}{float order in 2-column}%
%<latexrelease|fltrace>\def\@addtodblcol{%
%<latexrelease|fltrace>  \begingroup
%<*trace>
%<latexrelease|fltrace>  \fl@trace{***Start addtodblcol}%
%</trace>
%<latexrelease|fltrace>   \@insertfalse
%<latexrelease|fltrace>   \@setfloattypecounts
%<latexrelease|fltrace>   \@getfpsbit \tw@
%<*trace>
%<latexrelease|fltrace>   \fl@trace{fpstype \ifodd \@tempcnta OK
%<latexrelease|fltrace>                \else not \fi dbltop: \the \@fpstype}%
%</trace>
%<latexrelease|fltrace>   \ifodd\@tempcnta
%<latexrelease|fltrace>     \@flsetnum \@dbltopnum
%<latexrelease|fltrace>     \ifnum \@dbltopnum>\z@
%<latexrelease|fltrace>       \@tempswafalse
%<latexrelease|fltrace>       \ifdim \@dbltoproom>\ht\@currbox
%<latexrelease|fltrace>         \@tempswatrue
%<*trace>
%<latexrelease|fltrace>         \fl@trace{Space OK: \@dbltoproom =
%<latexrelease|fltrace>                \the \@dbltoproom > \the \ht \@currbox
%<latexrelease|fltrace>                                         (dbltoproom)}%
%</trace>
%<latexrelease|fltrace>       \else
%<*trace>
%<latexrelease|fltrace>      \fl@trace{fpstype: \the \@fpstype (addtodblcol)}%
%</trace>
%<latexrelease|fltrace>         \ifnum \@fpstype<\sixt@@n
%<*trace>
%<latexrelease|fltrace>           \fl@trace{BANG float ignoring \@dbltoproom}%
%<latexrelease|fltrace>           \fl@trace{\@spaces \@dbltoproom =
%<latexrelease|fltrace>                    \the \@dbltoproom.
%<latexrelease|fltrace>                    Ht float: \the \ht \@currbox-BANG}%
%</trace>
%    \end{macrocode}
% Need to check that there is room on the page, using the local value
% of |\@textmin| to make the necessary adjustment to |\@dbltoproom|.
%    \begin{macrocode}
%<latexrelease|fltrace>           \advance \@dbltoproom \@textmin
%<*trace>
%<latexrelease|fltrace>       \fl@trace{Local value of texmin: \the\@textmin}%
%<latexrelease|fltrace>       \fl@trace{\@spaces space on page =
%<latexrelease|fltrace>                   \the \@dbltoproom.
%<latexrelease|fltrace>                    Ht float: \the \ht \@currbox-BANG}%
%</trace>
%<latexrelease|fltrace>           \ifdim \@dbltoproom>\ht\@currbox
%<latexrelease|fltrace>             \@tempswatrue
%<*trace>
%<latexrelease|fltrace>         \fl@trace{Space OK BANG: space on page =
%<latexrelease|fltrace>                 \the\@dbltoproom > \the\ht\@currbox}%
%<latexrelease|fltrace>           \else
%<latexrelease|fltrace>         \fl@trace{fpstype: \the \@fpstype}%
%<latexrelease|fltrace>         \fl@trace{Fail---no room dbltoproom-BANG?:}%
%<latexrelease|fltrace>         \fl@trace{\@spaces space on page =
%<latexrelease|fltrace>                      \the \@dbltoproom.
%<latexrelease|fltrace>                       Ht float: \the \ht \@currbox}%
%</trace>
%<latexrelease|fltrace>           \fi
%<latexrelease|fltrace>           \advance \@dbltoproom -\@textmin
%<*trace>
%<latexrelease|fltrace>         \else
%<latexrelease|fltrace>           \fl@trace{fpstype: \the \@fpstype}%
%<latexrelease|fltrace>           \fl@trace{Fail---no room dbltoproom-ORD?:}%
%<latexrelease|fltrace>           \fl@trace{\@spaces \@dbltoproom =
%<latexrelease|fltrace>              \the \@dbltoproom.
%<latexrelease|fltrace>              Ht float: \the \ht \@currbox}%
%</trace>
%<latexrelease|fltrace>         \fi
%<latexrelease|fltrace>       \fi
%<latexrelease|fltrace>       \if@tempswa
%<latexrelease|fltrace>           \@bitor \@currtype \@dbldeferlist
%<*trace>
%<latexrelease|fltrace>           \fl@trace{dbldeferlist:
%<latexrelease|fltrace>                      \@dbldeferlist: (before)}%
%</trace>
%<latexrelease|fltrace>           \if@test
%<*trace>
%<latexrelease|fltrace>             \fl@trace{type already on list: dbldefer}%
%</trace>
%<latexrelease|fltrace>           \else
%<latexrelease|fltrace>              \@tempdima -\ht\@currbox
%<latexrelease|fltrace>              \advance\@tempdima
%<latexrelease|fltrace>                -\ifx \@dbltoplist\@empty
%<latexrelease|fltrace>                      \dbltextfloatsep
%<latexrelease|fltrace>                 \else \dblfloatsep \fi
%<latexrelease|fltrace>              \global \advance \@dbltoproom \@tempdima
%<latexrelease|fltrace>              \global \advance \@colht \@tempdima
%<latexrelease|fltrace>              \global \advance \@dbltopnum \m@ne
%<latexrelease|fltrace>              \@cons \@dbltoplist \@currbox
%<*trace>
%<latexrelease|fltrace>              \fl@trace{dbltopnum (after) =
%<latexrelease|fltrace>                                    \the \@dbltopnum}%
%<latexrelease|fltrace>              \fl@trace{***Success: dbltop}%
%</trace>
%<latexrelease|fltrace>              \@inserttrue
%<latexrelease|fltrace>           \fi
%<latexrelease|fltrace>       \fi
%<*trace>
%<latexrelease|fltrace>     \else
%<latexrelease|fltrace>       \fl@trace{Fail: dbltopnum = \the \@dbltopnum:
%<latexrelease|fltrace>                          fpstype \the \@fpstype=ORD?}%
%<latexrelease|fltrace>       \ifnum \@fpstype<\sixt@@n
%<latexrelease|fltrace>         \fl@trace{ERROR: !t float not successful
%<latexrelease|fltrace>                                        (addtodblcol)}%
%<latexrelease|fltrace>       \fi
%</trace>
%<latexrelease|fltrace>     \fi
%<latexrelease|fltrace>   \fi
%<latexrelease|fltrace>   \if@insert
%<latexrelease|fltrace>   \else
%<*trace>
%<latexrelease|fltrace>     \fl@trace{put on dbldeferlist}%
%</trace>
%<latexrelease|fltrace>     \@cons\@dbldeferlist\@currbox
%<*trace>
%<latexrelease|fltrace>     \fl@trace{dbldeferlist: \@dbldeferlist: (after)}%
%</trace>
%<latexrelease|fltrace>   \fi
%<*trace>
%<latexrelease|fltrace>   \fl@trace{End of addtodblcol -- locally count:}%
%<latexrelease|fltrace>   \fl@trace{ dbltop: \the \@dbltopnum.}%
%</trace>
%<latexrelease|fltrace>  \endgroup
%<*trace>
%<latexrelease|fltrace>  \fl@trace{End of addtodblcol -- globally count:}%
%<latexrelease|fltrace>  \fl@trace{dbltop: \the \@dbltopnum.}%
%</trace>
%<latexrelease|fltrace>}%
%<latexrelease|fltrace>\EndIncludeInRelease
%    \end{macrocode}
%  \end{macro}
%
%
%
% \begin{macro}{\@addmarginpar}
%    \begin{macrocode}
%<*2ekernel>
\def\@addmarginpar{\@next\@marbox\@currlist{\@cons\@freelist\@marbox
    \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
    \if@twocolumn
        \if@firstcolumn \@tempcnta\m@ne \fi
    \else
      \if@mparswitch
         \ifodd\c@page \else\@tempcnta\m@ne \fi
      \fi
      \if@reversemargin \@tempcnta -\@tempcnta \fi
    \fi
    \ifnum\@tempcnta <\z@  \global\setbox\@marbox\box\@currbox \fi
    \@tempdima\@mparbottom
    \advance\@tempdima -\@pageht
    \advance\@tempdima\ht\@marbox
    \ifdim\@tempdima >\z@
      \@latex@warning@no@line {Marginpar on page \thepage\space moved}%
    \else
      \@tempdima\z@
    \fi
    \global\@mparbottom\@pageht
    \global\advance\@mparbottom\@tempdima
    \global\advance\@mparbottom\dp\@marbox
    \global\advance\@mparbottom\marginparpush
    \advance\@tempdima -\ht\@marbox
%    \end{macrocode}
% Putting box movement inside the `marbox':
%    \begin{macrocode}
    \global\setbox \@marbox
                   \vbox {\vskip \@tempdima
                          \box \@marbox}%
    \global \ht\@marbox \z@
    \global \dp\@marbox \z@
%    \end{macrocode}
% Sticking (rather than gluing:-) the `marbox' to the line above,
% changed vskip to kern:
%    \begin{macrocode}
    \kern -\@pagedp
    \nointerlineskip
    \hb@xt@\columnwidth
      {\ifnum \@tempcnta >\z@
          \hskip\columnwidth \hskip\marginparsep
       \else
          \hskip -\marginparsep \hskip -\marginparwidth
       \fi
       \box\@marbox \hss}%
%    \end{macrocode}
%    For this reason the following code can vanish:
%\begin{verbatim}
%    \nobreak             %% No longer needed.  CAR92/12
%    \vskip -\@tempdima   %% No longer needed.  CAR92/12
%\end{verbatim}
%    \begin{macrocode}
    \nointerlineskip
    \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Kludgeins}
%
% This part of the file is part of the implementation of the following
% two new commands for \LaTeX2e{}.
%
%\begin{verbatim}
% \enlargethispage{<dim>}
%\end{verbatim}
% Adds |<dim>| to the height of the current column only. On the printed
% page the bottom of this column is extended downwards by exactly
% |<dim>| without having any effect on the placement of the footer; this
% may result in an overprinting.
%
%\begin{verbatim}
% \enlargethispage*{<dim>}
%\end{verbatim}
%% Similar to |\enlargethispage| but it tries to squeeze the column to
% be printed in as small a space as possible, ie it uses any
% shrinkability in the column. If the column was not explicitly broken
% (\eg with |\pagebreak|) this may result in an overfull box message but
% except for this it will come out as expected (if you know what to
% expect).
%
% The star form of this command is dedicated to Leslie Lamport, the
% other we need for ourselves (FMi, CAR).
%
% These commands may well have unwanted effects if used soon
% before a |\clearpage|: please give keep them clear of such places.
%
%  \begin{macro}{\@kludgeins}
% \changes{v0.1c}{1993/11/23}{Insert added}
%    The insert which makes \TeX{} do a lot of the necessary work.
%    All we need to put into it is the amount by which the pagegoal
%    should be changed.
%    \begin{macrocode}
\newinsert \@kludgeins
\global\dimen\@kludgeins \maxdimen
\global\count\@kludgeins 1000
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\enlargethispage}
%  \begin{macro}{\enlargethispage*}
% \changes{v0.1c}{1993/11/23}{Commands added}
%    The user command.
%    \begin{macrocode}
\gdef \enlargethispage {%
   \@ifstar
     {%
%<*trace>
      \fl@trace{Enlarging page height * }%
%</trace>
      \@enlargepage{\hbox{\kern\p@}}}%
     {%
%<*trace>
      \fl@trace{Enlarging page height exactly---}%
%</trace>
      \@enlargepage\@empty}%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
%  \begin{macro}{\@enlargepage}
% \changes{v0.1c}{1993/11/23}{Command added}
%    This actually inserts the insert, after checking for extreme
%    values of the change.
%    \begin{macrocode}
\gdef\@enlargepage#1#2{%
%<*trace>
   \fl@trace{\@spaces\@spaces by #2}%
%</trace>
   \@tempskipa#2\relax
   \ifdim \@tempskipa>.5\maxdimen
     \@latex@error{Suggested\space extra\space height\space
                   (\the\@tempskipa)\space dangerously\space
                   large}\@eha
   \else
     \ifdim \vsize<.5\maxdimen
%<*trace>
       \fl@trace {Kludgeins added--pagegoal before: \the\pagegoal}%
%</trace>
       \@bsphack
         \insert\@kludgeins{#1\vskip-\@tempskipa}%
       \@esphack
%    \end{macrocode}
%    This next bit is for tracing only:
%    \begin{macrocode}
%<*trace>
       \ifvmode \par
         \fl@trace {Kludgeins added--pagegoal after: \the \pagegoal}%
       \fi
%</trace>
     \else
       \@latex@error{Page\space height\space already\space
                     too\space large}\@eha
     \fi
   \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%
%
%  \begin{macro}{\ShowFloat}
%    This command provides some information about the contenta of a
%    float register.  Float registers have internal names of the form
%    \cs{bx@}\meta{Uppercase-letter(s)-or numbers} and you specify just this
%    letter or letters as the argument, e.g., \verb=\ShowFloat{A}=.
%    (There is not much error recovery if you specify something that
%    isn't a float.)
% \changes{v1.4g}{2021/07/31}{Macro added}
% \changes{v1.4h}{2021/09/03}{Renamed, original name never distributed}
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2021/11/15}%
%<latexrelease>                 {\ShowFloat}{Show float register contents}%
\def\ShowFloat#1{\begingroup
    \let \fl@trace \fl@tracemessage
    \fl@trace{***Float #1 details:}%
    \ifcsname bx@#1\endcsname
      \expandafter\fl@ShowFloat\csname bx@#1\endcsname
    \else
      \fl@trace{Not a float!}%
    \fi
  \endgroup
}
\def\fl@ShowFloat#1{%
  \fl@traceval{\count#1}%  % this here should be interpreted on day
  \fl@traceval{\ht#1}%
  \fl@traceval{\dp#1}%
  \fl@traceval{\wd#1}%
  {\tracingonline1\showboxbreadth10\showboxdepth3\showbox#1}%
}
%    \end{macrocode}
%    Here are two definitions from \texttt{fltrace} that make the above
%    code work:
%    \begin{macrocode}
\def \fl@traceval #1{\fl@trace{\string #1 = \the #1}}
\def \fl@tracemessage #1{{\let\@elt\@empty\typeout{LaTeX2e: #1}}}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\ShowFloat}{Show float register contents}%
%<latexrelease>
%<latexrelease>\let\ShowFloat\@undefined
%<latexrelease>\let\fl@ShowFloat\@undefined
%<latexrelease>\let\fl@traceval\@undefined
%<latexrelease>\let\fl@tracemessage\@undefined
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%  \end{macro}
%
%
%
%
% \subsubsection{Float control}
%
% This part implements controllable floats and other changes
% to the float mechanism.
%
% It provides, at the document level, the following command for
% inclusion in \LaTeX2e{}.
%
% \begin{verbatim}
%     \suppressfloats
% \end{verbatim}
%
% This suppresses all further floats on the current page.
%
% With an optional argument it suppresses only floats only in certain
% positions on the current page.
% \begin{quote}
%  |[t]|\quad suppresses only floats at the top of the page
%  |[b]|\quad suppresses only floats at the bottom of the page
% \end{quote}
%
% It also enables the use of an extra specifier, {\tt !}, in the
% location optional argument of a float.  If this is present then,
% just for this particular float, whenever it is processed by the float
% mechanism the following are ignored:
%
% \begin{itemize}
% \item  all restrictions on the number of floats which can appear;
% \item  all explicit restrictions on the amount of space which should
%   (not) be occupied by floats and/or text.
% \end{itemize}
%
% The mechanism will still attempt to ensure that pages are not
% overfull.
%
% These specifiers override, for the single float, the suppression
% commands described above.
%
%
% In its current form, it also supplies a reasonably exhaustive, and
% somewhat baroque, means of tracing some aspects of the float
% mechanism.
%
% More tracing.
%  \begin{macro}{\fl@trace}
%  \begin{macro}{\tracefloatsoff}
%  \begin{macro}{\tracefloats}
%  \begin{macro}{\fl@traceval}
%  \begin{macro}{\tracefloatvals}
%  \begin{macro}{\fl@tracemessage}
% \changes{v1.0c}{1993/11/30}{Commands added}
% \changes{v1.0h}{1993/12/12}{Commands changed}
% \changes{v1.0j}{1993/12/17}{tracefloatvals made a document command}
%    Set-up tracing for floats independent of other tracing as it
%    produces mega-output.  Default is no tracing.
% \changes{v1.1j}{1995/04/24}
%   {Do not add to kernel unless `trace' specified}
% \changes{v1.2n}{2014/04/24}
%   {Renamed internal trace commands; provide as package}
%
%    \begin{macrocode}
%<*fltrace>
\def \fl@tracemessage #1{{\let\@elt\@empty\typeout{LaTeX2e: #1}}}
\def \tracefloats{\let \fl@trace \fl@tracemessage}
\def \tracefloatsoff {\let \fl@trace \@gobble}
\tracefloatsoff
\def \fl@traceval #1{\fl@trace{\string #1 = \the #1}}
\IncludeInRelease{2015/01/01}{\tracefloatvals}%
                          {trace float vals}%
\def \tracefloatvals{%
%    \end{macrocode}
%    As |\@dblfloatplacement| sets |\f@depth| it needs to be run
%   inside a group, otherwise the float placement will test for the
%   wrong value.\footnote{This is a somewhat questionable design.}
%    \begin{macrocode}
 \begingroup
%    \end{macrocode}
%    When the user requests \cs{tracefloatvals} then they should show
%    regardless of the tracing state, so locally we make sure that it
%    is activated.
% \changes{v1.4e}{2021/07/31}{Enable display when doing \cs{tracefloatvals}}
%    \begin{macrocode}
  \tracefloats
%    \end{macrocode}
%    
%    \begin{macrocode}
  \@dblfloatplacement
  \@floatplacement
  \fl@trace{***Float placement parameters:}%
  \fl@traceval\@colnum
  \fl@traceval\@colroom
  \fl@traceval\@topnum
  \fl@traceval\@toproom
  \fl@traceval\@botnum
  \fl@traceval\@botroom
  \fl@traceval\@fpmin
  \fl@trace{\string\textfraction = \textfraction}%
  \fl@traceval\@dbltopnum
  \fl@traceval\@dbltoproom
  \fl@trace{\string\textfraction = \textfraction}%
  \fl@trace{toplist: \@toplist}%
  \fl@trace{botlist: \@botlist}%
  \fl@trace{midlist: \@midlist}%
  \fl@trace{deferlist: \@deferlist}%
  \fl@trace{dbltoplist: \@dbltoplist}%
%FMi  \fl@trace{dbldeferlist: \@dbldeferlist}%
 \endgroup
}
\EndIncludeInRelease
\IncludeInRelease{0000/00/00}{\tracefloatvals}%
                          {trace float vals}%
\def \tracefloatvals{%
 \begingroup
  \tracefloats
  \@dblfloatplacement
  \@floatplacement
  \fl@trace{***Float placement parameters:}%
  \fl@traceval\@colnum
  \fl@traceval\@colroom
  \fl@traceval\@topnum
  \fl@traceval\@toproom
  \fl@traceval\@botnum
  \fl@traceval\@botroom
  \fl@traceval\@fpmin
  \fl@trace{\string\textfraction = \textfraction}%
  \fl@traceval\@dbltopnum
  \fl@traceval\@dbltoproom
  \fl@trace{\string\textfraction = \textfraction}%
  \fl@trace{toplist: \@toplist}%
  \fl@trace{botlist: \@botlist}%
  \fl@trace{midlist: \@midlist}%
  \fl@trace{deferlist: \@deferlist}%
  \fl@trace{dbltoplist: \@dbltoplist}%
% next line only in old releases
  \fl@trace{dbldeferlist: \@dbldeferlist}%
 \endgroup
}
\EndIncludeInRelease
%    \end{macrocode}
%
%
%
%
%    We need to make sure that \texttt{fltrace} comes before
%    \texttt{flafter} to make the tracing work.
%    \begin{macrocode}
\@ifpackageloaded{flafter}
 {\PackageWarningNoLine
      {fltrace}{Load 'fltrace' before 'flafter'\MessageBreak
                Attempting to recover by reloading 'flafter'}%
%    \end{macrocode}
%    Hide the fact that \texttt{flafter} was already loaded and then
%    request it anew.
% \changes{v1.2m}{2015/01/20}{Reset \cs{IncludeInRelease} flags}
%    \begin{macrocode}
    \expandafter\let\csname ver@flafter.sty\endcsname\relax
    \def\reserved@a#1{%
      \expandafter\let\csname\string#1+flafter+IIR\endcsname\relax}%
    \reserved@a\@addtocurcol
    \reserved@a\@addtonextcol
    \RequirePackage{flafter}}{}
%</fltrace>
%    \end{macrocode}
%    As the code for \texttt{flafter} will contain tracing calls so
%    that it works in conjunction with \texttt{fltrace} we need to
%    provide a dummy definition for |\fl@trace| in that package.
%    \begin{macrocode}
%<*flafter>
\providecommand\fl@trace[1]{}
%</flafter>
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\suppressfloats}
%  \begin{macro}{\@flstop}
% \changes{v1.0f}{1993/12/05}{Commands added}
% Float suppression commands: these set the relevant counter
% globally to zero.  Thus they are overridden for a particular float
% by an ! specifier.
%
%    \begin{macrocode}
%<*2ekernel>
\def \suppressfloats {%
   \@ifnextchar [%
     \@flstop
    {\global \@colnum \z@}%
}
%    \end{macrocode}
% Maybe this should be a loop over |#1|?
%    \begin{macrocode}
\def \@flstop [#1]{%
   \if t#1%
     \global \@topnum \z@
   \fi
   \if b#1%
     \global \@botnum \z@
   \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
% Manipulation of float placement and type; both their strings and the
% corresponding count registers.
%
%  \begin{macro}{\@fpstype}
%  \begin{macro}{\@reqcolroom}
%  \begin{macro}{\@textfloatsheight}
% \changes{v1.0f}{1993/12/05}{Commands added}
% First a new count register to go with |\@currtype|.
%
% Then a new skip register, for information needed to remove the
% |\@maxsep| conservatism: it is possible that this could use a
% temporary register.
%
% Finally a dimension register to hold the total height of in-text
% floats on the current page.  This is needed to implement a
% major change in the functionality of |\@addtocurcol| which is,
% nevertheless, a bug fix.
% It is not local and therefore cannot be a temporary register.
%
%    \begin{macrocode}
\newcount \@fpstype
\newdimen \@reqcolroom
\newdimen \@textfloatsheight
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%
%  \begin{macro}{\saved@reqcolroom}
%    Saved value of \cs{@reqcolroom}; this is needed when making several tests.
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2025/06/01}%
%<latexrelease>                 {\saved@reqcolroom}{float placement calculation}%
\newdimen \saved@reqcolroom
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\saved@reqcolroom}{float placement calculation}%
%<latexrelease>\let \saved@reqcolroom \@undefined
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@fpsadddefault}
% \changes{v1.0f}{1993/12/05}{Command added}
% Adds the default placement to what is already there.
%
% Should not need to change this, but could do it as follows:
% \begin{verbatim}
%\def \@fpsadddefault {%
%   \@temptokena \expandafter\expandafter\expandafter
%                {\csname fps@\@captype \endcsname}%
%   \edef \reserved@a {\the\@temptokena}%
%   \@onelevel@sanitize \reserved@a
%   \edef \@fps {\@fps\reserved@a}%
%}
% \end{verbatim}
%
%    \begin{macrocode}
%<*2ekernel|fltrace>
\def \@fpsadddefault {%
%<*trace>
   \fl@trace{fps changed from: \@fps}%
%</trace>
   \edef \@fps {\@fps\csname fps@\@captype \endcsname}%
   \@latex@warning {%
     No positions in optional float specifier.\MessageBreak
     Default added (so using `\@fps')}%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@setfloattypecounts}
% \changes{v1.0f}{1993/12/05}{Command added}
% Sets counters |\@fpstype| and |\@currtype|.
%
% BANG $==$ bit4 of $|\count\@currbox| = 0$.
%
%    \begin{macrocode}
\def \@setfloattypecounts {%
  \@currtype \count\@currbox
  \@fpstype \count\@currbox
  \divide\@currtype\@xxxii \multiply\@currtype\@xxxii
  \advance \@fpstype -\@currtype
%<*trace>
  \fl@trace{(mod 32) fpstype: \the \@fpstype}%
  \fl@trace{(mult of 32) currtype: \the \@currtype}%
% Tracing only: but some should be changed into real errors/warnings?
  \ifnum \@fpstype<\sixt@@n
    \ifnum \@fpstype=\z@
      \fl@trace{ERROR: no PLACEMENT, fpstype = \the \@fpstype = 0?}%
    \fi
    \ifnum \@fpstype=\@ne
      \fl@trace{WARNING: only h, fpstype = \the \@fpstype = 1?}%
    \fi
    \fl@trace{BANG float}%
  \else
    \ifnum \@fpstype=\sixt@@n
      \fl@trace{ERROR: no PLACEMENT, fpstype = \the \@fpstype = 16?}%
    \fi
    \ifnum \@fpstype=17
      \fl@trace{WARNING: only h, fpstype = \the \@fpstype = 17?}%
    \fi
    \fl@trace{ORD float}%
  \fi
%</trace>
}
%</2ekernel|fltrace>
%    \end{macrocode}
%  \end{macro}
%
% Macros for getting, testing and setting bits of the fps.
%
%
%  \begin{macro}{\@getfpsbit}
% \changes{v1.0f}{1993/12/05}{Command added}
% Sets |\@tempcnta| to required bit of |\count\@currbox|.
%
%    \begin{macrocode}
%<*2ekernel>
\def \@getfpsbit {%
   \@boxfpsbit \@currbox
}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@boxfpsbit}
% \changes{v1.0f}{1993/12/05}{Command added}
%    Used above.
%    \begin{macrocode}
\def \@boxfpsbit #1#2{%
   \@tempcnta \count#1%
   \divide \@tempcnta #2\relax
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@testfp}
% \changes{v1.0f}{1993/12/05}{Command added}
% New definition of the float page test.
%
% \changes{v1.1v}{1996/07/26}{remove \cs{global} before \cs{@test...}}
%    \begin{macrocode}
\def \@testfp #1{%
   \@boxfpsbit #18\relax % Really `#1 8' for human readers!
   \ifodd \@tempcnta
   \else
     \@testtrue
   \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@setfpsbit}
% \changes{v1.0f}{1993/12/05}{Command added}
% Sets required bit of |\@tempcnta| (to 1).
%
%    \begin{macrocode}
\def \@setfpsbit #1{%
   \@tempcntb \@tempcnta
   \divide \@tempcntb #1\relax
   \ifodd \@tempcntb
   \else
     \advance \@tempcnta #1\relax
   \fi
}
%</2ekernel>
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@resethfps}
% \changes{v1.0f}{1993/12/05}{Command added}
% \changes{v1.0h}{1993/12/12}{Warnings added: minimal}
% \changes{v1.0m}{1994/04/24}{Warning changed}
% \changes{v1.0m}{1994/04/24}{Number 2 changed to \cs{tw@}}
% \changes{v1.0o}{1994/05/02}{Code shortened}
% Globally adds t as a possible location for an h or !h only placement:
% this must be done using the count.
%
% Although it will leave |\@fpstype| set to 17 even if it was
% originally 1, this does not matter since it is the last thing in
% |\@addtocurcol|.
%    \begin{macrocode}
%<*2ekernel|fltrace>
\def \@resethfps {%
   \let\reserved@a\@empty
   \ifnum \@fpstype=\@ne
      \def \reserved@a {!}%
      \@fpstype 17
   \fi
   \ifnum \@fpstype=17
     \global \advance \count\@currbox \tw@
     \@latex@warning@no@line {%
       `\reserved@a h' float specifier changed to `\reserved@a ht'}%
%<*trace>
     \fl@trace{%
        `t' added to `\reserved@a h'- new Count: \the \count\@currbox}%
%</trace>
   \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
% Special stuff for BANG floats.
%
%  \begin{macro}{\@flsetnum}
% \changes{v1.0f}{1993/12/05}{Command added}
%
% Ignores any zero float counter value in case BANG.
%
% It uses a local assignment to the normally global counter: a bit
% naughty, perhaps?
%
% These assignments are safe so long as the counter involved is only
% consulted once (\ie only for the `bang float') with the changed value.
% This is the case within |\@addtocurcol| because it is used only
% once within a call of the output routine (which forms a group).
%
% For |\@addtonextcol| this is achieved by putting a group around its
% code; this is needed because it is called (by |\@startcolumn|) for
% each float which was on the deferlist.  Almost identical
% considerations pertain to |\@addtodblcol|.  There may be more
% efficient ways to handle this, but the group seems to be the simplest.
%
% \changes{v1.0n}{1994/04/30}{Rogue space removed}
%    \begin{macrocode}
\def \@flsetnum #1{%
%<*trace>
   \fl@trace{fpstype: \the \@fpstype (flsetnum \string#1)}%
%</trace>
   \ifnum \@fpstype<\sixt@@n
     \ifnum #1=\z@
%<*trace>
       \fl@trace{BANG float resetting \string#1 to 1}%
%</trace>
       #1\@ne
     \fi
   \fi
%<*trace>
   \fl@trace{#1 (before) = \the #1}%
%</trace>
}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@flsettextmin}
% \changes{v1.0f}{1993/12/05}{Command added}
% This ignores |\textfraction| space restriction in case BANG.
%
%    \begin{macrocode}
\def \@flsettextmin {%
%<*trace>
   \fl@trace{fpstype: \the \@fpstype (flsettextmin)}%
%</trace>
   \ifnum \@fpstype<\sixt@@n
%<*trace>
     \fl@trace{BANG ignoring textmin}%
%</trace>
     \@textmin \z@
   \else
     \@textmin \textfraction\@colht
%<*trace>
     \fl@trace{ORD textmin = \the \@textmin}%
%</trace>
   \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@flcheckspace}
% \changes{v1.0f}{1993/12/05}{Command added}
% This ignores space restriction in case BANG; this is still slightly
% conservative since it does not allow for the fact that, if there is
% no text in the column then |\textfloatsep| is not needed.
% Sets |@tempswa| true if there is room for |\@currbox|.
%
%    \begin{macrocode}
%</2ekernel|fltrace>
%<*2ekernel|fltrace|latexrelease>
%<latexrelease|fltrace>\IncludeInRelease{2025/06/01}%
%<latexrelease|fltrace>                 {\@flcheckspace}{float placement calculation}%
\def \@flcheckspace #1#2{%
%    \end{macrocode}
%    When this test is executed, the value of \cs{@reqcolroom} may
%    no longer be correct due to a previous test that altered it. We
%    therefore reset it to a value saved earlier.
%  \changes{v1.4n}{2025/01/29}{Reset current value of \cs{@reqcolroom} (gh/1645)}
%    \begin{macrocode}
   \@reqcolroom \saved@reqcolroom
   \advance \@reqcolroom
     \ifx #2\@empty \textfloatsep \else \floatsep \fi
%<*trace>
   \fl@trace{colroom = \the \@colroom
                                   (flcheckspace \string#1 \string#2)}%
   \fl@trace{reqcolroom = \the \@reqcolroom
                                   (flcheckspace \string#1 \string#2)}%
%</trace>
   \ifdim \@colroom>\@reqcolroom
     \ifdim #1>\ht\@currbox
       \@tempswatrue
%<*trace>
       \fl@trace{Space OK: #1 = \the #1 > \the \ht \@currbox
                                   (flcheckspace \string#1 \string#2)}%
%</trace>
     \else
%<*trace>
       \fl@trace{fpstype: \the \@fpstype
                                   (flcheckspace \string#1 \string#2)}%
%</trace>
       \ifnum \@fpstype<\sixt@@n
%<*trace>
         \fl@trace{BANG float ignoring #1
                                   (flcheckspace \string#1 \string#2):}%
         \fl@trace{\@spaces #1 = \the #1.  Ht float: \the \ht \@currbox
                                                       \space BANG}%
%</trace>
         \@tempswatrue
%<*trace>
       \else
         \fl@trace{Fail---no room (flcheckspace \string#1 \string#2)
                       (fpstype \the \@fpstype=ORD?):}%
         \fl@trace{\@spaces #1 = \the #1.  Ht float: \the \ht \@currbox
                                                        \space ORD?}%
%</trace>
       \fi
     \fi
%<*trace>
   \else
     \fl@trace{Fail---no room at 2nd test of colroom
                   (flcheckspace \string#1 \string#2)}%
%</trace>
   \fi
}
%</2ekernel|fltrace|latexrelease>
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease|fltrace>\EndIncludeInRelease
%<latexrelease|fltrace>\IncludeInRelease{0000/00/00}%
%<latexrelease|fltrace>                 {\@flcheckspace}{float placement calculation}%
%<latexrelease|fltrace>
%<latexrelease|fltrace>\def \@flcheckspace #1#2{%
%<latexrelease|fltrace>   \advance \@reqcolroom
%<latexrelease|fltrace>     \ifx #2\@empty \textfloatsep \else \floatsep \fi
%<*trace>
%<latexrelease|fltrace>   \fl@trace{colroom = \the \@colroom
%<latexrelease|fltrace>                                   (flcheckspace \string#1 \string#2)}%
%<latexrelease|fltrace>   \fl@trace{reqcolroom = \the \@reqcolroom
%<latexrelease|fltrace>                                   (flcheckspace \string#1 \string#2)}%
%</trace>
%<latexrelease|fltrace>   \ifdim \@colroom>\@reqcolroom
%<latexrelease|fltrace>     \ifdim #1>\ht\@currbox
%<latexrelease|fltrace>       \@tempswatrue
%<*trace>
%<latexrelease|fltrace>       \fl@trace{Space OK: #1 = \the #1 > \the \ht \@currbox
%<latexrelease|fltrace>                                   (flcheckspace \string#1 \string#2)}%
%</trace>
%<latexrelease|fltrace>     \else
%<*trace>
%<latexrelease|fltrace>       \fl@trace{fpstype: \the \@fpstype
%<latexrelease|fltrace>                                   (flcheckspace \string#1 \string#2)}%
%</trace>
%<latexrelease|fltrace>       \ifnum \@fpstype<\sixt@@n
%<*trace>
%<latexrelease|fltrace>         \fl@trace{BANG float ignoring #1
%<latexrelease|fltrace>                                   (flcheckspace \string#1 \string#2):}%
%<latexrelease|fltrace>         \fl@trace{\@spaces #1 = \the #1.  Ht float: \the \ht \@currbox
%<latexrelease|fltrace>                                                       \space BANG}%
%</trace>
%<latexrelease|fltrace>         \@tempswatrue
%<*trace>
%<latexrelease|fltrace>       \else
%<latexrelease|fltrace>         \fl@trace{Fail---no room (flcheckspace \string#1 \string#2)
%<latexrelease|fltrace>                       (fpstype \the \@fpstype=ORD?):}%
%<latexrelease|fltrace>         \fl@trace{\@spaces #1 = \the #1.  Ht float: \the \ht \@currbox
%<latexrelease|fltrace>                                                        \space ORD?}%
%</trace>
%<latexrelease|fltrace>       \fi
%<latexrelease|fltrace>     \fi
%<*trace>
%<latexrelease|fltrace>   \else
%<latexrelease|fltrace>     \fl@trace{Fail---no room at 2nd test of colroom
%<latexrelease|fltrace>                   (flcheckspace \string#1 \string#2)}%
%</trace>
%<latexrelease|fltrace>   \fi
%<latexrelease|fltrace>}
%<latexrelease|fltrace>\EndIncludeInRelease
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@flupdates}
% \changes{v1.0f}{1993/12/05}{Command added}
%    This updates everything when a float is placed.
%
%    \begin{macrocode}
%<*2ekernel>
\def \@flupdates #1#2#3{%
   \global \advance #1\m@ne
   \global \advance \@colnum \m@ne
   \@tempdima -\ht\@currbox
   \advance \@tempdima
     -\ifx #3\@empty \textfloatsep \else \floatsep \fi
   \global \advance #2\@tempdima
   \global \advance \@colroom \@tempdima
   \@cons #3\@currbox
}
%</2ekernel>
%    \end{macrocode}
%  \end{macro}
%
%
% Interesting facts about float mechanisms past and present, together
% with a summary of various features, some unresolved:
%
% \begin{enumerate}
%   \item  The value |\textfraction| does not affect the processing
%     of doublecol floats: this seems sensible, but should be
%     documented.
%   \item |\twocolumn| floatplacement was wrong: dbl not needed, ord
%     needed.
%   \item |\@floatplacement| was not called after |\@startdblcol|
%     or |\@topnewpage|.  This has been changed; it is clearly a bug
%     fix.
%   \item The use |\@topnewpage| when |\dblfigrule| is non-trivial
%   produced a rule in the wrong place.  This has been fixed by not
%   using |\dblfigrule| when processing the `float' from
%   |\@topnewpage|.
%   \item  If the specifier was just h and the float could not be put
%     here, it went on the deferlist and stayed there until a clearpage.
%     It now gets changed to a `th': this is only an error-recovery
%     action, putting just h or !h should be deprecated.
%   \item |\@dblmaxsep| was `the maximum of |\dblfloatsep| and
%     |\dbltexfloatsep|'. But it was never used!  Now gone completely,
%     like |\@maxsep|.
%   \item After an h float is put on a page, it was counted as text when
%     applying the |\textfraction| test; this is possibly too big a
%     change although it is a bug fix?
%   \item  Two consecutive h floats are separated by twice |\intextsep|:
%     this could be changed to one by use of |\addvspace|, OK?
%     Note that it would also mean that less space is put in if an h
%     float  immediately follows other spaces.  This is also possibly
%     too big a change, at least for compatibility mode?
%     Or it may be simply wrong!  It has not been changed.
%   \item Now |\@addtocurcol| checks first for just p fps.  I think
%     that this is an increase in efficiency, but maybe the coding
%     should be made even more efficient.
%   \item |\@tryfcolumn| now tests if the list is empty first, otherwise
%     lots of wasted time!  Thus this test has been removed from
%     |\@startcolumn|.
%     As Frank pointed out, this makes |\@startcolumn| less
%     efficient. But it is now the same as |\@startdblcolumn|: I can
%     see no reason why they should be different, but which is best?
%   \item Why is |\@colroom| set in |\@doclearpage|?
%   \item  Footnotes. Check what |\clearpage| does when footnotes are
%     left over.  Footnotes are not put on float pages and, also,
%     |\@addtonextcol| ignores the existence of held-over footnotes
%     in deciding what floats can go on the page.  Not changed.
%   \item  |\clearpage| can still lose non-boxes, at least when floats
%     are involved.  It also moves some to the `wrong page', but this
%     may be a coding problem.
%   \item  The ! option makes it necessary to check in |\output| that
%     there is enough room left on the page after adding a float.  (This
%     would have been necessary anyway if anyone set |\@textmin| too
%     close to zero!  A similar danger existed also if the text in a
%     |\twocolumn[text]| entity gets too large.)
%     The current implementation of this also makes the normal case a
%     little less efficient, OK?
%     Not enough room means, at present, less than  |\baselineskip|,
%     with a warning: is this OK?  Should it be made generic (another
%     parameter)?
%   \item  There are four possibilities for supporting this:
%
%     |\twocolumn[\maketitle more text]|
%
%     One is to change
%     |\maketitle| slightly to allow this.  Another is to change
%     |\@topnewpage| so that more than one |\twocolumn[]| command is
%     allowed; in this case |\maketitle\twocolumn[more text]| will work.
%     The former is more robust from the user's viewpoint, but makes the
%     code for |\maketitle| rather ad hoc (maybe it is already?).
%     Another is to misuse the global twocolumn flag locally within
%     |\@topnewpage|.
%     Yet another is to move the column count register from the multicol
%     package into the kernel.  This has been done.
%   \item  Where should the reinserts be put to maximise the
%     probability that footnotes come out on the correct page?
%     Or should we go for as much compatibility as possible (but see
%     next item)?
%   \item  Should we continue to support (as much as possible)
%     |\samepage|?  Some of its intended functionality is now advertised
%     as being provided by |\enlargethispage|.  Use of either is likely
%     to result in wrongly placed footnotes, marginals, etc.
%     Which should have priority: obeying the pagination instructions,
%     or correct placement of notes/marginalia?
%   \item  Is the adjustment of space to cause shrinking in the
%      kludge-* case correct?  Should it be limited to 0pt?
%   \item  Is the setting of |\boxmaxdepth| in makecol and friends
%     needed?  It only has any effect if |\@textbottom| ends with a box
%     or rule, in which case the vskip to allow for its depth should
%     also be added.  If it is kept, it should probably be the last
%     thing in the box.  It has now been removed.
%
%     It would perhaps be better to document that |\@textbottom|
%     and |\@texttop| must have natural height 0pt.
%   \item  I cannot see why the vskip adjustment for the depth
%     is needed if boxmaxdepth is used to ensure that there is never
%     a too deep box.
%   \item  The value of |\boxmaxdepth| should be explicitly set
%     whenever necessary: it is too risky to assume that it has any
%     particular value.  Care is needed in deciding what to set it to.
%
%     It is interesting to note that the value of |\boxmaxdepth| is
%     unique in being read before the local settings for the box group
%     are reset; all other parameter settings which affect the box
%     construction use their values outside the box group.
%   \item  Should |\@maxdepth| store the setting of |\maxdepth| from
%     lplain?  Or should we provide a proper interface to class files
%     for setting these?
% \end{enumerate}
%
% An analysis of various other macros.
%
%    |\@opcol| should do |\@floatplacement|, but where?  Right at the
%    end, since it always occurs at the start of a column.
% \begin{verbatim}
% \def\@opcol{%
%   % Why is this done first?
%   \global \@mparbottom \z@
%   \if@twocolumn
%     \@outputdblcol
%   \else
%     \@outputpage
%     % This is not needed since it is done at the end of
%     %   |\@outputpage|:
%     \global \@colht \textheight
%   \fi}
% \end{verbatim}
%
% Only tracing has been added to these.
%
%    \begin{macrocode}
%<latexrelease|fltrace>\IncludeInRelease{2017/01/01}%
%<latexrelease|fltrace>  {\@makefcolumn}{negative height floats}%
%<*2ekernel|fltrace|latexrelease>
\def\@makefcolumn #1{%
  \begingroup
%    \end{macrocode}
% \changes{v1.3b}{2017/01/01}{make fpmin negative so ignored even if float height is negative}
%    \begin{macrocode}
    \@fpmin -\maxdimen
%    \end{macrocode}
%
%    \begin{macrocode}
    \let \@testfp \@gobble
    \@tryfcolumn #1%
  \endgroup
%<*trace>
  \if@fcolmade
    \fl@trace{PAGE: in \string\clearpage
                              \if@twocolumn ---twocolumn\fi---}%
    \fl@trace{----- float column/page completed from \string#1}%
  \fi
%</trace>
}
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease|fltrace>\EndIncludeInRelease
%<latexrelease|fltrace>\IncludeInRelease{0000/00/00}%
%<latexrelease|fltrace>  {\@makefcolumn}{negative height floats}%
%<latexrelease|fltrace>\def\@makefcolumn #1{%
%<latexrelease|fltrace>  \begingroup
%<latexrelease|fltrace>    \@fpmin \z@
%<latexrelease|fltrace>    \let \@testfp \@gobble
%<latexrelease|fltrace>    \@tryfcolumn #1%
%<latexrelease|fltrace>  \endgroup
%<*trace>
%<latexrelease|fltrace>  \if@fcolmade
%<latexrelease|fltrace>    \fl@trace{PAGE: in \string\clearpage
%<latexrelease|fltrace>                    \if@twocolumn ---twocolumn\fi---}%
%<latexrelease|fltrace>    \fl@trace{----- float column/page completed
%<latexrelease|fltrace>                    from \string#1}%
%<latexrelease|fltrace>  \fi
%</trace>
%<latexrelease|fltrace>}
%<latexrelease|fltrace>\EndIncludeInRelease
%</2ekernel|fltrace|latexrelease>
%    \end{macrocode}
% This will line up the last baselines in the two
% columns provided they are constructed in the normal way: \ie ending
% in a skip of minus the original depth, with |\@textbottom| adding
% nothing.
%
% Thus again it is essential for |\@textbottom| to have depth 0pt.
% \changes{1.2g}{2000/07/12}{Ensure that rule is in \cs{normalcolor}}
% \changes{v1.2m}{2014/12/30}{Command updated (latexrelease)}
%    \begin{macrocode}
%<latexrelease|fltrace>\IncludeInRelease{2025/06/01}%
%<latexrelease|fltrace>  {\@outputdblcol}{Use new mark mechanism}%
%<*2ekernel|fltrace|latexrelease>
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@outputdblcol{%
  \if@firstcolumn
    \global\@firstcolumnfalse
%    \end{macrocode}
% Save the left column
%    \begin{macrocode}
    \global\setbox\@leftcolumn\copy\@outputbox
%<fltrace>    \fl@trace{PAGE: first column boxed}%
%    \end{macrocode}
%
%    \begin{macrocode}
  \else
    \global\@firstcolumntrue
    \setbox\@outputbox\vbox{%
     \hb@xt@\textwidth{%
        \hb@xt@\columnwidth{\box\@leftcolumn \hss}%
        \hfil
%    \end{macrocode}
% \changes{v1.1m}{2006/09/13}{Ensure that rule is in \cs{normalcolor}}
% The color of the \cs{vrule} should be \cs{normalcolor} as to not
% inherit the color from the column.
%    \begin{macrocode}
        {\normalcolor\vrule \@width\columnseprule}%
        \hfil
       \hb@xt@\columnwidth{\box\@outputbox \hss}}}%
%<fltrace>    \fl@trace{PAGE: second column also boxed}%
    \@combinedblfloats
    \@outputpage
%<fltrace>    \fl@trace{PAGE: two column page completed}%
    \begingroup
      \@dblfloatplacement
      \@startdblcolumn
      \@whilesw\if@fcolmade \fi{\@outputpage
%<fltrace>      \fl@trace{PAGE: double float page completed}%
     \@startdblcolumn}%
    \endgroup
  \fi}%
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease|fltrace>\EndIncludeInRelease
%<latexrelease|fltrace>\IncludeInRelease{2015/01/01}%
%<latexrelease|fltrace>  {\@outputdblcol}{2 column marks}%
%<latexrelease|fltrace>\def\@outputdblcol{%
%<latexrelease|fltrace>  \if@firstcolumn
%<latexrelease|fltrace>    \global\@firstcolumnfalse
%<latexrelease|fltrace>    \global\setbox\@leftcolumn\copy\@outputbox
%<latexrelease|fltrace>    \splitmaxdepth\maxdimen
%<latexrelease|fltrace>    \vbadness\maxdimen
%<latexrelease|fltrace>     \setbox\@outputbox\vbox{\unvbox\@outputbox\unskip}%
%<latexrelease|fltrace>     \setbox\@outputbox\vsplit\@outputbox to\maxdimen
%<latexrelease|fltrace>    \toks@\expandafter{\topmark}%
%<latexrelease|fltrace>    \xdef\@firstcoltopmark{\the\toks@}%
%<latexrelease|fltrace>    \toks@\expandafter{\splitfirstmark}%
%<latexrelease|fltrace>    \xdef\@firstcolfirstmark{\the\toks@}%
%<latexrelease|fltrace>    \ifx\@firstcolfirstmark\@empty
%<latexrelease|fltrace>      \global\let\@setmarks\relax
%<latexrelease|fltrace>    \else
%<latexrelease|fltrace>      \gdef\@setmarks{%
%<latexrelease|fltrace>        \let\firstmark\@firstcolfirstmark
%<latexrelease|fltrace>        \let\topmark\@firstcoltopmark}%
%<latexrelease|fltrace>    \fi
%<latexrelease|fltrace>  \else
%<latexrelease|fltrace>    \global\@firstcolumntrue
%<latexrelease|fltrace>    \setbox\@outputbox\vbox{%
%<latexrelease|fltrace>     \hb@xt@\textwidth{%
%<latexrelease|fltrace>        \hb@xt@\columnwidth{\box\@leftcolumn \hss}%
%<latexrelease|fltrace>        \hfil
%<latexrelease|fltrace>        {\normalcolor\vrule \@width\columnseprule}%
%<latexrelease|fltrace>        \hfil
%<latexrelease|fltrace>       \hb@xt@\columnwidth{\box\@outputbox \hss}}}%
%<latexrelease|fltrace>  \@combinedblfloats
%<latexrelease|fltrace>    \@setmarks
%<latexrelease|fltrace>    \@outputpage
%<latexrelease|fltrace>    \begingroup
%<latexrelease|fltrace>      \@dblfloatplacement
%<latexrelease|fltrace>      \@startdblcolumn
%<latexrelease|fltrace>      \@whilesw\if@fcolmade \fi{\@outputpage
%<latexrelease|fltrace>     \@startdblcolumn}%
%<latexrelease|fltrace>    \endgroup
%<latexrelease|fltrace>  \fi}
%<latexrelease|fltrace>\EndIncludeInRelease
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease|fltrace>\IncludeInRelease{0000/00/00}%
%<latexrelease|fltrace>  {\@outputdblcol}{2 column marks}%
%<latexrelease|fltrace>\def\@outputdblcol{%
%<latexrelease|fltrace>  \if@firstcolumn
%<latexrelease|fltrace>    \global \@firstcolumnfalse
%<latexrelease|fltrace>    \global \setbox\@leftcolumn \box\@outputbox
%<*trace>
%<latexrelease|fltrace>    \fl@trace{PAGE: first column boxed}%
%</trace>
%<latexrelease|fltrace>  \else
%<latexrelease|fltrace>    \global \@firstcolumntrue
%<latexrelease|fltrace>    \setbox\@outputbox \vbox {%
%<latexrelease|fltrace>                         \hb@xt@\textwidth {%
%<latexrelease|fltrace>                           \hb@xt@\columnwidth {%
%<latexrelease|fltrace>                             \box\@leftcolumn \hss}%
%<latexrelease|fltrace>                           \hfil
%<latexrelease|fltrace>                           {\normalcolor\vrule
%<latexrelease|fltrace>                               \@width\columnseprule}%
%<latexrelease|fltrace>                           \hfil
%<latexrelease|fltrace>                           \hb@xt@\columnwidth {%
%<latexrelease|fltrace>                             \box\@outputbox \hss}%
%<latexrelease|fltrace>                                             }%
%<latexrelease|fltrace>                              }%
%<*trace>
%<latexrelease|fltrace>    \fl@trace{PAGE: second column also boxed}%
%</trace>
%<latexrelease|fltrace>    \@combinedblfloats
%<latexrelease|fltrace>    \@outputpage
%<*trace>
%<latexrelease|fltrace>    \fl@trace{PAGE: two column page completed}%
%</trace>
%<latexrelease|fltrace>    \begingroup
%<latexrelease|fltrace>      \@dblfloatplacement
%<latexrelease|fltrace>      \@startdblcolumn
%    \end{macrocode}
%    This loop could be replaced by an |\expandafter| tail
%    recursion in\\ |\@startdblcolumn|.
%    \begin{macrocode}
%<latexrelease|fltrace>      \@whilesw\if@fcolmade \fi
%<latexrelease|fltrace>        {\@outputpage
%<*trace>
%<latexrelease|fltrace>      \fl@trace{PAGE: double float page completed}%
%</trace>
%<latexrelease|fltrace>         \@startdblcolumn}%
%<latexrelease|fltrace>    \endgroup
%<latexrelease|fltrace>  \fi
%<latexrelease|fltrace>}%
%<latexrelease|fltrace>\EndIncludeInRelease
%</2ekernel|fltrace|latexrelease>
%    \end{macrocode}
%
% \subsubsection{Float placement parameters}
% \changes{v1.0i}{1993/12/14}{Section added to declare all parameters}
%
% The main purpose of this section is to ensure that all the
% float-placement parameters which need to be set in a class file or
% package have been declared.  It also describes their use and sets
% values for them which are reasonable for typical documents using
% US letter or A4 sized paper.
%
% \paragraph{Limits for the placement of floating objects}
%
% \begin{macro}{\c@topnumber}
%    This counter holds the maximum number of
%    floats that can appear at the top of a text page or column.
%    \begin{macrocode}
%<*2ekernel>
\newcount\c@topnumber
\setcounter{topnumber}{2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\topfraction}
%    This macro holds the maximum proportion (as a decimal number) of
%    a text page or column that can be occupied by floats at the top.
%    \begin{macrocode}
\newcommand\topfraction{.7}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@bottomnumber}
%    This counter holds the maximum number of
%    floats that can appear at the bottom of a text page or column.
%    \begin{macrocode}
\newcount\c@bottomnumber
\setcounter{bottomnumber}{1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bottomfraction}
%    This macro holds the maximum proportion (as a decimal number) of
%    a text page or column that can be occupied by floats at the bottom.
%    \begin{macrocode}
\newcommand\bottomfraction{.3}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@totalnumber}
%    This counter holds the maximum number of floats that can appear on
%    any text page or column.
%    \begin{macrocode}
\newcount\c@totalnumber
\setcounter{totalnumber}{3}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\textfraction}
%    This macro holds the minimum proportion (as a decimal number) of
%    a text page or column that must be occupied by text.
%    \begin{macrocode}
\newcommand\textfraction{.2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\floatpagefraction}
%    This macro holds the minimum proportion (as a decimal number) of
%    a page or column that must be occupied by floating objects before a
%    `float page' is produced.
%    \begin{macrocode}
\newcommand\floatpagefraction{.5}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@dbltopnumber}
%    This counter holds the maximum number of double-column floats that
%    can appear on the top of a two-column text page.
%    \begin{macrocode}
\newcount\c@dbltopnumber
\setcounter{dbltopnumber}{2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dbltopfraction}
%    This macro holds the maximum proportion (as a decimal number) of
%    a two-column text page that can be occupied by double-column floats
%    at the top.
%    \begin{macrocode}
\newcommand\dbltopfraction{.7}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dblfloatpagefraction}
%    This macro holds the minimum proportion (as a decimal number) of
%    a page that must be occupied by double-column floating objects
%    before a `double-column float page' is produced.
%    \begin{macrocode}
\newcommand\dblfloatpagefraction{.5}
%    \end{macrocode}
% \end{macro}
%
% \paragraph{Floats on a text page}
%
% \begin{macro}{\floatsep}
% \begin{macro}{\textfloatsep}
% \begin{macro}{\intextsep}
%    When a floating object is placed on a page with text, these
%    parameters control the separation between the float and the other
%    objects on the page. These parameters are used for both
%    one-column mode and single-column floats in two-column mode.
%    They are all rubber lengths.
%
%    |\floatsep| is the space between adjacent floats that are placed
%    at the top or bottom of the text page or column.
%
%    |\textfloatsep| is the space between the main text and floats
%    at the top or bottom of the page or column.
%
%    |\intextsep| is the space between in-text floats and the text.
%    \begin{macrocode}
\newskip\floatsep
\newskip\textfloatsep
\newskip\intextsep
\setlength\floatsep    {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep   {12\p@ \@plus 2\p@ \@minus 2\p@}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dblfloatsep}
% \begin{macro}{\dbltextfloatsep}
%    When double-column floats (floating objects that span the whole
%    |\textwidth|) are placed at the top of a text page in two-column
%    mode, the separation between the float and the text is controlled
%    by |\dblfloatsep| and |\dbltextfloatsep|.  They are rubber lengths.
%
%    |\dblfloatsep| is the space between adjacent double-column floats
%    placed at the top of the text page.
%
%    |\dbltextfloatsep| is the space between the main text and
%    double-column floats at the top of the page.
%    \begin{macrocode}
\newskip\dblfloatsep
\newskip\dbltextfloatsep
\setlength\dblfloatsep    {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \paragraph{Floats on their own page or column}
%
% \begin{macro}{\@fptop}
% \begin{macro}{\@fpsep}
% \begin{macro}{\@fpbot}
%    When floating objects are placed on a separate page or column,
%    called a `float page', the layout of the page is controlled by
%    these parameters, which are rubber lengths.
%
%    At the top of the page |\@fptop| is inserted;
%    typically this supplies some stretchable whitespace.
%    At the bottom of the page |\@fpbot| is inserted.
%    Between adjacent floats |\@fpsep| is inserted.
%
%    These parameters are used for all floating objects on a
%    `float page' in one-column mode, and for single-column
%    floats in two-column mode.
%
%    Note that at least one of the two parameters |\@fptop| and
%    |\@fpbot| should contain a |plus ...fil| so as to fill the
%    remaining empty space.
%    \begin{macrocode}
\newskip\@fptop
\newskip\@fpsep
\newskip\@fpbot
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{8\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@dblfptop}
% \begin{macro}{\@dblfpsep}
% \begin{macro}{\@dblfpbot}
%    Double-column `float pages' in two-column mode use similar
%    parameters.
%    \begin{macrocode}
\newskip\@dblfptop
\newskip\@dblfpsep
\newskip\@dblfpbot
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{8\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\topfigrule}
% \begin{macro}{\botfigrule}
% \begin{macro}{\dblfigrule}
%    The macros can be used to put in rules between floats and text;
%    whatever they insert should be vertical mode material which takes
%    up zero space.
% \task{CAR}{Add more rules (for Frank in addtocurcol)}
%    \begin{macrocode}
\let\topfigrule=\relax
\let\botfigrule=\relax
\let\dblfigrule=\relax
%</2ekernel>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \Finale
\endinput
