%%
%% This is file `lwarp-keyfloat.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lwarp.dtx  (with options: `keyfloat')
%% This is a generated file.
%% Copyright 2016-2020 Brian Dunn
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.


\LWR@ProvidesPackagePass{keyfloat}[2019/09/23]

\@ifpackagelater{keyfloat}{2019/09/23}{}{
    \PackageError{lwarp-keyfloat}
    {%
        The keyfloat package is out of date.\MessageBreak
        Update to keyfloat v2.01 2019/09/23 or later%
    }
    {%
        Please update the keyfloat package.  It's worth it!%
    }
}

\AtBeginDocument{
\providecommand*{\KFLT@LWR@hook@boxouter}{}
\renewcommand*{\KFLT@LWR@hook@boxouter}{%
    \ifbool{KFLT@keywrap}{%
    }{%
        \ifnumequal{\value{KFLT@keyfloatdepth}}{0}{%
            \setlength{\linewidth}{6in}%
            \setlength{\textwidth}{6in}%
            \setlength{\textheight}{9in}%
        }{}%
    }%
    \normalcolor%
}
\LetLtxMacro\KFLT@LWR@hook@keysubfloats\KFLT@LWR@hook@boxouter

\let\KFLT@LWR@hook@keyfloatsminipage\relax
\let\endKFLT@LWR@hook@keyfloatsminipage\relax
\newenvironment*{KFLT@LWR@hook@keyfloatsminipage}[1]{}{}
\LetLtxMacro\KFLT@LWR@hook@keyfloats\KFLT@LWR@hook@boxouter

\renewcommand*{\KFLT@maybeendfloatrow}{%
    \ifnumless{\value{KFLT@thiscol}}{\value{KFLT@numcols}}%
    {}% thiscol < numcols
    {% >=
        \defcounter{KFLT@thiscol}{0}%
    }%
}%

\renewcommand{\KFLT@trackrows}%
{%
    \ifboolexpr{%
        test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or%
        bool{KFLT@inkeysubfloats}%
    }%
    {% nested
        \KFLT@maybestartfloatrow%
        \ifnumgreater{\value{KFLT@thiscol}}{1}%
            {%
            }%
            {}%
    }% nested
    {}% not nested
}
\RenewDocumentCommand{\KFLT@onefigureimage}{m}
{%
\LWR@traceinfo{KFLT@onefigureimage}%
\ifthenelse{\NOT\equal{\KFLT@lw}{}}%
    {%
        \KFLT@frame{\includegraphics%
        [scale=\KFLT@s,width=\KFLT@imagewidth]{#1}}%
    }%
    {% not linewidth
        \ifthenelse{\dimtest{\KFLT@w}{>}{0pt}}%
        {% width is given
            \ifthenelse{\dimtest{\KFLT@h}{>}{0pt}}%
            {% w and h
                \KFLT@frame{\includegraphics%
                [scale=\KFLT@s,%
                width=\KFLT@imagewidth,height=\KFLT@h]{#1}}%
            }% w and h
            {% only w
                \KFLT@frame{\includegraphics%
                [scale=\KFLT@s,width=\KFLT@imagewidth]{#1}}%
            }% only w
        }% width is given
        {% width is not given
            \ifthenelse{\dimtest{\KFLT@h}{>}{0pt}}%
            {%
                \KFLT@frame{\includegraphics%
                [scale=\KFLT@s,height=\KFLT@h]{#1}}%
            }%
            {%
                \KFLT@frame{\includegraphics%
                [scale=\KFLT@s]{#1}}%
            }%
        }% width is not given
    }% not linewidth
\LWR@traceinfo{KFLT@onefigureimage: done}%
}
\RenewDocumentEnvironment{KFLT@boxinner}{}
{%
    \LWR@traceinfo{KFLT@boxinner}%
    \LWR@stoppars%
    \minipagefullwidth%
    \ifboolexpr{bool{KFLT@ft} or bool{KFLT@f}}{%
        \fminipage{\KFLT@imagewidth}%
    }{%
        \minipage{\KFLT@imagewidth}%
    }%
}
{%
    \ifboolexpr{bool{KFLT@ft} or bool{KFLT@f}}{%
        \endfminipage%
    }{%
        \endminipage%
    }%
    \LWR@startpars%
    \LWR@traceinfo{KFLT@boxinner: done}%
}

\newcommand*{\LWR@KFLT@settextalign}[1]{%
    \def\LWR@KFLT@textalign{justify}%
    \ifcsstring{KFLT@#1textalign}{\centering}%
        {\def\LWR@KFLT@textalign{center}}%
        {}%
    \ifcsstring{KFLT@#1textalign}{\raggedleft}%
        {\def\LWR@KFLT@textalign{right}}%
        {}%
    \ifcsstring{KFLT@#1textalign}{\raggedright}%
        {\def\LWR@KFLT@textalign{left}}%
        {}%
}

\renewcommand{\KFLT@addtext}[1]
{%
    \ifcsempty{KFLT@#1t}%
    {}% no text
    {% text to add
        {% local
        \addvspace{\smallskipamount}%
        \LWR@KFLT@settextalign{#1}%
        \begin{BlockClass}[text-align:\LWR@KFLT@textalign]{floatnotes}%
        \setlength{\parskip}{1.5ex}%
        \setlength{\parindent}{0em}%
        \csuse{KFLT@#1t}%
        \end{BlockClass}%
        }% local
    }% text to add
}

\@ifpackageloaded{tocdata}
{}
{% tocdata not loaded

    \newcommand*{\LWR@KFLT@setnamealign}[1]{%
        \def\LWR@KFLT@textalign{justify}%
        \ifstrequal{#1}{\centering}%
            {\def\LWR@KFLT@textalign{center}}%
            {}%
        \ifstrequal{#1}{\raggedleft}%
            {\def\LWR@KFLT@textalign{right}}%
            {}%
        \ifstrequal{#1}{\raggedright}%
            {\def\LWR@KFLT@textalign{left}}%
            {}%
    }

    \renewcommand*{\KFLT@@addartisttext}[3]{%
    %    \end{macrocode}
    % Add space and create the name inside a \element{div}:
    %    \begin{macrocode}
    %     \begin{minipage}{\linewidth}%
        \LWR@KFLT@setnamealign{#3}%
        \begin{BlockClass}[text-align:\LWR@KFLT@textalign]{floatnotes}%
    %    \end{macrocode}
    % Text alignment is |#3|, and depends on artist or author:
    %    \begin{macrocode}
    %     #3%
    %    \end{macrocode}
    % |#1| is empty or '|subgrp'| \\
    % |#2| is empty for artist, `|u|' for author:
    %    \begin{macrocode}
        \footnotesize\textsc{%
            \KFLT@optionalname{\csuse{KFLT@#1a#2p}}%
            \KFLT@optionalname{\csuse{KFLT@#1a#2f}}%
            \csuse{KFLT@#1a#2l}%
            \csuse{KFLT@#1a#2s}%
        }%
    %     \end{minipage}%
        \end{BlockClass}
    }

}% tocdata not loaded

\DeclareDocumentEnvironment{KFLT@marginfloat}{O{-1.2ex} m}
{%
    \uselengthunit{PT}%
    \LWR@BlockClassWP%
        {float:right; width:2in; margin:10pt}%
        {}%
        {marginblock}%
    \captionsetup{type=#2}%
    \minipage{\LWR@usersmarginparwidth}%
    \setlength{\marginparwidth}{.95\LWR@usersmarginparwidth}%
}
{%
    \endminipage%
    \endLWR@BlockClassWP%
}

\DeclareDocumentEnvironment{marginfigure}{o}
    {\begin{KFLT@marginfloat}{figure}}
    {\end{KFLT@marginfloat}}

\DeclareDocumentEnvironment{margintable}{o}
    {\begin{KFLT@marginfloat}{table}}
    {\end{KFLT@marginfloat}}

\DeclareDocumentEnvironment{keywrap}{m +m}
{%
    \begin{LWR@setvirtualpage}*
    \setlength{\LWR@templengthone}{#1}%
    \begin{LWR@BlockClassWP}%
        {%
            float:right; width:\LWR@printlength{\LWR@templengthone};  % extra space
            margin:10pt%
        }%
        {}%
        {marginblock}%
    \setlength{\linewidth}{.95\LWR@templengthone}%
    \booltrue{KFLT@keywrap}%
    #2%
    \end{LWR@BlockClassWP}%
    \end{LWR@setvirtualpage}%
}
{}
}% AtBeginDocument

\endinput
%%
%% End of file `lwarp-keyfloat.sty'.
