\def\filename{endfloat}
\def\fileversion{v2.6}
\def\filedate{2018/03/24}
\def\docdate{2018/03/24}
%
% \CheckSum{801}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%
% \iffalse
%% Description: LaTeX style to put figures and tables at end of article
%% Keywords: LaTeX, style-option, float, figure, table
%% Authors: James Darrell McCauley <jdm5548@diamond.tamu.edu>,
%%		Jeff Goldberg <jeffrey@goldmark.org>,
%%		Axel Sommerfeldt <axel.sommerfeldt@f-m.fm>
%% Maintainer: Axel Sommerfeldt <axel.sommerfeldt@f-m.fm>
%% Latest Version: Version 2.6 <March 2018>
% \fi
%
% \DoNotIndex{\documentclass,\usepackage,\hfuzz,\small,\tt,\begin,\end}
% \DoNotIndex{\NeedsTeXFormat,\filedate,\fileversion,\DoNotIndex}
% \DoNotIndex{\def,\edeg,\xdef,\gdef,\let,\divide,\advance,\multiply}
% \DoNotIndex{\",\-,\H,\',\\,\{,\},\^,\ }
% \DoNotIndex{\begingroup,\endgroup,\catcode,\global,\relax,\space}
% \DoNotIndex{\string,\immediate}
% \DoNotIndex{\normalsize,\large,\Large,\small,\tiny,\bf}
% \DoNotIndex{\@z}
% \DoNotIndex{\ifthenelse,\and,\equal,\whiledo,\if,\fi,\else}
% \DoNotIndex{\CodelineIndex,\EnableCrossrefs,\DisableCrossrefs}
% \DoNotIndex{\DocInput,\AltMacroFont}
% \DoNotIndex{\RecordChanges,\OnlyDescription}
% \DoNotIndex{\@input,\@namedef,\@whilesw,\clearpage,\ifnum,\ifx}
% \DoNotIndex{\jobname,\message,\MessageBreak,\newcommand}
% \DoNotIndex{\protect,\providecommand,\ProvidesPackage,\renewcommand}
% \DoNotIndex{\section,\setlength}
%
% \changes{v0.1}{1992/02/25}{created by Darrell McCauley (jdm)}
% \changes{v1.0}{1992/03/01}{cleaned up and released jdm}
% \changes{v2.0}{1992/06/02}{incorporated changes made by bj (see v1.99). jdm}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
% \changes{v2.1c}{1994/07/20}{Modify documentation -jpg}
% \changes{v2.3}{1995/03/05}{Fix figure* bug and docs -jpg}
%
% \newcommand*{\pkg}[1]{\textsf{#1}}
% \newcommand*{\file}[1]{\texttt{#1}}
% \newcommand*{\cls}[1]{\textsl{#1}}
% \newcommand{\bs}{\texttt{\char'134}}
% \newcommand*\x{\discretionary{-}{}{}}
%
% \title{The \texttt{\filename} package\thanks{This file
%        has version number \fileversion, last
%        revised \filedate, documentation dated \docdate.}}
% \author{James Darrell McCauley
%  \and Jeff Goldberg\thanks{JPG (jeffrey@goldmark.org)
%    is responsible for all modifications
%    from version 2.1 upwards.  Since there is almost no original code
%    left, he has claimed co-authorship from version 2.4.}
%  \and Axel Sommerfeldt\thanks{Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
%    is responsible for all modifications
%    from version 2.5 upwards.  He is
%    also the current maintainer.}
% }
% 
% \date{\docdate}
%
% \maketitle
%
% \begin{abstract}
% The purpose of this package is to put all figures on pages by themselves
% at the end of an article in a section named Figures. Likewise for tables.
% Markers, like ``[Figure 3 about here]'' appear in the text (by default)
% near where the figure (or table) would normally have occurred.
% This is usually required when preparing submissions to journals.
%
% A number of package options and other mechanisms are provided to
% give the user control over various aspects of the package's behavior.
%
% Loading this package will change the output of \LaTeX.
% \end{abstract}
% 
% \tableofcontents
% \section{In many voices}
%
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% This documentation was put in its current form by Jeff Goldberg,
% who has tried to indicate when he is (when
% I am) speaking.   See \autoref{sec:history} for more detail.
% However, both the original author, Darrell McCauley, and
% a major contributor, Brian Junker, use the first person
% singular.  In this version I no longer work to keep it clear
% who wrote what portions of the documentation and the code, but
% have allowed things to blend together a little more, since the
% constant interpolations were hindering readability.  Generally
% the user documentation was written by Darrell MaCauley (jdm),
% but anything that refers to \LaTeXe\ features was added
% by me (jpg).  Also, where you find spelling and typographical
% errors, you are likely to be reading my text.
%
% Axel Sommerfeldt has added a section about dealing with
% other floating environments than |figure| and |table|, and
% made adaptions to other sections affected by the
% changes of version 2.5. Furthermore he has added paragraphs
% about his \pkg{caption} package in section \ref{sec:removingcaptions}
% ``Removing captions''.
%
% This documentation is long.  Most users won't need to read beyond
% the first few pages, but there are a number of ways to customize
% the behavior of \pkg{endfloat} and these are detailed as the
% documentation progresses.  The package is unusual in the way
% it does its job, so it can interact with other packages and
% other aspects of \LaTeX\ in ways that may be surprising.
% Although the package is flexible in some respects, it is
% highly limited in others.
% Tools and hints are provided to help you control these interactions,
% but these do require some reading.  But you only need to take
% a look at these sections when the need arises.
%
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
%
% \section{Why write this package?}
% 
% Many journals require tables and figures to be separated from the text
% when you submit those ugly double spaced copies.  They also usually want
% a list of figures/tables before these sections (capability added in v2.0,
% control through package options added in v2.2).
%
% I (jdm) am writing a set of styles that look exactly like a journal, but just
% by adding one style option, I wanted the user to meet the requirements
% for formatting submissions. I encourage others to do the
% same.\footnote{Note that jdm, working in old \LaTeX209
% did not have the distinction between class, package and package
% options available to him at the time he made his comment.
% The most coherent way to do what is needed is to use a class,
% let's say \cls{submit}, which would load \pkg{endfloat} and
% presumably some double spacing packages among other things.  Once
% that class is defined, then other classes which are specific
% to particular journals can be defined.} 
%
% \section{Usage}
% \subsection{Loading}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% Just include the package in your preamble
% \begin{quote}
%   |\usepackage[|\ldots|]{endfloat}|
% \end{quote}
% 
% Note that versions 2.1 and beyond will no longer work with
% \LaTeX209.  Get your administrator to upgrade your site
% to the new standard, \LaTeXe.  Although version~2.0 (a \LaTeX209 version)
% will usually work with \LaTeXe, it will not do so in combination
% with certain other packages.
%
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
%
% \subsection{What it does}
%
% Merely loading the package will get it working.  Loading it will
% have \LaTeX\ produce two extra files with
% \texttt{.ttt} and \texttt{.fff} extensions
% (for tables and figures, respectively).
%
% This puts all figures and tables at the end of your document
% each on a page by itself\footnote{This
%    is the default.  See \autoref{sec:separator} to see how
%    to have multiple floats per page.}
% and creates a List of Figures and/or List of Tables section
% at the end (when appropriate and controllable by options).
% The floats are processed using |\baselinestretch{1}| irrespective
% of what is used in the document as a whole.  This can be
% reset to, say 1.4, by using
% \begin{quote}
%   |\AtBeginDelayedFloats{%|\\
%   |  \renewcommand{\baselinestretch}{1.4}}|
% \end{quote}
% which is available from version 2.4.  See \autoref{sec:hooks}
% for more discussion.
%
% It also leaves notes in the text (i.e., ``[Figure 4 about here.]'').
% If you would rather not have these, this can be turned off by
% using the |nomarkers| options.  If you
% do not like the look of this marker, you can change
% their text and appearance
% (see \autoref{sec:language}).
%
% \subsection{Starred floats}
% The |figure*| and |table*| versions are supported by the current
% version.\footnote{I (jpg) very stupidly introduced a bug in version 2.2
% which wrecked |figure*|.  It has been brought to my attention and
% fixed.  I offer my thanks and my apologies.}
% \iffalse % commented out by Axel Sommerfeldt since not true for version >= 2.4
% However, it must be noted that what actually gets processed at the
% end is always with the star, since in single column mode the
% |*| is harmless.
% \fi
%
% \subsection{Options} \label{sec:options}
% 
% Under version 2.2 and higher,
% the \pkg{endfloat} package uses package options.  The options
% are summarized in table~\ref{tab:options}.  In addition to these
% options, see sections~\ref{sec:extra} and~\ref{sec:hooks} for more
% advanced ways of controlling output.
%
% \begin{table}
% \caption{Options and defaults} \label{tab:options}
% \smallskip
% \begin{tabular}{lcll}
% \hline
% \multicolumn{1}{c}{Option} &
% \multicolumn{1}{c}{Default}&
% \multicolumn{1}{c}{Default implication} &
% \multicolumn{1}{c}{Descriptions} \\
% \hline
% |nofiglist|    & off  &                          & no list of figures          \\
% |notablist|    & off  &                          & no list of tables           \\
% |nolists|      &      & |nofiglist|, |notablist| & neither list                \\
% |figlist|      & on   &                          & list of figures             \\
% |tablist|      & on   &                          & list of tables              \\
% |lists|        &      & |figlist|, |tablist|     & list of tables and figures  \\
% |nofighead|    & on   &                          & no `Figures' section header \\
% |notabhead|    & on   &                          & no `Tables' section header  \\
% |noheads|      &      & |nofighead|, |notabhead| & neither of the headers      \\
% |fighead|      & off  &                          & `Figures' section header    \\
% |tabhead|      & off  &                          & `Tables' section header     \\
% |heads|        &      & |fighead|, |tabhead|     & Both section headers        \\
% |markers|      & on   &                          & Place markers in the text   \\
% |nomarkers|    & off  &                          & no markers in text          \\
% |tablesfirst|  & off  &                          & Put tables before figures   \\
% |figuresfirst| & on   &                          & Put figures before tables   \\
% |tablesonly|   & off  &                          & Handle tables only          \\
% |figuresonly|  & off  &                          & Handle figures only         \\
% |notables|     & off  &                          & Disregard tables            \\
% |nofigures|    & off  &                          & Disregard figures           \\
% \hline
% \end{tabular}
% \end{table}
%
% The list of tables and figures can be suppressed by using the
% \texttt{nofiglist} and \texttt{notablist} options.  Both
% can be suppressed with the \texttt{nolists} option.\footnote{In
% versions prior to 2.2 the command for turning off the lists turned
% on the headers (the equivalent of the |heads| option).  That is
% not the case with these options.  The |lists| and the |heads|
% options are entirely orthogonal.}
% The default is \texttt{lists}.
%
% A section header for `Tables' and `Figures' can be produced by using
% the option |tabhead|, |fighead|, respectively, and |heads| for both.
% The defaults are |notabhead| and |nofighead|.
%
% If you want the headers instead of the lists you would need to 
% use both the |nolists| and the |heads| options.
%
% If you want to suppress the markers in the text, use the
% option \texttt{nomarkers}.  The default is
% \texttt{markers}.
%
% Normally the figures at the end appear before the tables.
% This can be changed by using the option \texttt{tablesfirst}.
% The default is \texttt{figuresfirst}.
% \iffalse % Commented out by Axel Sommerfeldt
% \footnote{It is hoped that
%   future versions will allow new kinds of float or environment
%   to be delayed, in which case an entirely new mechanism will
%   need to be introduced for ordering their appearance.}
% \fi
%
% If nothing else if specified, both figures and tables will be handled
% by the \pkg{endfloat} package.
% This can be altered by usage of the options |tables|\x|only|
% resp. |figures|\x|only|.
% 
% \medskip
%
% A typical usage might be something like
% \begin{quote}
%   |\documentclass[a4paper,12pt]{article}|\\
%   |\usepackage[nolists,tablesfirst]{endfloat}|\\
%   \ldots\\
%   |\begin{document}|
% \end{quote}
% which would suppress the list of tables and figures as well as
% the corresponding section headers, and would have the tables
% precede the figures.
%
% \subsubsection{Contradictions and dilemmas}
%
% It is not recommended that one specify conflicting options, but
% if you insist, here are the rules.  In table~\ref{tab:options} the third
% column indicates what other options are implied by default.  That
% is |heads| turns on |fighead| by default, but that implication
% can be overruled by explicitly stating the |nofighead| option.
%
% \begin{enumerate}
% \iffalse % commented out by Axel Sommerfeldt
% \item \label{rule:default}
%   When two entirely conflicting options are both specified
%   the one corresponding to the default wins.
%   (e.g., if both |markers| and |nomarkers| are specified then
%   |markers| will be in effect).  Here the notion of default is
%   determined by inspecting the second column of table~\ref{tab:options}.
% \fi
% \item \label{rule:elsewhere}
%   When one option is more specific than the other the more specific
%   one holds true, and the more general will only partially hold.
%   So specifying \texttt{fighead} and \texttt{noheads} will be the
%   same as saying \texttt{fighead} and \texttt{notabhead}.
% \item
% \iffalse % changed by Axel Sommerfeldt
%   The order in which the options appear is not relevant.
% \else
%   The order in which the options appear is relevant.
% \fi
% \item
%   If some of the obsolete commands for these options are used
%   all bets are off on these interactions.
% \end{enumerate}
%
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% 
% \section{Modifying marker text}\label{sec:language}
%
% \changes{v1.0b}{1992/03/10}{adaptation for LaTeX 2.09 and
%                      international namegiving by Ronald Kappert
%                      R.Kappert@urc.kun.nl}
% \DescribeMacro{\tableplace}
% \DescribeMacro{\figureplace}
% \DescribeMacro{\floatplace}
%  Announcements in any language can be generated by 
%   using |\re|\x|new|\x|command| to redefine |\table|\x|place| and
%   |\figure|\x|place|, or by redefining |\float|\x|place|.
%
%  The defaults are
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \begin{quote}
%   |\newcommand\figureplace{\floatplace{figure}}|\\
%   |\newcommand\tableplace{\floatplace{table}}|\\
%   \\
%   |\newcommand\floatplace[1]{%|\\
%   |  \begin{center}|\\
%   |    [\csname #1name\endcsname~%|\\
%   |     \csname thepost#1\endcsname\ about here.]|\\
%   |  \end{center}}|
% \end{quote}
%
% These redefinitions may be placed in the \file{endfloat.cfg}
% file (see \autoref{sec:extra} for more information).
%
% WARNING! The name of the counters |post|\x|tbl| and |post|\x|fig|
% have been changed to |post|\x|table| and |post|\x|figure| in version 2.5.
% However, |\the|\x|post|\x|tbl| and |\the|\x|post|\x|fig| are still available for
% usage inside redefined versions of |\table|\x|place| and |\figure|\x|place|
% so old documents (hopefully) will still work.
%
% Hooks for the \texttt{babel} package are not (yet) provided, so
% you will have to do things by hand:
% \begin{quote}
%   |\renewcommand{\figurename}{Abra} % if no babel|\\
%   |\renewcommand{\figureplace}{%|\\
%   |  \begin{center}|\\
%   |    [A(z) \thepostfigure.~\figurename itt legyen.]|\\
%   |  \end{center}}|
% \end{quote}
% 
% If you wish to change the name of the figure or table section
% heading, you can do that in the usual way (via the \texttt{babel}
% package, or by redefining |\figure|\x|section| and |\table|\x|section|
% directly).
%
% \DescribeMacro{\efloatheading}
% Endfloat uses |\efloat|\x|heading| for applying this heading.
% By default it is defined to use |\mark|\x|both| for that purpose:
% \begin{quote}
%   |\newcommand\efloatheading[1]{%|\\
%   |  \markboth{\uppercase{#1}}{\uppercase{#1}}}|
% \end{quote}
% forcing the headings applied in uppercase.  You may change this by using
% |\re|\x|new|\x|command| to redefine |\efloat|\x|heading| as you wish:
% \begin{quote}
%   |\renewcommand\efloatheading[1]{|\meta{code that applies \#1 as heading}|}|
% \end{quote}
% It makes most sense to place such a redefinition in the configuration
% file (see \autoref{sec:extra}).
%
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v1.0b}{1992/03/10}{adaptation for LaTeX 2.09 and
%                      international namegiving by Ronald Kappert
%                      R.Kappert@urc.kun.nl}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
%
% \section{Commands before processing delayed material} \label{sec:hooks}
%
% \DescribeMacro{\AtBeginFigures}
% \DescribeMacro{\AtBeginTables}
% \DescribeMacro{\AtBeginDelayedFloats}
% If you wish to have some more control over how the tables and figures
% are processed, you can make use of the commands |\At|\x|Begin|\x|Delayed|\x|Floats|,
% |\At|\x|Begin|\x|Figures|, and |\At|\x|Begin|\x|Tables|.
% If you wanted to ensure that the tables begin
% on a recto page, you could for example say something like
% |\At|\x|Begin|\x|Tables{\clear|\x|double|\x|page}| in the preamble  of your
% document.\footnote{It is difficult for me to imagine a situation where
% one would be using \pkg{endfloat} and the class option \texttt{twoside},
% without which \texttt{\bslash cleardoublepage}
% is the same as \texttt{\bslash clearpage}, together.
% Another, more realistic example would be to adjust the
% \texttt{\bslash baselinestretch} for table and figure processing.}
% Material in |\At|\x|Begin|\x|Tables| and |\At|\x|Begin|\x|Figures| is processed after
% the list of tables or list of figures (if those options are set) and
% just before the files with the delayed material in input.  These are
% also processed after the original definitions of the table and figure
% environments are restored.
%
% These commands can be used either in the preamble of your document,
% or in the \file{endfloat.cfg} file (see \autoref{sec:extra}).
% 
% \section{Processing delayed floats before the end}
%
% \DescribeMacro{\processdelayedfloats}
% If you wish to process
% the floats prior to the end of the document, you may do so with the
% |\processdelayedfloats| command, which has been made available from
% version~2.4 onward.  This will process all of the
% unprocessed tables and figures up to that point.  You may wish
% to use this command at the end of every chapter for example.
%
% If you do use this, there are several points which should be noted.
% \begin{enumerate}
% \item All outstanding floats will be processed at the
%   end of the document.
% \item If you use the |lists| option you will get a list of all
%   tables and figures in the document.  Not just the ones for
%   the current chapter.  Using lists may have other odd consequences.
% \item It is your responsibility to set |\table|\x|place| and
%   |\figure|\x|place| correctly, as well as to possibly reset
%   the counters |\the|\x|post|\x|table| and |\the|\x|post|\x|figure| (\autoref{sec:language})
%   as you wish.  If you do not reset them, they will continue to
%   increase throughout the document.
% \end{enumerate}
% 
% \section{Several floats per page}\label{sec:separator}
%
% \DescribeMacro{\efloatpreamble}
% Endfloat applies |\efloat|\x|preamble| before typesetting the very first
% (delayed) float in their respective files.
% By default it is defined to do nothing.
% You may change this by using
% |\re|\x|new|\x|command| to redefine |\efloat|\x|preamble| as you wish.
%
% \medskip
%
% \DescribeMacro{\efloatseparator}
% Endfloat places |\efloat|\x|separator| between the floats in their
% respective files.  By default it is defined to be |\clear|\x|page|
% forcing one float per page.  You may change this by using
% |\re|\x|new|\x|command| to redefine |\efloat|\x|separator| as you wish.
% One possibility, suggested by a user, is
% \begin{quote}
%   |\renewcommand{\efloatseparator}{\mbox{}}|
% \end{quote}
%
% \DescribeMacro{\efloatpostamble}
% Endfloat applies |\efloat|\x|postamble| after typesetting the very last
% (delayed) float in their respective files.
% By default it is defined to be |\efloat|\x|separator|.
% You may change this by using
% |\re|\x|new|\x|command| to redefine |\efloat|\x|postamble| as you wish.
%
% \medskip
%
% It makes most sense to place such redefinitions in the configuration
% file (see \autoref{sec:extra}).
%
% \medskip
%
% \DescribeMacro{\efloattype}
% If you need to know what floats are actually processed, you could draw on
% |\efloat|\x|type| which is set to the environment type currently processed,
% for example |figure| or |table|.
%
% \section{Configuration file and other end environments}\label{sec:extra}
%
% Many users have suggested options to the package which are
% often journal specific.  Many of the suggestion options are
% also not specific to how \pkg{endfloat} itself works, but to how
% captions and lists of figures and tables are to appear.
% Instead of burdening the package with options that, in the
% end, are specific to particular journals, I have added a
% configuration file for \pkg{endfloat} which will allow
% you to make many of these redefinitions without
% having to further increase the size of \pkg{endfloat} itself.
%
% As of version 2.4 \pkg{endfloat} will look for a file
% called \file{endfloat.cfg} in \TeX's input path.  If it
% is found, it will be included after \pkg{endfloat} is loaded.
% The purpose of this configuration file is to allow the user to
% include additional definitions related to \pkg{endfloat}.
% For example, any redefinition of \verb"\floatplace" can
% go in this file, so that the preamble does not need to
% be filled with material that only makes sense when
% \pkg{endfloat} is loaded.\footnote{However, if you find yourself
% placing other material (such as double spacing or modification
% of title page and abstract) into \file{endfloat.cfg} to
% simulate a journal submission class, you should really
% do the right thing and create a journal submission class.
% Creating a minor class (one that loads an existing class
% such as \cls{article} is not difficult.  See the
% \textit{Class Guide}\cite{LT3:ClassGuide} for instructions.  Future versions
% of the \pkg{endfloat} documentation may include a sample.}
%
% The configuration file can also provided
% so that the user could specify environments other
% than |figure| and |table| (and their |*|-ed counterparts) which can
% be delayed until the end of the document.
% \iffalse % commented out by Axel Sommerfeldt
% At the moment that would
% be very difficult to do with environments which are not processed with
% tables of figures (ie, those environments that should have a different
% ``list-of'', different counters, and different temporary files from
% those used by tables and figures); but the plan is to make even that
% ever more easier.
% \fi
%
% \subsection{Modified figures and tables}
%
% As stated in \autoref{sec:envnames}, \pkg{endfloat} will
% utterly fail if one does something like
% \begin{quote}
%   |\newenvironment{foo}{...\begin{table}...}|\\
%   |    {...\end{table}...}|
% \end{quote}
% because \pkg{endfloat} will make |\begin{table}| go into a verbatim
% like mode and look for the literal string |\end{table}|, which it
% will not see in |\end{foo}|.
%
% \iffalse
% However, for those who know \LaTeX\ internals fairly well, it is
% not impossible to tell \pkg{endfloat} to also treat the |foo| environment
% as a delayed table.  It is however, not easy, although my goal
% is to make this easier in subsequent versions.   It will take
% a fair amount of understanding of the implementation to see how to
% do this.  And the best thing to do is to follow an example.
% \else
% However, inserting the following code into the document preamble
% may be worth a try:
% \begin{quote}
%   |\DeclareDelayedFloatFlavor{foo}{table}|
% \end{quote}
% This tells the \pkg{endfloat} package that |foo| should be treated as |table|,
% at least from \pkg{endfloat}'s point of view.
% If you keep your fingers crossed this may actually work.
% \fi
%
% \subsection{Environments based on figures and tables}
%
% The \pkg{rotating} package\cite{RahBar:rotating}
% contains definitions of environments
% |side|\x|ways|\x|figure| and |side|\x|ways|\x|table|\footnote{These
% require support from the dvi driver, such as \texttt{dvips}.},
% and it would be nice to have these work in documents which also
% use \pkg{endfloat}.
% \iffalse % changed by Axel Sommerfeldt
% \par
% Appropriate redefinitions of these so that they work with \pkg{endfloat}
% are given in the file \file{efxmpl.cfg}.  If you wish to use
% that file, you should include it as a package (possibly renamed)
% \emph{after} you include \pkg{endfloat}.  Or you could simple rename
% it to \file{endfloat.cfg} and \pkg{endfloat} will include it automatically.\par
% For a description of those commands see \autoref{sec:config}.
% \else
% This can be archived with
% \begin{quote}
%   |\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}|\\
%   |\DeclareDelayedFloatFlavor{sidewaystable}{table}|
% \end{quote}
% after loading both, the \pkg{endfloat} and \pkg{rotating} package.
% The general syntax of |\Declare|\x|Delayed|\x|Float|\x|Flavor| is
% \begin{quote}
%   |\DeclareDelayedFloatFlavo|(|u|)|r|\marg{environment}\marg{is a variant of}
% \end{quote}
% so for example
% \begin{quote}
%   |\usepackage{endfloat,threeparttable}|\\
%   |\DeclareDelayedFloatFlavour{threeparttable}{table}|
% \end{quote}
% makes the |three|\x|part|\x|table| environment known to the \pkg{endfloat} package
% as a variant of the floating environment |table|.
%
% This works with the |long|\x|table| environment as well:
% \begin{quote}
%   |\usepackage{endfloat,longtable}|\\
%   |\DeclareDelayedFloatFlavour*{longtable}{table}|
% \end{quote}
% Note that we use the starred variant of |\Declare|\x|Delayed|\x|Float|\x|Flavor|
% here which only redefines |long|\x|table| but leaves the unnumbered
% |long|\x|table*| intact.
% \fi
%
% \subsection{Other floating environments}
%
% By using |\new|\x|float| offered by the \pkg{float} package\cite{Lingnau:float},
% or |\Declare|\x|New|\x|Float|\x|Type| offered by the \pkg{floatrow} package\cite{Lapko:floatrow},
% or |\Declare|\x|Floating|\x|Environment| offered by the \pkg{newfloat}
%  package\cite{Sommerfeldt:newfloat}
% one can define new floating environments. These environments
% can be made supported by the \pkg{endfloat} package, too, e.g.
% \begin{quote}
%   |\usepackage{newfloat,endfloat}|\\
%   |\DeclareFloatingEnvironment{map}|\\
%   |\DeclareDelayedFloat{map}{Maps}|
% \end{quote}
% will define a new floating environment called ``map'' and
% set up the \pkg{endfloat} package to handle this environment, too.
%
% The trick is using the command
% \begin{quote}
%   |\DeclareDelayedFloat|\marg{float}\oarg{file extension}\marg{heading}
% \end{quote}
% which makes the new floating environment known to the \pkg{endfloat} package.
%
% The \meta{file extension} specifies the file where the floating environments
% will be stored, like |fff| for figures and |ttt| for tables.
% If no \meta{file extension} is given, |ef|\meta{float} will be used, e.g. |efmap|
% will be used as file extension in the code example above.
%
% The \meta{heading} will be used for the section header, if selected.
% If |\list|\meta{float}|name| is not defined, it will be used for the list heading, too.
%
% The package options |nolists|, |lists|, |noheads|, and |heads| will be respected
% for new environments, too. But if you would like to set individual options for
% them, you can do so by using
% \begin{quote}
%   |\SetupDelayedFloat|\marg{float}\marg{options}
% \end{quote}
% where options are |nolist|, |list|, |nohead|, and |head| analogous to the package
% options for figures and tables specified in section \ref{sec:options}.
%
% By the way, |\Setup|\x|Delayed|\x|Float| works for the environments |figure| and
% |table|, too, so
% \begin{quote}
%   |\usepackage[nofiglist,fighead]{endfloat}|
% \end{quote}
% is identical to
% \begin{quote}
%   |\usepackage{endfloat}|\\
%   |\SetupDelayedFloat{figure}{nolist,head}|
% \end{quote}
% and (if you prefer using key-value options instead)
% \begin{quote}
%   |\usepackage{endfloat}|\\
%   |\SetupDelayedFloat{figure}{list=false,head=true}|
% \end{quote}
%
% \subsection[Changing list and caption appearance]
%     {Changing the appearence of ``lists of'' and captions}
%
% When the |lists| option is used, the \LaTeX\ commands |\list|\-|of|\-|tables|
% and |\list|\-|of|\-|figures| are called.  These produce lists indicating
% the page number that each table or figure appear on.  With \pkg{endfloat}
% in use this information is usually superfluous, and -- rumor has it --
% undesirable by at least some journals.
% What seems to be required
% when using lists is that either the list does not the figure or table number,
% and/or the caption doesn't not contain the caption text.
%
% This section provides a few rudimentary samples of what you might
% put into the configuration file to get these effects.  I have chosen
% not to make these package options, because they are often too journal
% specific.  The availability of the configuration file means that
% you can put this things there, and the differences between \pkg{endfloat}
% using and non-\pkg{endfloat} using \LaTeX\ source documents is minimal.
%
% \subsubsection{Removing captions}
% \label{sec:removingcaptions}
%
% \DescribeMacro{\captionsetup}
% If you have included the \pkg{caption} package in your document
% you can omit the caption text by adding
% \begin{quote}
%  |\captionsetup{labelsep=none,textformat=empty}|
% \end{quote}
% to the preamble of your document.~\footnote{%
% This needs at least version $3.2$ of the \pkg{caption} package.}
% If this should be done for figures (or tables) only one can use the
% optional argument of |\caption|\x|setup|, e.g.:
% \begin{quote}
%  |\captionsetup[figure]{labelsep=none,textformat=empty}|
% \end{quote}
% See \pkg{caption} package documentation for details and alternatives.
%
% \DescribeMacro{\@makecaption}
% If the \pkg{caption} package is not used, the simplest thing
% is to provide a redefinition of |\@makecaption|.
% You should model your redefinition after the one used in the
% document class you actually use instead of blindly
% following what is here.  |\@makecaption| takes two arguments, the
% first will be something like ``figure 3'' and the second will
% be the caption text.  We will simply ignore the second argument.
% Most of the tricky bit of the definition
% is about testing whether the caption is longer than a line.  Since
% we will only be using the first argument, we can safely assume that
% the caption will fit on one line.\footnote{If you have 
% \texttt{\bs figurename} as something absurdly long or a
% very narrow \texttt{\bs textwidth},
% then you will have to use a more complicated version.}
% Your redefinition of |\@makecaption| may look like
% \begin{quote}
%   |\renewcommand{\@makecaption}[2]{%|\\
%   |  \vskip\abovecaptionskip|\\
%   |  \hbox to \hsize{\hfil #1\hfil}%|\\
%   |  \vskip\belowcaptionskip}|
% \end{quote}
% 
% \DescribeMacro{\caption}
% This still leaves one problem.   If you use
% \begin{quote}\ttfamily
%   |\caption|\oarg{short caption text}\marg{full caption text}
% \end{quote}
% only the short caption text will ever appear in the list of tables or
% figures.  The following redefinition of |\caption| will take care of
% that.
%
% Again, first of all a solution for usage with the \pkg{caption} package:~\footnote{%
% This needs at least version $3.3$ of the \pkg{caption} package.}
% \begin{quote}
%   |\captionsetup{list-entry=heading}|
% \end{quote}
%
% If the \pkg{caption} package is not used,
% the following code should be used instead:
% \iffalse
% First save the original definition of |\caption|
% \fi
% \begin{quote}
%   |\let\OrigCaption\caption|\\
%   |\renewcommand{\caption}[2][X]{\OrigCaption[#2]{}}|
% \end{quote}
%
% \subsubsection{Eliminating numbers from lists of tables and figures}
%
% This is a bit trickier, and I have heard that it doesn't work
% with all versions of \LaTeXe, but I am unwilling to reinstall
% and older version for debugging this.
% A user [get the name] suggested that page numbers be suppressed
% in the lists of figures and tables.
%
% \begin{macro}{\l@figure}
% \begin{macro}{\l@table}
% All this requires is a redefinition of |\l@figure| and |\l@table|
% which are defined in \texttt{classes.txt}.  Also see section~2.4.1 of the
% \emph{Companion} to see how these macros are called.
%
% The real only trick here is that |\l@figure| is defined to take
% two arguments, but the second is never used.  The way it will be
% called will give it something like
% \begin{quote}
%   |{\numberline {3} Caption of that figure}{85}|
% \end{quote}
% as arguments, where the second argument is the page number.
% The |\numberline| command will make use of the \LaTeX\ register
% |\@tempdima| for the width of the box containing the table
% or figure number.  So we need to set that.
% The rest is pretty unsophisticated.  You can, of course, modify it
% at will.
% \begin{quote}
%   |\renewcommand*{\l@figure}[2]{%|\\
%   |   \setlength\@tempdima{2.3em}%|\\
%   |   \noindent\hspace*{1.5em}#1\hfil\newline }|
% \end{quote}
% And for tables:
% \begin{quote}
%   |\let\l@table\l@figure|
% \end{quote}
% \end{macro}
% \end{macro}
% 
% \section{Obsolete commands}
%
% Versions of the package prior to 2.2 had some commands which the
% user could specify in the preamble to do what \emph{some} of the
% options do now.  Although I would like to eventually remove those
% commands, they are documented in the \textit{Companion}; so they
% will remain for quite some time.
% 
% \section{Caveats}\label{sec:caveats}
%
% Some of the things that are listed here may be considered bugs,
% design errors, interactions to watch out for, or just the
% way life is sometimes.  They are, at least, a matter of concern, and you
% should watch out for them.
% 
% \subsection{Literal strings}
%
% When floats are being read, \LaTeX\ is in verbatim mode.  Among
% other things, this means that the lines like
% \begin{quote}
%   |\end{figure}|
% \end{quote}
% or
% \begin{quote}
%   |\end{figure}%|
% \end{quote}
% must appear on lines by themselves without any whitespace before
% or after them.  A complete reimplementation of the most difficult
% part of the package is required to fix this limitation, but
% it is among the distant goals I have.
%
% \subsection{Extra files}
% This creates two extra files: \texttt{\meta{jobname}.fff} and
% \texttt{\meta{jobname}.ttt}.  Any files by those names
% in the current directory will be overwritten.
%
% \subsection{Environment names} \label{sec:envnames}
%
% Because of how the redefinitions of \texttt{figure} and \texttt{table}
% are actually implemented, it is crucial that these environment
% names be used.  That is, you cannot simply define a new environment which
% calls \texttt{figure} or \texttt{table} since the former must
% look for the literal string
% \begin{quote}
%   |\end{figure}|
% \end{quote}
% in the document, while doing no expansion of control sequences.
% The latter does the same, but wants |table| instead of
% |figure|.  This caution generally applies to all `verbatim-like'
% environments
%
% Although I haven't been able to confirm this yet, the
% \LaTeX\ system ScientificWord\footnote{A registered trademark.
% Write to info@tcisoft.com for more information.}
% may automatically put floats
% inside a macro called \verb"\FFRAME".  If so, I hope
% that either someone from ScientificWord or one of its
% users will create something for \verb"\FFRAME" similarly to
% what I have done for \verb"\sidewaystable" in the sample configuration
% file (\autoref{sec:extra}).
%
% \iffalse % commented out by Axel Sommerfeldt
% Steps are slowly being taken to allow for new delayed environments
% to be added.  That will be version~3, but I (jpg) still have
% a long way to go to get there.  Each new minor release of
% the package includes few changes visible to the user, but may
% contain substantial internal changes to move the package in the desired
% direction.  Version~2.4 now contains a configuration file in which
% various things can be defined.  See \autoref{sec:extra} for
% more information.
%
% Once it does become easier to delay other environments, the
% word ``float'' may not be the best expression, since there will
% be no reason to expect that only floating environments are
% delayed.
% \fi
%
% \subsection{The Environment's environment}\label{sec:envenv}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
%
% Because no \TeX\ expansion is done while the material in these
% floats are read in, but is delayed until the floats are
% processed at the end of the document, it will be the state of
% \TeX\ at the end which will matter.  For example, a document
% with something like
% \begin{quote}
%   |\newcommand{\XXX}{YYY}|\\
%   \ldots\\
%   |\begin{table}|\\
%   \ldots\\
%   \ldots |\XXX| \ldots\\
%   \ldots\\
%   |\end{table}|\\
%   \ldots\\
%   |\renewcommand{\XXX}{ZZZ}|\\
%   \ldots\\
%   |\end{document}|
% \end{quote}
%  will process the table with |\XXX| expanding to |ZZZ|.
%
% In any particular instance, the user can use either re-redefine
% |\XXX| before the end of document, or can re-redefine it using
% on of the hooks, |\At|\x|Begin|\x|Delayed|\x|Floats|, |\At|\x|Begin|\x|Tables|,
% or |\At|\x|Begin|\x|Figures|, which are discussed in \autoref{sec:hooks}.
%
% \subsection{Verbatim in delayed floats}\label{sec:verbatim}
%
% There should be no problem with verbatim text within a
% float unless that verbatim text contains an |\end{figure}| or
% |\end{table}| in a figure or table respectively.  I don't see
% a fix for this.  All I can imagine is that you create a new
% delayed type which behaves exactly like |figure| (or |table|)
% (even writing |\begin{figure}| and |\end{figure}| to the
% \texttt{.fff} file. [\textit{mutatis mutandis} for |table|])
% In future versions, I may create a sample like this in the
% sample configuration file, but it is a low priority since
% the only time one would write such a figure or table would
% be in a document about \LaTeX\ and it is difficult to imagine
% circumstances where a document about \LaTeX\ would need to
% be subject to \pkg{endfloat}.
%
% \subsection{Ordering End Document material}\label{sec:enddocument}
%
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
%
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1}{1994/06/25}{Use AtEndDocument. jpg}
%
% Version 2.1 uses the \LaTeXe\ directive |\AtEndDocument|.  This
% makes it \LaTeXe\ specific, but it means that it can be used
% with other packages that use that directive.  Previous versions
% of \pkg{endfloat} redefined |\enddocument|.  Now several
% packages or commands can add stuff at the ends of documents
% and still work together.  This does mean that \emph{the order
% of loading packages can be important!}  If you use several
% packages that may use the |\AtEndDocument| directive and you
% get funny results, try loading them in a different order.
% It that doesn't work, complain to the maintainer of the packages
% so that they will work out a way for the packages to interact
% correctly.
%
% \changes{v2.1}{1994/06/25}{Use AtEndDocument. jpg}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
%
% \subsubsection{General ordering and wish list}\label{sec:order}
%
% I believe that the output of a \LaTeXe\ run should be independent
% of the order in which package are loaded.  It would be possible
% to set this up, but it would take coordination of all package
% writers who use |\AtEndDocument|.  The actual call to |\AtEndDocument|
% would not occur during package loading, but some new command,
% like |\ExecuteAtEndDocument| would be called by the user after
% all such packages are loaded, with tags for each thing in the
% packages, so something like
% \begin{quote}
%   |\usepackage{lastpage}|\\
%   |\usepackage{endfloat,xyzzy}|\\
%   |\ExecuteAtEndDocument{endfloat,xyzzy,lastpage}|
% \end{quote}
% and the order of End Document material would be the \pkg{endfloat}
% material, followed by \textsf{xyzzy}, and finally by \pkg{lastpage}.
% The package \pkg{xyzzy} is fictitious, while the
% package \pkg{lastpage}\cite{Goldberg:lastpage} exists,
% it doesn't really matter what these do.
% 
% I will have to wait until someone else develops such a system, but
% I will gladly modify the packages I am responsible for maintaining
% to comply with it.  Until then
% I will include a message
% which begins with \texttt{AED}
% in every usage of |\At|\x|End|\x|Document|, and try to minimize any side
% effects my usage may have.
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
%
% \subsection{What are packages for?} \label{sec:monoton}
% 
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
%
% One option is to not have packages like \pkg{endfloat} actually call
% |\At|\x|End|\x|Document|, but merely define a user level command which
% would make the call itself.  This way, the order of those particular
% commands would matter, but not the ordering of the package loading.
%
% Another advantage of this is that packages could easily be things
% which make commands available, but do not actually entail
% a change in \texttt{.dvi} output themselves.  It is classes,
% and options to classes which do that.  That is, the actual
% loading of packages should have no visible effects, other than
% making new commands available.  (Typeface changing
% packages, such as \textsf{times}, are obvious, and principled, exceptions.)
% The disadvantage is that it leads
% to two-step modifications (loading and calling) to change
% a document.
%
% I would propose any package (other than typeface changing
% packages) which changes output instead of merely providing additional
% commands, should be clearly labeled as doing such in the documentation
% and in a message.
% 
% \subsection{Float position specifiers} \label{sec:gobble}
%
% Float position specifiers are passed to the temporary files
% and are used when those floats are processed.  This may lead
% to funny results, especially if the first figure or first table uses
% |[p]| while the |heads| option is being used.  This can lead to
% that float, floating to the page after the header.
% Most other float specifiers will not lead to any problems, because
% the package mucks about the various float specification parameters.
%
% \subsection{Misplaced headers} \label{sec:buggyheads}
%
% Version 2.2c contains a partial fix to a problem with the placement
% of floats around the section headers produced by the |heads| option.
% There were two variants of the problem.  In one the first float
% after the header would float above the header.  This has been fixed
% by using the \LaTeXe\ command |\suppressfloats|.  The other
% problem is that that the first float may float to a page float
% after the page with the header on it.
%
% This has been partially fixed, but
% if users use the |[p]| specification on their first floats or if
% there are large floats, the problem can still
% show up.  It is recommended that whenever the user wants a |[p]| that
% an |[hp]| be used instead.  In normal running (without \pkg{endfloat}),
% this should only rarely effect the document, but it will help avoid
% the problem with the floating end float.  An |[h]| may also be needed for
% large floats.  There is only need to be concerned about the first
% figure and first table.
%
% The natural solution to this problem will require that the bug
% in described in \autoref{sec:gobble} be resolved.
%
% \subsection{Known incompatibilities}
%
% Above I have outlined sources of potential conflicts and incompatibilities
% with other packages.  Those sections contain a discussion of potential
% work-arounds.  Here I list where I know of specific incompatibilities
% with distributed packages.  This list is not complete.  If you know
% on an addition, please let me know.
%
% \subsubsection{Environment names}
%
% The packages listed here all have the problem described in
% \autoref{sec:envnames}.  The work-arounds are also described
% there.  \pkg{rotating}, \emph{Scientific Word}.
%
% \subsubsection{Ordering end material}
%
% The following packages put things at the end of the document, and
% peculiar results are possible if you don't pay attention to the
% order in which packages are loaded.  This is described in
% \autoref{sec:order}.  The package \pkg{lastpage} is among
% these, as are recent versions of the package \pkg{harvard}.
%
% \subsubsection{Conflicting \cs{enddocument}}
%
% Prior to \LaTeXe's provision of the hook |\AtEndDocument|, package
% writers were forced to redefine |\enddocument|.  Some did so
% in ways that over wrote any other package's redefinition of the
% same.  When you encounter such a package you should try to get
% its author to release a modified version.  Version~2.0 of \pkg{endfloat}
% was such a packages.   So was the winter 1993 version of~\pkg{harvard}
% (which has been fixed).  But
% for those using an old version of \pkg{harvard} you will encounter
% problems.
%
% \subsubsection{Miscellaneous}
%
% There are several other potential conflicts that don't fall into
% the broader categories.
%
% \begin{itemize}
% \item |\listoftables| and |\listoffigurers| are left undefined
%     in class \cls{elsart}.  But this is because Elsevier does
%     not want those lists.  Elsevier, bless them, does not want
%     floats at the end for submissions to its journals.  So
%     there is no reason to use \pkg{endfloat} (with or without lists)
%     with class \cls{elsart}.  Let's hope that other publishers
%     will follow Elsevier's lead in understanding that the
%     submission rules which were created were created for a reason,
%     and when those reasons no longer apply, the rules should be changed.
%
%     I look forward to the day when \pkg{endfloat} will serve
%     no purpose.
%
% \item The \pkg{float} package appears to work in my limited tests.
% \iffalse % commented out by Axel Sommerfeldt
%     Although, only tables and figures get moved to end.
%     The success is due to the robustness with which \pkg{float}
%     is written.
% \fi
%
% \item The \pkg{floatrow} package appears to work in my limited tests.
% But please note that the \pkg{endfloat} package needs to be loaded
% \emph{after} the \pkg{floatrow} package.
%
% \item The \pkg{newfloat} package appears to work in my limited tests, too.
%
% \end{itemize}
%
% \section{Support}\label{sec:support}
%
% As is usual, this package is provided with no warranty whatsoever.
% However, it is my desire to make it useful and usable, although
% I may very well fail at that.  If you
% need a feature added, see whether the hooks will allow you to
% do what you want.  If something goes wrong look over
% \autoref{sec:caveats}.  But if you need to get in touch
% with the maintainer, you should send email at
% \texttt{axel.sommerfeldt@f-m.fm}.
%
% \section{History}\label{sec:history}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.1}{1994/06/25}{Use AtEndDocument. jpg}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
%
% \subsection{The burden of history}
%
% By version 2.2 the file was getting so that most of the bytes
% were things that had been commented out of previous versions,
% and changelog messages.  Instead of this making things clearer
% to the maintainer, it turns out to be clutter.  I (jpg) have started
% to throw out some of history (it is not really useful to see
% who corrected what typo or cleaned up what extraneous space
% with a |%| in 1991.  Although my purge of history is far
% from complete, it should be noted that I do want to preserve
% the spirit of the history.  I have already been miscredited
% with original authorship.  I have made extensive modifications
% and extensions, but the basic core (even if only a small amount
% of version 2.0 code remains) and concept are JDM's.
%
% \subsection{Author}
% The file was written by Darrell McCauley (jdm5548@diamond.tamu.edu)
% in February and March 1992.   He acknowledges that much of the
% guts are adapted from
% \texttt{comment.sty} by Victor Eijkhout (eijkhout@csrd.uiuc.edu).
% So, although Jeff
% Goldberg (jeffrey@goldmark.org) now maintains this, he should not
% be credited with writing the package, but only with extending and
% maintaining it.  He has contributed enough so that by version~2.4
% he claimed co-authorship.
% 
% \subsection{Version 2.6}
%
% Version 2.6 was build by Axel Sommerfeldt (axel.sommerfeldt@f-m.fm),
% and introduces the following changes:
% \begin{itemize}
% \item
% New package options |no|\x|tables| and |no|\x|figures| have been added
% to allow better control over which floating environments
% will be handled by the \pkg{endfloat} package.
% \item
% New macros called |\efloat|\x|type|, |\efloat|\x|heading|, |\efloat|\x|preamble|,
% and |efloat|\x|postamble| have been added which allow the user more control
% over how the delayed floats are typeset.
% \item
% A percent sign (|%|) is now allowed at the end of |\end|\marg{environment}, too, e.g.:
% \begin{quote}
%   |\begin{figure}|\\
%   |  |\ldots\\
%   |\end{figure}%|
% \end{quote}
% \item
% Two bugs have been fixed regarding the usage of UTF-8 characters in floating environments.
% \end{itemize}
%
% \subsection{Version 2.5}
%
% Version 2.5 was build by Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
% with permission of Jeff Goldberg, and introduces the following changes:
% \begin{itemize}
% \item
% New commands
% |\Declare|\x|Delayed|\x|Float| and |\Declare|\x|Delayed|\x|Float|\x|Flavor|
% for handling floating environments other than |figure| and |table|,
% and |\Setup|\x|Delayed|\x|Float| for setting options.
% To make this possible a lot of internal code had to be reorganized,
% but by trying to keep original versions of macros and trying to leave the
% operational sequence itself as original as possible this hopefully won't break
% compatibility with existing documents or extensions written for the
% \pkg{endfloat} package.
%
% \item
% New package options |tables|\x|only| and |figures|\x|only| have been added
% to allow better control over which floating environments
% will be handled by the \pkg{endfloat} package.
%
% \item
% The \pkg{endfloat} package should cooperate with
% the \pkg{floatrow} package now, at least if you load it \emph{after}
% the \pkg{floatrow} package.
%
% \item
% Older versions of the \pkg{endfloat} package used to process |figure| and
% |table| as starred variant always, but at least version $2.4$ did not.
% It had stored all of them as starred variant into the temporary files, but had
% processed them as non-starred always.
% To make this more consistent the version $2.5$ does store the environments
% as they are now, and processes them the same way, i.e.~non-starred
% variants will be stored and processed as non-starred, and starred variants
% will be stored and processed as starred.
% \end{itemize}
% If you notice a change in behaviour after updating the \pkg{endfloat}
% package to version 2.5, please contact me (Axel) and I'll try to fix this.
%
% \subsection{Version 2.4}
%
% Version 2.4 involves the largest set of additional features
% since at least version 2.2 (which added all the options).  Some
% of these are
% \begin{itemize}
%
% \item
% This version adds various user hooks, both as commands:
% |\At|\x|Begin|\x|Figures|, |\At|\x|Begin|\x|Tables|, and
% |\At|\x|Begin|\x|Delayed|\x|Floats| (\autoref{sec:hooks}),
% and |\efloat|\x|separator| (\autoref{sec:separator}).
%
% \item
% Most importantly, there is the addition of a configuration file
% (\autoref{sec:extra}).  An example configuration file contains
% code which allows \pkg{endfloat} to work properly with
% the \texttt{sidewaystable} environment of the \pkg{rotating}
% package.
%
% \item
% Additionally, all figures and tables are written as |figure*| and
% |table*| in the temporary files, eliminating the need to force single
% column mode when table and figures are processed.
%
% \item
% There are a fair number of internal changes to the code (which
% make it easier for the various hooks to work).
%
% \item
% Also changed some internal command names, such as |\xtable|,
% which did not include |@| to names that to include |@| such as
% |\ef@extable|.  Also renamed all commands |\end...| to something
% else so as to not use up valuable environment name space.
%
% \item
% Removed dead code.  It was making this too hard to read.
%
% \item
% Documentation changes to reflect user level changes.  Also added
% more to the Caveats section (\autoref{sec:caveats}).
% 
% \end{itemize}
%
% During the past few months I have received a wonderful level
% of feedback from users.   Many made very useful suggestions.
% Even those queries which resulted from a misunderstanding of
% how to use the package have been lead me to modify the
% documentation.  I had intended to acknowledge all of you,
% but the list has grown too long.  You know who you are.  Thanks,
% and good luck with your journal submissions!
%
% \subsection{Version 2.3}
% 
% Very minor changes in the organization of some parts of the
% code, but I fixed a bug I introduced while ``cleaning up'' for
% for version~2.2:  I had misunderstood part of the original
% code and commented out a necessary trick to allow for |figure*|
% The bug was very real, so I am releasing this version~2.3 as soon
% as I can document it, and am not waiting to include other planned
% improvements.
%
% \subsection{Version 2.2}
%
% A user (Kate Hedstrom) pointed out a number of bugs and shortcomings,
% which led me (jpg) to finally sit down and make some of the changes
% I had been planning on making.  The effect of the |tablesfirst| option
% was specifically requested, and also work on the bug discussed
% in \autoref{sec:buggyheads}.  Although my bug fix is partial,
% version 2.2 includes the means to suppress the headers altogether.
%
% \subsubsection{Package options}
%
% I, jpg, have used the package option facility of \LaTeXe\
% to get other options (described in \autoref{sec:options}).
% I also made some cosmetic changes (breaking up lines to reduce
% the number of overfull boxes when printing the documentation,
% line breaks and indentation to make the code more readable.
% I also replaced some |\def|s with |\newcommand|s and
% |\providecommand|s.  This are not logged, because I actually
% found that all of the logging information was hampering my
% ability to read and modify the code.
%
% \subsubsection{Internal commands}
%
% In version 2.2, I also replaced some code internal
% to |\xfigure| and |\xtable| with |\efloat@foundendfig|
% and |\efloat@foundendtab|.  This was merely a stylistic
% change.
%
% I also deleted some some definitions
% which are not used.  These had had probably been left as hooks, but with
% not enough for them to be useful hooks.  There are some cases where
% I have left these in when I could see what they could be used for.
% I have tried to add a note as to their potential use.
%
% \subsubsection{Documentation}
%
% Massive changes to user documentation, and some to the code
% documentation.
%
% \subsection{Version 2.1}
%
% I, Jeffrey Goldberg, in June 1994 wanted to use Darrell McCauley's
% \file{endfloat.sty} with \LaTeXe.  It worked fine until I
% needed to use the \LaTeXe\ directive |\At|\x|End|\x|Document| for
% some other function, and discovered that it was not functioning
% and that it was because version 2.0 (and earlier) of
% \texttt{endnotes.sty} redefined |\end|\x|document|.   The
% fix that I needed was trivial, but it made the file no
% longer compatible with \LaTeX209.  As a consequence, it seemed
% that the only way I could make up for this crime was to make
% it fully compatible with \LaTeXe.
%
% \subsection{Minor changes (version 2.0)}
%
% A series of changes and fixes were made in March 1992.  Many
% by the original author others by  Ronald Kappert (R.Kappert@urc.kun.nl)
% who replaced literal strings with |\figurename|, and so on; and
% by schultz@unixg.ubc.ca who pointed out gobbling bug with
% |\nomarkersintext|.
%
% \subsection{Brian Junker's modifications (version 2.0)}
%
% Brian Junker (brian@stat.cmu.edu) made a number of fixes.
% Here are his change comments:
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
%
% \begin{enumerate}
%   \item Changed ``comment" to ``figure" and ``komment" to
%                      ``table" throughout, to avoid collisions with other
%                      style files' definitions of ``comment".  Also
%                      fixes |\begin{table}| ends with |\end{komment}|
%                      error generated by my (older) version of PC\TeX.
%
%   \item Fixed gobble of float position specifiers.
%         There are two ways to do this:
%         \begin{enumerate}
%         \item |\write\ifnextchar[{\gobbleuntilnext}{}|
%                      into every
%                      environment written to |\jobname.fff|, etc.;
%          \item save \LaTeX's old def's of |\figure| and |\table|
%                      and re-use them when processing fig's and tables.
%                      I chose the latter approach, for maximum
%                      consistency with \LaTeX, other style files, etc.
%          \end{enumerate}
%
%  \item Added def's of |\tablename| and |\figurename|,
%                      which my version of PC-\TeX\ seemed to need.
%                      [backward compatibility for earlier versions ---jdm]
%
%  \item Moved formatting of figure and table markers to
%                      |\figure|\x|place| and |\table|\x|place|.
%
%   \item Style change: in-text markers are now
%                      centered reminders like ``[Figure 4 about here.]".
%
%    \item Style change: added list of tables and
%                      figures to the table and figure sections.
%                      Change back to old format with |\nofiglist| and
%                      |\notablist|.
%
%    \item Changed default to |\markersintext|.
%
%     \item Fixed trivial typo in |\@openposttbls|
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \end{enumerate}
%  All changes marked |% bj| at end of line.
%  ---Brian Junker (brian@stat.cmu.edu)
%
% \section{Wish list}
%
% I doubt that I will really work on this wish list in the near future
% but in addition to solving the know bugs, there is one major sort of
% change that I (jpg) would like to see:
% \begin{itemize}
% \item
%    Updating the verbatim writing by using the tools in the
%    |verbatim| standard packages, and the |moreverb| package.
%    Since they provide more generalized an cleaner verbatim code
%    then this which dates back to the earliest days of \LaTeX.
% \iffalse % commented out by Axel Sommerfeldt
% \item
%    Integrate with the |float| package  which (among other things)
%    enables the user to define new floating environments. 
%    \pkg{endfloat} v2.2 only allows figures and tables to be placed at
%    the end, not all types of potential floats.  Nor does it allow
%    the user to specify which of the two types it does recognize
%    to be placed at the end.
% \fi
% \end{itemize}
%
% \begin{thebibliography}{1}
% 
% \bibitem{Goldberg:lastpage}
% Jeffrey Goldberg.
% \newblock The \texttt{lastpage} package.
% \newblock Electronic documentation
% 
% \bibitem{A-W:GMS94}
% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
% \newblock {\em The {\LaTeX} Companion}.
% \newblock Addison-Wesley, Reading, Massachusetts, 1994.
%  
% \bibitem{LT3:ClassGuide}
% The \LaTeX3 Project.
% \newblock \emph{\LaTeXe\ for class and package writers}
% \newblock (Preliminary draft) June 1994.
% \newblock Electronic Documentation
%
% \bibitem{Lingnau:float}
% Anselm Lingnau.
% \newblock An Improved Environment for Floats
% \newblock August 2001 (version~1.3)
% \newblock Electronic Documentation
%
% \bibitem{Lapko:floatrow}
% Olga Lapko.
% \newblock The floatrow package
% \newblock August 2009 (version~0.3)
% \newblock Electronic Documentation
%
% \bibitem{Sommerfeldt:newfloat}
% Axel Sommerfeldt.
% \newblock The newfloat package
% \newblock November 2011 (version~1.0)
% \newblock Electronic Documentation
%
% \bibitem{RahBar:rotating}
% Sebastian Rahtz and Leonor Barroca.
% \newblock A style option for rotated objects in \LaTeX{}
% \newblock April 1994. (version~2)
% \newblock Electronic Documentation
% \end{thebibliography}
%  
%\StopEventually{\PrintIndex\PrintChanges}
% \clearpage
%
% \section{The documentation driver file}
%
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% The next bit of code contains the documentation driver file for
% \TeX{}, i.e., the file that will produce the documentation you are
% currently reading. It will be extracted from this file by the
% \texttt{docstrip} program.
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\setlength\hfuzz{2pt}    % ignore small overfulls
%
\usepackage{ifpdf}
\ifpdf
  \usepackage{mathptmx,courier}
  \usepackage[scaled=0.90]{helvet}
\fi
%
\usepackage{hypdoc}
\ifpdf\usepackage{hypdestopt}\fi
\hypersetup{pdfkeywords={LaTeX, package, endfloat},pdfstartpage={},pdfstartview={}}
%
\CodelineIndex
\EnableCrossrefs
 %\DisableCrossrefs   % Say \DisableCrossrefs if index is ready
 %\RecordChanges      % Gather update information
 \OnlyDescription    % comment out for implementation details
\begin{document}
  \let\subsectionautorefname\sectionautorefname
  \let\subsubsectionautorefname\sectionautorefname
   \DocInput{endfloat.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
%
% \section{The implementation}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
%
% \subsection{File and package identification}
%
% We start by checking if this file was already loaded. If not we
% identify the current version.
% \changes{v2.1}{1994/06/25}{Use LaTeX2e package form. jpg}
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{endfloat}[\filedate\space\fileversion\space
               LaTeX2e package puts figures and tables at end (jdm)]
%    \end{macrocode}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e package form. jpg}
%
% \subsection{How it was written}
% [this subsection mostly based on jdm's original text.]
%
% Overview: redefine the figure and table environment following 
% the |comment| environment of
% \texttt{comment.sty} written by Victor Eijkhout
% \texttt{eijkhout@csrd.uiuc.edu}.
%
% Instead of processing what was between |\begin{...}| and |\end{...}|,
% every line is written to a file (|\jobname.fff| for figures, |\jobname.ttt|
% for tables).  Then, when you do an |\end{document}|, the figure section
% is processed, then the table section is processed.  The |tablesfirst|
% option changes this order.
%
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1}{1994/06/25}{Use AtEndDocument. jpg}
%
% After initial versions, I [jdm] received much help from Ronald Kappert
% and Brian Junker (see change log below). \emph{Thanks guys!}
%
% \subsection{Define warning message}
%
% Since I, JPG, am making the commands options, I want to warn users
% to use the options, since these commands should be discontinued
% in future versions.
%
% Since these commands are available now for over two decades,
% I, AS, think that it would be a bad idea removing them now.
% So I decided to drop the warning message introduced by JPG instead.
%
% \subsection{Flags}
%
% Put all of the newifs for the user options and flags here.
% Note that these are global flags only,
% the ones bound to a specific environment will be defined
% inside |\Declare|\x|Delayed|\x|Float| instead. 
%
% I (as) have added the definition of |\Setup|\x|Delayed|\x|Float|
% here in version 2.5.
%
%    \begin{macrocode}
\newif\if@domarkers
\newif\if@tablist                % bj
\newif\if@figlist                % bj
\newif\if@tabhead
\newif\if@fighead
\newif\if@tablesfirst
\newif\ifefloat@figures          % as
\newif\ifefloat@tables           % as
\newif\ifefloat@list             % as
\newif\ifefloat@head             % as
%    \end{macrocode}
%
% \begin{macro}{\efloat@syncobsoleteflags}
% The switches |\if@tablist|, |\if@figlist|, |\if@tabhead|, and |\if@fighead|
% are obsolete, but still needed by some old (and unmaintained) document classes
% and packages. So we still support them, and keep them in sync with the values
% actually used by the \pkg{endfloat} package.
% \changes{v2.5c}{2011/12/22}{This macro added. as}
%    \begin{macrocode}
\newcommand*\efloat@syncobsoleteflags{%
  \efloat@ifflag{tablelist}{\@tablisttrue}{\@tablistfalse}%
  \efloat@ifflag{figurelist}{\@figlisttrue}{\@figlistfalse}%
  \efloat@ifflag{tablehead}{\@tabheadtrue}{\@tabheadfalse}%
  \efloat@ifflag{figurehead}{\@figheadtrue}{\@figheadfalse}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Default values}
%
% Set default values of all of the (global) flags here.
%
%    \begin{macrocode}
\@domarkerstrue
\@tablisttrue
\@figlisttrue
\@tabheadfalse
\@figheadfalse
\@tablesfirstfalse
\efloat@figurestrue              % as
\efloat@tablestrue               % as
\efloat@listtrue                 % as
\efloat@headfalse                % as
%    \end{macrocode}
%
% \begin{macro}{\SetupDelayedFloat}
% \changes{v2.5}{2011/11/26}{This command added. as}
% \changes{v2.5c}{2011/12/22}{Usage of \cs{efloat@syncobsoleteflags} added. as}
% While global flags will be set using package options,
% environment specific flags will be set with |\Setup|\x|Delayed|\x|Float|.
%    \begin{macrocode}
\RequirePackage{keyval}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\SetupDelayedFloat[2]{%
  \def\efloat@type{#1}%
  \setkeys{endfloat}{#2}}
%    \end{macrocode}
%    \begin{macrocode}
\define@key{endfloat}{list}[true]{\efloat@setkey{list}{#1}}
\define@key{endfloat}{nolist}[]{\efloat@setkey{list}{false}}
\define@key{endfloat}{head}[true]{\efloat@setkey{head}{#1}}
\define@key{endfloat}{nohead}[]{\efloat@setkey{head}{false}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\efloat@setkey{%
  \@expandtwoargs\efloat@@setkey\efloat@type}
\newcommand*\efloat@@setkey[3]{%
  \@ifundefined{ef@ext@#1}%
    {\PackageError{endfloat}%
      {Unknown environment `#1'}%
      {Only environments known to the `endfloat' package are allowed here.}}%
    {\efloat@setflag{#1#2}{#3}%
     \efloat@syncobsoleteflags}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@ifflag}
% |\efloat@ifflag|\marg{flag}\marg{yes-code}\marg{no-code}
% tests if a flag has been set.
% \changes{v2.5a}{2011/12/04}{This macro added. as}
%    \begin{macrocode}
\newcommand*\efloat@ifflag[1]{%
  \@nameuse{ef@if@#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@setflag}
% |\efloat@setflag|\marg{flag}\marg{value}
% sets a flag to the given boolean value.
% \changes{v2.5a}{2011/12/04}{This macro added. as}
%    \begin{macrocode}
\newcommand*\efloat@setflag[2]{%
  \@nameuse{if#2}%
    \global\expandafter\let\csname ef@if@#1\endcsname\@firstoftwo
  \else
    \global\expandafter\let\csname ef@if@#1\endcsname\@secondoftwo
  \fi}%
%    \end{macrocode}
% \end{macro}
%
% \subsection{Other preliminaries}
%
% I (jpg) have been slowly working at making more and more of the
% code for processing tables and figures common, with the idea
% that once I have factored out all that is common with them
% I will be then be able to set up code for other floats,
% I have still a very long way to go, but common code created
% for version 2.3 is here.
%
% I (as) have added the definition of |\Declare|\x|Delayed|\x|Float|
% and |\Declare|\x|Delayed|\x|Float|\x|Flavor| here in version 2.5.
%
% \begin{macro}{\efloat@newwrite}
% attempt to reduce old |\@openpostfigs| and |\@openposttbls| to
% one command
% The first one calls |\newwrite| so, |\efloat@newwrite{ttt}|
% will have the effect of |\newwrite\efloat@postttt|.
%    \begin{macrocode}
\newcommand*\efloat@newwrite[1]{%
   \expandafter\newwrite\csname efloat@post#1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@openpost}
% |\efloat@openpost{ttt}| will be the same as
% \begin{quote}
%   |\immediate\openout\efloat@postttt=\jobname.ttt\relax|
% \end{quote}
% while also calling |\efloat@setflag{ttt}{true}| to set a flag
% (|@ef@tttopen|) in the case of |ttt|.
% \changes{v2.5a}{2011/12/04}{\cs{ef@setct} replaced by \cs{efloat@setflag}. as}
% \changes{v2.5c}{2011/12/22}{\cs{efloat@setflag} replaced by \cs{ef@setct}. as}
%    \begin{macrocode}
\newcommand*\efloat@openpost[1]{%
   \expandafter\immediate\expandafter\openout
      \csname efloat@post#1\endcsname =\jobname.#1\relax
   \ef@setct{#1}{1}%
   \message{(\jobname.#1)}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@closepost}
% Close the file for writing.  Set a flag saying so.
% \changes{v2.6}{2018/03/24}{This macro added. as}
%    \begin{macrocode}
\newcommand*\efloat@closepost[1]{%
   \expandafter\immediate\expandafter\closeout\csname efloat@post#1\endcsname
   \ef@setct{#1}{0}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ef@newct}
% \begin{macro}{\ef@setct}
% \begin{macro}{\ef@ifct}
% |\ef@newct{ttt}| will create a new counter called |\@ef@tttopen|
% and |\ef@setct{ttt}{1}| would set it to 1.\par
% To offer best compatibility to version $2.4$ we still use these counters
% although using |\efloat@setflag{tttopen}{1}| would be a better alternative.
% (Otherwise the \pkg{apa} document class would break.)
% \changes{v2.5c}{2011/12/22}{\cs{ef@ifct} added by as}
%    \begin{macrocode}
\newcommand*\ef@newct[1]{%
  \expandafter \newcount \csname @ef@#1open\endcsname}
\newcommand*\ef@setct[2]{%
  \expandafter\global\csname @ef@#1open\endcsname=#2\relax}
\newcommand*\ef@ifct[1]{%
  \expandafter\ifnum \csname @ef@#1open\endcsname>0 \relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\efloat@condopen}
% Conditionally open a file
% \changes{v2.5a}{2011/12/04}{\cs{ifnum} replaced by \cs{efloat@ifflag}. as}
%    \begin{macrocode}
\newcommand*\efloat@condopen[1]{%
   \ef@ifct{#1}{}{\efloat@openpost{#1}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@iwrite}
% Immediate write to one of these files.
% \changes{v2.6}{2018/03/18}{Bugfix: Uses \cs{protected@write} now. as}
%    \begin{macrocode}
\newcommand\efloat@iwrite[1]{%
   \immediate\expandafter\protected@write\csname efloat@post#1\endcsname{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloatheading}
% This macro changes the page headings.
% By default it is defined to use |\markboth| for this purpose,
% but you may redefine this command in the configuration file or preamble.
% \changes{v2.6}{2018/03/18}{This macro added. as}
%    \begin{macrocode}
\providecommand\efloatheading[1]{\markboth{\uppercase{#1}}{\uppercase{#1}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloatpreamble}
% |\efloat|\x|preamble| will be typeset in front of the delayed floating environments.
% By default it does nothing; if you want it to be something else,
% you may redefine this command in the configuration file or preamble.
% \changes{v2.6}{2018/03/24}{This macro added. as}
%    \begin{macrocode}
\providecommand\efloatpreamble{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloatseparator}
% A user suggested that in some cases we may not wish
% to force \pkg{endfloat} to put each float on a page by itself.
% By default that is what it does, by defining |\efloat|\x|separator|
% to be |\clear|\x|page|.  If you want it to be something else,
% you may redefine this command in the configuration file or preamble.
% \changes{v2.6}{2018/03/24}{Use \cs{providecommand} instead of \cs{newcommand} to define this macro. as}
%    \begin{macrocode}
\providecommand{\efloatseparator}{\clearpage}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloatpostamble}
% |\efloat|\x|postamble| will be typeset at the end of the delayed floating environments.
% By default that is what it does, by defining |\efloat|\x|postamble|
% to be |\efloat|\x|separator|.  If you want it to be something else,
% you may redefine this command in the configuration file or preamble.
% \changes{v2.6}{2018/03/24}{This macro added. as}
%    \begin{macrocode}
\providecommand\efloatpostamble{\efloatseparator}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ef@makeinnocent}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
%    \begin{macrocode}
\newcommand*{\ef@makeinnocent}[1]{\catcode`#1=12 }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\figurename}
% \begin{macro}{\tablename}
% Make sure that |\tablename| and |\figurename| are defined.
%    \begin{macrocode}
\providecommand{\figurename}{Figure}
\providecommand{\tablename}{Table}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\floatplace}
% Place marker.
% \changes{v1.0b}{1992/03/10}{adaptation for LaTeX 2.09 and
%                      international namegiving by Ronald Kappert
%                      R.Kappert@urc.kun.nl}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.5}{2011/11/26}{universalized by as}
%    \begin{macrocode}
\newcommand{\floatplace}[1]{%
   \begin{center} 
     [\csname #1name\endcsname~\csname thepost#1\endcsname\ about here.]
   \end{center}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareDelayedFloat}
% This one prepares the given environment for cooperation with the \pkg{endfloat}
% package, i.e.~|figure| resp.~|table|.
% \changes{v2.5}{2011/11/26}{This command added. as}
% \changes{v2.5a}{2011/12/04}{\cs{ef@newct} replaced by \cs{efloat@setflag}. as}
% \changes{v2.5b}{2011/12/05}{Starred variant added. as}
% \changes{v2.5c}{2011/12/22}{\cs{efloat@setflag} replaced by \cs{ef@newct}. as}
%    \begin{macrocode}
\newcommand*\DeclareDelayedFloat{%
  \@ifstar{\efloat@declare{*}}{\efloat@declare{}}}
\@onlypreamble\DeclareDelayedFloat
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\efloat@declare[2]{%
  \@testopt{\efloat@@declare{#1}{#2}}{ef#2}}
\@onlypreamble\efloat@declare
%    \end{macrocode}
%    \begin{macrocode}
\def\efloat@@declare#1#2[#3]#4{%
%    \end{macrocode}
% Counters
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
%    \begin{macrocode}
  \newcounter{post#2}%
%    \end{macrocode}
% Remember the file extension in |\ef@ext@|\meta{environment}.
%    \begin{macrocode}
  \edef\@tempa{#3}%
  \edef\@tempb{\@nameuse{ext@#2}}%
  \ifx\@tempa\@tempb
    \PackageError{endfloat}%
      {File extension `\@tempa' is already used by the List}%
      {Try using a different file extension here, e.g. `ef\expandafter\@gobbletwo\@tempa'.}%
  \else
    \expandafter\let\csname ef@ext@#2\endcsname\@tempa
  \fi
%    \end{macrocode}
% Code for opening the |\jobname.fff|
%    \begin{macrocode}
  \efloat@newwrite{#3}%
  \ef@newct{#3}%
%    \end{macrocode}
% Place marker
% (Note: The \pkg{float} package uses |\fname@|\textit{X} as float name,
% but we need |\|\textit{X}|name| in |\float|\x|place|.)
%    \begin{macrocode}
  \@ifundefined{#2name}{\@namedef{#2name}{\@nameuse{fname@#2}}}{}%
  \efloat@namedef{#2place}{\floatplace{#2}}%
%    \end{macrocode}
% Re-define float.
%    \begin{macrocode}
  \DeclareDelayedFloatFlavor#1{#2}{#2}%
%    \end{macrocode}
% Define the heading title. (Only relevant if option |fighead| is set.)
%    \begin{macrocode}
  \expandafter\providecommand\csname #2section\endcsname{#4}%
%    \end{macrocode}
%    \begin{macrocode}
%    \end{macrocode}
% Here we set-up the hooks for getting stuff into |\process...|
% commands easily.
%    \begin{macrocode}
  \efloat@namedef{process#2s@hook}{}%
  \edef\@tempb{\def\noexpand\@tempa{\@car#2\@nil}}%
  \uppercase\expandafter{\@tempb}%
  \edef\@tempb{%
    \noexpand\g@addto@macro\noexpand\@tempa{\@cdr#2\@nil}}%
  \@tempb
  \efloat@namedef{AtBegin\@tempa s}{%
    \expandafter\g@addto@macro\csname process#2s@hook\endcsname}%
  \expandafter\expandafter\expandafter\let\expandafter
    \csname AtBegin\@tempa es\expandafter\endcsname
    \csname AtBegin\@tempa s\endcsname
%    \end{macrocode}
%    \begin{macrocode}
  \efloat@namedef{process#2s}{\efloat@process{#3}{#2}}%
  \efloat@namedef{process#2es}{\@nameuse{process#2s}}%
%    \end{macrocode}
% Flags: Set default values of all of the flags here.
%    \begin{macrocode}
  \efloat@@setkey{#2}{list}{efloat@list}%
  \efloat@@setkey{#2}{head}{efloat@head}%
%    \end{macrocode}
% Finally add the environment to the list of delayed floats
%    \begin{macrocode}
  \@cons\efloat@list{{#2}}}
\@onlypreamble\efloat@@declare
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\efloat@list{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@namedef}
% Same as \cs{@namedef} from the \LaTeX\ kernal,
% but uses \cs{newcommand} instead of \cs{def}.
% \changes{v2.5c}{2011/12/23}{This macro added}
%    \begin{macrocode}
\newcommand*\efloat@namedef[1]{%
  \expandafter\newcommand\csname #1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareDelayedFloatFlavor}
% \begin{macro}{\DeclareDelayedFloatFlavour}
% This one redefines the given environment, i.e. |figure| resp. |table|.
% While the non-starred variant redefines both variants (non-starred and starred),
% the starred variant only redefines the environment as given.\par
% We do this |\At|\x|Begin|\x|Document| so we are (hopefully) redefining this
% environment as the very last package.
% (Otherwise \pkg{endfloat} would not work with \pkg{floatrow}.)
% \changes{v2.5b}{2011/12/05}{This command added. as}
%    \begin{macrocode}
\newcommand*\DeclareDelayedFloatFlavor{%
  \@ifstar{\efloat@declareflavor\@gobble}%
          {\efloat@declareflavor\@iden}}
\@onlypreamble\DeclareDelayedFloatFlavor
\let\DeclareDelayedFloatFlavour\DeclareDelayedFloatFlavor
\@onlypreamble\DeclareDelayedFloatFlavour
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\efloat@declareflavor[3]{%
  \@ifundefined{ef@ext@#3}%
    {\PackageError{endfloat}%
       {Unknown environment `#3'}%
       {Only environments known to the `endfloat' package are allowed here.}}%
    {\efloat@AtBeginDocument{%
       \efloat@@declareflavor{#2}{#3}%
       #1{\efloat@@declareflavor{#2*}{#3}}}}}
\@onlypreamble\efloat@declareflavor
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\efloat@@declareflavor[2]{%
  \def\@tempa{\@efloat{#2}{#1}}%
  \@ifundefined{efloat@#1@ORI}%
%    \end{macrocode}
% Save old definition of the environment.
%    \begin{macrocode}
    {\expandafter\expandafter\expandafter\let\expandafter
       \csname efloat@#1@ORI\expandafter\endcsname
       \csname #1\endcsname
%    \end{macrocode}
% Restore old definition of the environment at |\efloat@restore|\x|floats|.
%    \begin{macrocode}
     \expandafter\g@addto@macro\expandafter\efloat@restorefloats\expandafter{%
       \expandafter\let
         \csname #1\expandafter\endcsname
         \csname efloat@#1@ORI\endcsname}%
%    \end{macrocode}
% Re-define float.
%    \begin{macrocode}
     \expandafter\let\csname#1\endcsname\@tempa}%
%    \end{macrocode}
%    \begin{macrocode}
    {\expandafter\ifx\csname#1\endcsname\@tempa \else
       \PackageError{endfloat}%
         {The environment `#1' was already redefined}%
         {You can't use \noexpand\DeclareDelayedFloatFlavor twice for a given environment.}%
     \fi}}
\@onlypreamble\efloat@@declareflavor
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\efloat@AtBeginDocument}
% To be compatible to version $2.4$ we usually redefine |\figure| and |\table| immediately.
% But if the \pkg{floatrow} package is loaded we can't, so we have to use
% |\At|\x|Begin|\x|Document| here.
% (Note: |\efloat@At|\x|Begin|\x|Document| will be defined using |\provide|\x|command|
% so document classes and packages can pre-define it if needed.)
% \changes{v2.5c}{2011/12/22}{This command added. as}
% \changes{v2.5d}{2011/12/23}{Revised. as}
%    \begin{macrocode}
\@ifpackageloaded{floatrow}{%
  \PackageInfo{endfloat}{`floatrow' package detected, delaying redefinitions}
  \providecommand*\efloat@AtBeginDocument{\AtBeginDocument}
}{%
  \providecommand*\efloat@AtBeginDocument{\@iden}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@restorefloats}
% Restore the original definition of all environments (floats and flavors)
% known to the \pkg{endfloat} package.
% This macro will be filled with life by |\Declare|\x|Delayed|\x|Float|\x|Flavor|.
% \changes{v2.5}{2011/11/26}{This macro added by as}
%    \begin{macrocode}
\newcommand*\efloat@restorefloats{}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Options and (obsolete) Commands}
%
% \begin{macro}{\efloat@SetOption}
% Sets an option (via |\efloat@Setup|) for all environments known to
% the \pkg{endfloat} package.
% \changes{v2.5}{2011/11/26}{This macro added. as}
%    \begin{macrocode}
\newcommand*\efloat@SetOption[1]{%
  \def\@elt##1{\efloat@Setup{##1}{#1}}%
  \efloat@list
  \let\@elt\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@Setup}
% Within option code we can't use |\Setup|\x|Delayed|\x|Float| since
% |figure| and |table| are not declared as delayed floating environments yet.
% So we use |\efloat@Setup| instead which will simply collect the settings for
% execution at a later stage.
% \changes{v2.5a}{2011/12/03}{This macro added. as}
%    \begin{macrocode}
\newcommand\efloat@Setup[2]{%
  \g@addto@macro\efloat@ProcessOptions{%
    \SetupDelayedFloat{#1}{#2}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@ProcessOptions}
% Processes options setup with |\efloat@Setup|.
% \changes{v2.5a}{2011/12/03}{This macro added. as}
%    \begin{macrocode}
\newcommand\efloat@ProcessOptions{%
  \let\efloat@SetOption\@undefined
  \let\efloat@Setup\@undefined
  \let\efloat@ProcessOptions\@undefined}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\markersintext}
% \begin{macro}{\nomarkersintext}
% First set up flags and defaults.  First set for flagging
% whether markers appear in text.
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.2a}{1994/10/07}{Create new options}
%    \begin{macrocode}
\DeclareOption{nomarkers}{\@domarkersfalse}
\DeclareOption{markers}{\@domarkerstrue}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand{\markersintext}{\@domarkerstrue}
\newcommand{\nomarkersintext}{\@domarkersfalse}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dotablist}
% \begin{macro}{\notablist}
% Options for creating lists of Tables \ldots
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.5}{2011/11/26}{We use \cs{SetupDelayedFloat} now. as}
%    \begin{macrocode}
\newcommand{\dotablist}{%
  \SetupDelayedFloat{table}{list=true}}
\newcommand{\notablist}{%
  \SetupDelayedFloat{table}{list=false,head=true}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dofiglist}
% \begin{macro}{\nofiglist}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.5}{2011/11/26}{We use \cs{SetupDelayedFloat} now. as}
% \ldots and Figures
%    \begin{macrocode}
\newcommand{\dofiglist}{%
  \SetupDelayedFloat{figure}{list=true}}
\newcommand{\nofiglist}{%
  \SetupDelayedFloat{figure}{list=false,head=true}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% Now we make options |tablist| and |notablist| and |figlist| and
% |nofiglist|.  Note that options will be processed in order of
% the |\DeclareOption| commands in this file.  So by placing
% |list| after |nolist| we ensure that if both are specified, |list|
% is in effect.
%
% First two new options
%    \begin{macrocode}
\DeclareOption{nolists}{\efloat@listfalse \efloat@SetOption{list=false}}
\DeclareOption{lists}{\efloat@listtrue \efloat@SetOption{list=true}}
%    \end{macrocode}
% Now the more specific ones, which must come after the more
% general options to get the right interactions between semi-conflicting
% options.
%    \begin{macrocode}
\DeclareOption{notablist}{\efloat@Setup{table}{list=false}}
\DeclareOption{nofiglist}{\efloat@Setup{figure}{list=false}}
\DeclareOption{tablist}{\efloat@Setup{table}{list=true}}
\DeclareOption{figlist}{\efloat@Setup{figure}{list=true}}
%    \end{macrocode}
% 
% The \texttt{notablist} and \texttt{nofiglist} options still leave
% a section header at the beginning of the tables and figures.
%
% Note again the role that order plays, by placing |fighead| after
% |noheads| it ensures that |fighead| will be in effect if both
% are specified.
%    \begin{macrocode}
\DeclareOption{heads}{\efloat@headtrue \efloat@SetOption{head=true}}
\DeclareOption{noheads}{\efloat@headfalse \efloat@SetOption{head=false}}
%    \end{macrocode}
%    \begin{macrocode}
\DeclareOption{fighead}{\efloat@Setup{figure}{head=true}}
\DeclareOption{tabhead}{\efloat@Setup{table}{head=true}}
\DeclareOption{nofighead}{\efloat@Setup{figure}{head=false}}
\DeclareOption{notabhead}{\efloat@Setup{table}{head=false}}
%    \end{macrocode}
% Also need option for putting tables first
%    \begin{macrocode}
\DeclareOption{tablesfirst}{\@tablesfirsttrue}
\DeclareOption{figuresfirst}{\@tablesfirstfalse}
%    \end{macrocode}
% \changes{v2.5a}{2011/12/03}{Options `tablesonly' and `figuresonly' added. as}
%    \begin{macrocode}
\DeclareOption{tablesonly}{\efloat@figuresfalse \efloat@tablestrue}
\DeclareOption{figuresonly}{\efloat@figurestrue \efloat@tablesfalse}
%    \end{macrocode}
% \changes{v2.6}{2018/03/04}{Options `tables' and `figures' added. as}
%    \begin{macrocode}
\DeclareOption{notables}{\efloat@tablesfalse}
\DeclareOption{nofigures}{\efloat@figuresfalse}
%    \end{macrocode}
% Other option stuff
%    \begin{macrocode}
\DeclareOption*{%
   \PackageWarning{endfloat}{Unknown option `\CurrentOption'}}
%    \end{macrocode}
% Process (global) options
%    \begin{macrocode}
\ProcessOptions*
%    \end{macrocode}
% For compatibility reasons we still store the original code of `figure' and `table'
% to |\@bfig| and |\@btab| although we don't make use of it anymore.
%    \begin{macrocode}
\let\@bfig\figure             % bj
\let\@btab\table              % bj
%    \end{macrocode}
% Declare `figure' and `table' as delayed floating environment, if requested
%    \begin{macrocode}
\if@tablesfirst
  \ifefloat@tables
    \DeclareDelayedFloat{table}[ttt]{Tables}
  \fi
  \ifefloat@figures
    \DeclareDelayedFloat{figure}[fff]{Figures}
  \fi
\else
  \ifefloat@figures
    \DeclareDelayedFloat{figure}[fff]{Figures}
  \fi
  \ifefloat@tables
    \DeclareDelayedFloat{table}[ttt]{Tables}
  \fi
\fi
%    \end{macrocode}
% Process environment specific options
%    \begin{macrocode}
\efloat@ProcessOptions
%    \end{macrocode}
%
% \begin{macro}{\thepostfig}
% \begin{macro}{\theposttbl}
% For compatibility reasons we still offer the old counters
% |postfig| and |posttbl|, so existing redefinitions of |\figure|\x|place|
% and |\table|\x|place| resp. existing extensions to the \pkg{endfloat} package
% will still work.
%    \begin{macrocode}
\let\c@postfig\c@postfigure
\let\c@posttbl\c@posttable
\newcommand\thepostfig{\thepostfigure}
\newcommand\theposttbl{\theposttable}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Parsing \texttt{figure} and \texttt{table}}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% 
% Now we get the utilities for parsing needed to
% get unmodified code into files.
%    \begin{macrocode}
\let\efloat@float\relax
%    \end{macrocode}
%
% \begin{macro}{\@efloat}
% the {blank space } appearing with |\nomarkersintext| was fixed by adding
% a percent sign (|%|) at strategic locations, determined by setting
% |\tracingcommands=1| ---Darrell
% 
% As mentioned by the jdm above, the following is based
% on \texttt{comment.sty}.  It appears that the idea is to
% turn off all control sequence processing and read in from
% input each line, until a line is found that looks like
% |\end{figure}|.  Thus the actual name of the environment
% is hardcoded into the use of the macros
% (see \autoref{sec:envnames}).  ---jpg]
%
% \changes{v1.1}{1992/03/13}{verified that floats were
%               used before a section was
%               created for them. jdm}
% \changes{v1.2}{1992/03/14}{corrected typo that may have caused figures not
%                      to be printed. jdm}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.0}{1992/06/02}{Corrected problem of extra blank spaces in
%                      the output when nomarkersintext was in effect
%                      (bug reported by schultz@unixg.ubc.ca).
%                      jdm}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
% \changes{v2.5}{2011/11/26}{universalized by as}
% \changes{v2.5b}{2011/12/05}{revised by as}
% \changes{v2.6}{2018/03/18}{Re-defines \cs{efloat@endtestX} and \cs{efloat@enddbltestX}, too. as}
% \changes{v2.6}{2018/03/24}{Writes \cs{efloatseparator} into the file, if necessary. as}
%    \begin{macrocode}
\newcommand*\@efloat[1]{%
  \expandafter\@@efloat\expandafter{\csname ef@ext@#1\endcsname}{#1}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\@@efloat[3]{%
%    \end{macrocode}
%    \begin{macrocode}
% If we have already done one table then the file we write to
% is already open, and there is nothing to do, else open it up.
%    \begin{macrocode}
  \efloat@condopen{#1}%
%    \end{macrocode}
% Write |\efloatseparator| into the file, if necessary.
%    \begin{macrocode}
  \@nameuse{efloat@separator@#1}%
%    \end{macrocode}
% Since the figures are not actually processed until much later, we don't
% use \LaTeX's figure numbering mechanism, but we use our own.   Also
% put marker in text (if option set).  In the future, I may combine
% the counter for the markers and the counter used as a flag for
% whether the file is open into one thing.
%    \begin{macrocode}
  \if@domarkers
    \stepcounter{post#2}% % bj
    \@nameuse{#2place}%   % bj
  \fi
%    \end{macrocode}
% |\@currenvir| (current environment) it set to fool
% latex into expecting the end of this environment
% to match the environment name.   It will be used more extensively
% when dealing with the problem discussed in \autoref{sec:envnames}.
%    \begin{macrocode}
  \def\@currenvir{efloat@float}%
%    \end{macrocode}
% Now we set up catcodes for reading in text without processing
% things.  But need to make |^^M| special since we want to read
% line by line.
%    \begin{macrocode}
  \begingroup
  \let\do\ef@makeinnocent \dospecials
  \ef@makeinnocent\^^L% and whatever other special cases
  \endlinechar`\^^M \catcode`\^^M=12 %
%    \end{macrocode}
% Patch |\efloat@endtest| so it contains the actual environment name.
%    \begin{macrocode}
  \efloat@patch\efloat@endtest{#3}% as
  \efloat@patch\efloat@enddbltest{#3}% as
  \efloat@patch\efloat@endtestX{#3}% as
  \efloat@patch\efloat@enddbltestX{#3}% as
%    \end{macrocode}
% We have read a |\begin{figure}| to get here.  We need to write that
% into the file. \par
% I (jpg) would add the |[htb]| parameters to what
% gets written, but that leaves any float specifiers that had
% been employed by the user wandering around in the floated material.
%    \begin{macrocode}
  \def\next{\efloat@xfloat{#1}}%
  \next\string\begin{#3}}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@foundend}
% When |\ef@xfigure| is verbatim-like reading the figure it has to
% do some clean-up after it as found the |\end{figure}| or
% |\end{figure*}|.  This is it.  [this part written by jpg v2.2]\par
% Note that this macro will not be used by the \pkg{endfloat} package
% itself anymore, but we'll leave it here so extensions written for the
% \pkg{endfloat} package which uses it will still work.
%    \begin{macrocode}
\newcommand*\efloat@foundend[2]{%
  \edef\efloat@enddbltest{\string\end{#2}}%
  \efloat@found@end{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@found@end}
% This is the new version of \cs{efloat@foundend}, actually used
% by this package.
% \changes{v2.5}{2011/11/26}{This variant of \cs{efloat@foundend} added by as}
% \changes{v2.6}{2018/03/24}{Writing \cs{efloatseparator} delayed until next \cs{@efloat}. as}
%    \begin{macrocode}
\newcommand*\efloat@found@end[1]{%
%    \end{macrocode}
% Write |\end{figure}| into the file, followed by |\efloatseparator|.
%    \begin{macrocode}
  \efloat@iwrite{#1}{\efloat@enddbltest}%
  \global\@namedef{efloat@separator@#1}{%
    \efloat@iwrite{#1}{\string\efloatseparator}%
    \efloat@iwrite{#1}{ }}%
%    \end{macrocode}
% Re-define |\next| so the current floating environment will be closed.
%    \begin{macrocode}
  \def\next{\endgroup\end{efloat@float}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@xfloat}
% |\efloat@xfloat| reads line by line, checking whether each line
% is the |\end{figure}|.  If it is, then write out end stuff
% to the file.  Otherwise write out read in line to the
% file and do the |\next| line.
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
% \changes{v2.5}{2011/11/26}{universalized by as}
% \changes{v2.5}{2011/11/26}{\cs{long} added. as}
% \changes{v2.5c}{2011/12/22}{renamed from \cs{ef@xfigure} to \cs{efloat@xfloat} by as}
% \changes{v2.6}{2018/03/18}{Actual test out-sourced to \cs{efloat@if@end}. as}
%    \begin{macrocode}
{\catcode`\^^M=12 \endlinechar=-1 %
 \long\gdef\efloat@xfloat#1#2^^M{%
  \efloat@if@end{#2}{\efloat@found@end{#1}}{\efloat@iwrite{#1}{#2}}%
  \next}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@if@end}
% |\efloat@if@end| tests if the given argument marks the end of the current floating environment.
% If yes, |\@firstoftwo| will be executed, |\secondoftwo| otherwise.
% \changes{v2.6}{2018/03/18}{This macro added. as}
% \changes{v2.6}{2018/03/18}{Tests \cs{efloat@endtestX} and \cs{efloat@enddbltestX}, too. as}
%    \begin{macrocode}
\newcommand\efloat@if@end[1]{%
  \def\test{#1}%
  \let\efloat@next\@firstoftwo
%    \end{macrocode}
% Test for |\end{figure}|
%    \begin{macrocode}
  \ifx\test\efloat@endtest
%    \end{macrocode}
% Test for |\end{figure*}|
%    \begin{macrocode}
  \else\ifx\test\efloat@enddbltest
%    \end{macrocode}
% Test for |\end{figure}%| and |\end{figure*}%|
%    \begin{macrocode}
  \else\ifx\test\efloat@endtestX
  \else\ifx\test\efloat@enddbltestX
%    \end{macrocode}
% Finally, if none of the above, we have a line of text in the
% body of the figure which should be written to the file.
%    \begin{macrocode}
  \else
    \let\efloat@next\@secondoftwo
  \fi\fi\fi\fi \efloat@next}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@endtest}
% \iffalse
% Generalizing these end\ldots{}test so that they
% can be used for user specified floating environments will
% require more |\expandafter|s then you can shake a stick at.
% I am not looking forward to taking on that task.  I should
% look at the version control package to see what I can
% lift from there, since it must be the same problem.
% \fi
% I (as) have generalized this end\ldots{}test so it can be
% used for user specific floating environments as well.
% I did this by simply replacing |figure| with |X|, this will be patched
% to the correct environment name in |\@efloat| by using |\efloat@patch|.
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.1b}{1994/07/03}{Modify documentation -jpg}
% \changes{v2.5}{2011/11/26}{`figure' replaced by 'X' and documentation modified. as}
% \changes{v2.6}{2018/03/18}{\cs{efloat@endtestX} and \cs{efloat@enddbltestX} are used for the test, too. as}
%    \begin{macrocode}
{\escapechar=-1%
 \catcode`\#=14 % hash mark is comment character
 \catcode`\%=12 # percent sign is other character
 \xdef\efloat@endtest{\string\\end\string\{X\string\}}
 \xdef\efloat@enddbltest{\string\\end\string\{X\string\}}
 \xdef\efloat@endtestX{\string\\end\string\{X\string\}%}
 \xdef\efloat@enddbltestX{\string\\end\string\{X\string\}%}
}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\efloat@patch[2]{%
    \def\x##1X##2\@nil{\def#1{##1#2##2}}%
    \expandafter\x#1\@nil}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ef@xfigure}
% \changes{v2.5c}{2011/12/22}{Revived by as}
% \begin{macro}{\ef@xtable}
% \changes{v2.5c}{2011/12/22}{Revived by as}
% \changes{v2.6}{2018/03/18}{Re-defines \cs{efloat@endtestX} and \cs{efloat@enddbltestX}, too. as}
% Both, |\ef@xfigure| and |\ef@xtable|, are gone with version $2.5$ of the \pkg{endfloat}
% package.
% But unfortunately some old and unmaintained document classes and packages still
% uses these internal macros, so we still provide them to stay compatible.
%    \begin{macrocode}
\newcommand*\ef@xfigure{\ef@xfloat{fff}{figure}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\ef@xtable{\ef@xfloat{ttt}{table}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\ef@xfloat[2]{%
  \efloat@patch\efloat@endtest{#2}%
  \efloat@patch\efloat@enddbltest{#2*}%
  \efloat@patch\efloat@endtestX{#2}%
  \efloat@patch\efloat@enddbltestX{#2*}%
%    \end{macrocode}
%    \begin{macrocode}
  \def\next{\efloat@xfloat{#1}}%
  \next}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Processing Figures and Tables}
%
% \begin{macro}{\AtBeginDelayedFloats}
% Here we set-up the hooks for getting stuff into |\process...|
% commands easily.  The command |\g@addto@macro| is defined
% in \file{classes.dtx}.  I was about to write it myself, when I realized that
% it must already exist for things like |\AtBeginDocument|.
%    \begin{macrocode}
\newcommand*\processdelayedfloats@hook{}
\def\AtBeginDelayedFloats{%
   \g@addto@macro\processdelayedfloats@hook}
\newcommand*\processotherdelayedfloats{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@process}
% |\efloat@process|\marg{file extension}\marg{environment name}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.1}{1994/06/25}{Use LaTeX2e documentation form. jpg}
% \changes{v2.5}{2011/11/26}{universalized by as}
% \changes{v2.5a}{2011/12/04}{\cs{ifnum} replaced by \cs{efloat@ifflag}. as}
% \changes{v2.5a}{2011/12/04}{\cs{ef@setct} replaced by \cs{efloat@setflag}. as}
% \changes{v2.5c}{2011/12/22}{\cs{efloat@setflag} replaced by \cs{ef@setct}. as}
% \changes{v2.6}{2018/03/18}{Bugfix: Usage of \cs{makeatletter}\ldots\cs{makeatother} added. as}
% \changes{v2.6}{2018/03/18}{Usage of \cs{markboth} replaced by \cs{efloatheading}. as}
% \changes{v2.6}{2018/03/24}{\cs{efloat@type} replaced by \cs{efloattype}. as}
% \changes{v2.6}{2018/03/24}{Usage of \cs{@input} replaced by \cs{efloat@input}. as}
% \changes{v2.6}{2018/03/24}{Usage of \cs{efloatpreamble} and \cs{efloatpostamble} added. as}
%    \begin{macrocode}
\newcommand*\efloat@process[2]{%
%    \end{macrocode}
% First test to see if there are any figures to process.
% If so do it.
%    \begin{macrocode}
  \ef@ifct{#1}{%
%    \end{macrocode}
% Close the file for writing.  Set a flag saying so.
%    \begin{macrocode}
    \efloat@closepost{#1}%
%    \end{macrocode}
% Define |\efloat|\x|type| which can be evaluated by user-defined variants of
% |\efloat|\x|heading|, |\efloat|\x|preamble|, |\efloat|\x|separator|, and |\efloat|\x|postamble|.
%    \begin{macrocode}
    \def\efloattype{#2}%                                      % as
%    \end{macrocode}
% Deal with headers and list of figures if necessary
%    \begin{macrocode}
    \clearpage                                                % bj
    \efloat@ifflag{#2list}{%                                  % bj
      {\normalsize\efloat@listof{#2}}%                        % bj
      \clearpage                                              % bj
    }{}%
    \efloat@ifflag{#2head}{%
      \section*{\@nameuse{#2section}}%                        % bj
%    \end{macrocode}
% See the discussion in \autoref{sec:place} for what problem
% the |suppressfloats[t]| is here to solve.  If I understand the
% \textit{Companion} correctly (page 144), this was not available
% in previous versions of \LaTeX.
%    \begin{macrocode}
      \suppressfloats[t]%                                     % jpg
    }{}%
    \expandafter\expandafter\expandafter\efloatheading        % bj
      \expandafter\csname #2section\endcsname                 % bj
%    \end{macrocode}
% Use any user defined hooks just before inputting the file.
%    \begin{macrocode}
    \processdelayedfloat@hook
    \@nameuse{process#2s@hook}%
%    \end{macrocode}
% Input the file, surrounded by |\efloatpreamble| and |\efloatpostamble|.
%    \begin{macrocode}
    \efloatpreamble
    \efloat@input{\jobname.#1}%
    \efloatpostamble
  }{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@input}
% Input the file, surrounded by |\makeatletter| and |\makeatother|
% so characters written as (internal) macros (for example UTF-8 characters)
% will be processed without errors.
% \changes{v2.6}{2018/03/18}{This macro added. as}
%    \begin{macrocode}
\newcommand*\efloat@input[1]{%
  \makeatletter
  \@input{#1}%
  \makeatother}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\processdelayedfloat@hook}
% For generic changes document classes can use the hook
% |\process|\x|delayed|\x|float@hook|. If the float type is needed,
% it can be extracted from |\efloattype|.
% \changes{v2.5d}{2011/12/25}{This hook added}
%    \begin{macrocode}
\newcommand*\processdelayedfloat@hook{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\efloat@listof}
% This one will do the ``List of Figures'' resp. ``List of Tables''.
% \changes{v2.5}{2011/11/26}{This macro added}
%    \begin{macrocode}
\newcommand*\efloat@listof[1]{%
%    \end{macrocode}
% If no name is given for the list we set it to ``List of \textit{X}'' where
% \textit{X} is the heading given as second mandatory argument
% to |\Declare|\x|Delayed|\x|Float|.
%    \begin{macrocode}
  \expandafter\providecommand\csname list#1name\endcsname
    {List of \@nameuse{#1section}}%
%    \end{macrocode}
% If |\listof|\textit{X}|s| is defined, we use it here.
% Otherwise we try using |\listof| (defined by the \pkg{float} and \pkg{floatrow}
% package) instead. If this will fail, too, we have to give up (and issue an error message).
%    \begin{macrocode}
  \@ifundefined{listof#1s}%
    {\@ifundefined{listof}%
      {\PackageError{endfloat}%
         {Don't know how to make List of `#1'}%
         {You could try defining \protect\listof#1s on your own}}%
      {\listof{#1}{\@nameuse{list#1name}}}}%
    {\@nameuse{listof#1s}}}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Getting float placement correct} \label{sec:place}
%
% In versions prior to this attempt (v2.2c), when the |heads| options
% were used, the float could could either float to the next page, leaving
% the section header alone, or could float to the top of the page, leaving
% section header at the bottom of the page.  The idea here is to change the
% parameters that place floats, to very very strongly
% encourage floats at the bottom of pages.
% It also allows for easy top floats.  Thus obviating the need
% for float pages.
% A |\suppressfloats[t]| in the commands
% that issue the headers will make sure that the floats don't float
% above the headers.
%
%    \begin{macrocode}
\renewcommand{\bottomfraction}{1.0}
\renewcommand{\topfraction}{1.0}
\renewcommand{\textfraction}{0.0}
%    \end{macrocode}
%
% \subsubsection{Calling the processing commands}
%
% \begin{macro}{\processdelayedfloats}
% Note that there is an extra set |{| and |}| so  that the
% restoration of the original definitions is in a group and is \emph{not}
% global.  If, for some reason, you wish them to be global then use
% something like
% \begin{quote}
%  |\makeatletter|\\
%  |\g@addto@macro\processdelayedfloats{\efloat@restorefloats}|\\
%  |\makeatother|
% \end{quote}
% \changes{v2.5}{2011/11/26}{Process float list instead of |figure| and |table|. as}
%    \begin{macrocode}
\newcommand{\processdelayedfloats}{{%
%    \end{macrocode}
% Here we reset stuff to apply while end stuff is being processed.
% Prior to version 2.4, these were in |\processtables| and |\processfigures|.
%    \begin{macrocode}
  \def\baselinestretch{1}\normalsize
  \efloat@restorefloats
%    \end{macrocode}
% The hook comes after those settings so as to override them if desired.
%    \begin{macrocode}
  \processdelayedfloats@hook
%    \end{macrocode}
% Process tables, figures, and others (or figures, tables, others)
%    \begin{macrocode}
  \efloat@processfloats
  \processotherdelayedfloats}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\efloat@processfloats{%
  \let\@tempa\@empty
  \def\@elt##1{\g@addto@macro\@tempa{\@nameuse{process##1es}}}%
  \efloat@list
  \let\@elt\relax
  \@tempa}
%    \end{macrocode}
% \changes{v1.99}{1992/05/27}{extensive changes by bj}
% \changes{v2.1}{1994/06/25}{Modify documentation text. jpg}
% \changes{v2.1}{1994/06/25}{Use AtEndDocument. jpg}
%    \begin{macrocode}
\AtEndDocument{%                                              % jpg
   \message{AED endfloat: Processing end Figures and Tables}% % jpg
   \onecolumn
   \processdelayedfloats }
%    \end{macrocode}
% \end{macro}
%
% Use, or don't use, configuration file.
%    \begin{macrocode}
\InputIfFileExists{endfloat.cfg}{%
   \typeout{*** Using endfloat.cfg ***}}{}
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \section{Extra macros -- HIGHLY Experimental} \label{sec:config}
%
% \subsection{Getting new delayed environments}
%
% \iffalse % changed by Axel Sommerfeldt
% I have been promising to make it easy to define new sorts
% of environments which can be delayed.  I don't expect to deliver
% on that promise any time soon; so until I do, I will provide a
% couple of useful extra macros in a configuration fill which
% the user may experiment with.  The two that I have needed are
% used in conjunction with the
% \textsf{rotating} package\cite{RahBar:rotating}, which
% among other things provides environments |sidewaystable| and
% |sidewaysfigure|.   With the following definitions, these should
% also work properly with \pkg{endfloat}.
% \else
% This section used to offer a configuration file which was able
% to integrate the environments |side|ways|figure| and |side|ways|table|
% offered by the \pkg{rotating} package\cite{RahBar:rotating}
% into the \pkg{endfloat} package.\par
% For compatibility reasons we still do, so existing documents
% including |efxmpl.cfg| will still work,~e.g.
% \begin{quote}
%   \ldots\\
%   |\usepackage{endfloat}|\\
%   |\makeatletter|\\
%   |\input{efxmpl.cfg}|\\
%   |\makeatother|\\
%   \ldots
% \end{quote}
% \fi
%
%    \begin{macrocode}
%<*config>
%    \end{macrocode}
%
% We must, of course, have use of the rotating package.
%    \begin{macrocode}
\RequirePackage{rotating}
%    \end{macrocode}
%
% We declare |side|\x|ways|\x|figure| and |side|\x|ways|\x|table| as
% variants of the |figure| resp.~|table| environments.
%    \begin{macrocode}
\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
\DeclareDelayedFloatFlavor{sidewaystable}{table}
%    \end{macrocode}
%
%    \begin{macrocode}
%</config>
%    \end{macrocode}
%
% \emph{Note:}
% If you would like to add support of given floating environments to
% the \pkg{endfloat} package, please do not use configuration files
% but |\Declare|\x|Delayed|\x|Float| and |\Declare|\x|Delayed|\x|Float|\x|Flavor|
% instead.
%
% \Finale
%
\endinput
