texlive[50534] Master/texmf-dist: keyfloat (22mar19)

commits+karl at tug.org commits+karl at tug.org
Fri Mar 22 21:49:29 CET 2019


Revision: 50534
          http://tug.org/svn/texlive?view=revision&revision=50534
Author:   karl
Date:     2019-03-22 21:49:29 +0100 (Fri, 22 Mar 2019)
Log Message:
-----------
keyfloat (22mar19)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/keyfloat/README.txt
    trunk/Master/texmf-dist/doc/latex/keyfloat/keyfloat.pdf
    trunk/Master/texmf-dist/source/latex/keyfloat/keyfloat.dtx
    trunk/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty

Modified: trunk/Master/texmf-dist/doc/latex/keyfloat/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/keyfloat/README.txt	2019-03-22 20:49:17 UTC (rev 50533)
+++ trunk/Master/texmf-dist/doc/latex/keyfloat/README.txt	2019-03-22 20:49:29 UTC (rev 50534)
@@ -1,7 +1,7 @@
 The LaTeX keyfloat package
 Provides a key/value interface for generating floats.
 
-v1.00 — 2019/01/11
+v2.00 — 2019/03/21
 Copyright 2016-2019 Brian Dunn — www.BDTechConcepts.com
 
 LaTeX Project Public License, version 1.3

Modified: trunk/Master/texmf-dist/doc/latex/keyfloat/keyfloat.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/keyfloat/keyfloat.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/keyfloat/keyfloat.dtx	2019-03-22 20:49:17 UTC (rev 50533)
+++ trunk/Master/texmf-dist/source/latex/keyfloat/keyfloat.dtx	2019-03-22 20:49:29 UTC (rev 50534)
@@ -17,7 +17,7 @@
 % \iffalse
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>\ProvidesPackage{keyfloat}
-%<package>    [2019/01/11 v1.00 Key/value interface for floats and subfloats.]
+%<package>    [2019/03/21 v2.00 Key/value interface for floats and subfloats.]
 %
 %<*driver>
 \documentclass{ltxdoc}
@@ -140,7 +140,8 @@
 \captionsetup*[table]{
 	style=default, justification=centering,
 	margin=0pt, parskip=0pt, skip=1ex,
-	labelfont={small,bf},textfont={small,bf}
+	labelfont={small,bf},textfont={small,bf},
+    position=top
 }
 
 \captionsetup*[subfigure]{
@@ -152,7 +153,8 @@
 \captionsetup*[subtable]{
 	style=default, justification=centering,
 	margin=0pt, parskip=0pt, skip=1ex,
-	labelfont={small},textfont={small}
+	labelfont={small},textfont={small},
+    position=top
 }
 
 \captionsetup*[example]{
@@ -203,6 +205,8 @@
 \usepackage[normalem]{ulem}
 
 
+\usepackage{tocdata}[2019/03/21]% v2.02 or later
+
 \usepackage{tocloft}
 \setlength{\cftsubsecnumwidth}{3em}
 \setlength{\cftsubsubsecindent}{2.8em}
@@ -211,10 +215,8 @@
 
 % \usepackage{titletoc}
 
-\usepackage{tocdata}[2016/12/02]% v0.12 or later
 
 
-
 \usepackage{titleps}
 
 \newpagestyle{pageheadfoot}{
@@ -313,7 +315,7 @@
 %<*package>
 % \fi
 %
-% \CheckSum{0}
+% \CheckSum{1174}
 %
 % \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
@@ -342,8 +344,11 @@
 % \changes{v0.15}{2017/05/12}{\ 2017/05/12}
 % \changes{v1.00}{2019/01/11}{\ 2019/01/11}
 % \changes{v1.00}{2019/01/08}{Source formatting improvements.}
-% \changes{v1.00}{2019/01/08}{PDF bookmark improvements.}
+% \changes{v1.00}{2019/01/08}{Docs \PDF\ bookmark improvements.}
 % \changes{v1.00}{2019/01/08}{Removed spurious spaces.}
+% \changes{v2.00}{2019/03/21}{\ 2019/03/21}
+% \changes{v2.00}{2019/03/17}{Added custom float types.}
+% \changes{v2.00}{2019/03/17}{Added float authors.}
 
 
 
@@ -413,15 +418,24 @@
 % two small figures placed vertically next to
 % one larger figure.
 %
+% \vfill
 %
-% \bigskip
-%
 % \noindent
 % As an example, a typical command to include a figure with a framed image of half \cs{linewidth}
 % could be: \\
 % \hspace*{1em}\verb|\keyfig*[hbp]{f,lw=.5,c={A caption},l={fig:label}}{image}|
-% \bigskip
 %
+% \vfill
+%
+% \noindent \pkg{keyfloat} uses the \pkg{caption}, \pkg{subcaption},
+% \pkg{newfloat}, and \pkg{wrapfig} packages,
+% \watchout
+% and cannot be used with the
+% \pkg{subfig}, \pkg{subfigure}, \pkg{subfloat}, \pkg{floatrow}, \pkg{float},
+% or \pkg{floatflt} packages.
+%
+% \vfill
+%
 % \footnotesize
 % \begin{description}
 % \item[License:] \
@@ -516,21 +530,24 @@
 % The macros and environments provided by \pkg{keyfloat} include:
 % \begin{description}
 % \item[\cs{keyfig}:] A figure with an image.
+% \item[\cs{keytab}:] A table.
+% \item[\cs{keyflt}:] An arbitrary float type macro.
 % \item[\cs{keyfigbox}:] A figure with arbitrary contents.
 % \item[\cs{keyparbox}:] A ``figure'' without a caption, useful
 %	to place uncaptioned text inside a group,
-% \item[\cs{keytab}:] A table.
-% \item[keyfigure:] A figure environment.
-% \item[keytable:] A table environment.
-% \item[keyfloats:] A group of rows and columns of floats.
-% \item[keysubfigs:] A figure containing a group of rows and columns of subfigures.
-% \item[keysubtabs:] A table containing a group of rows and columns of subtables.
-% \item[keywrap:] Wraps a keyfloat around an environment of text.  Usable inside a list.
-% \item[marginfigure:] A figure environment placed into
+% \item[\env{keyfigure}:] A figure environment.
+% \item[\env{keytable}:] A table environment.
+% \item[\env{keyfloat}:] An arbitrary float type environment.
+% \item[\env{keyfloats}:] A group of rows and columns of floats.
+% \item[\env{keysubfigs}:] A figure containing a group of rows and columns of subfigures.
+% \item[\env{keysubtabs}:] A table containing a group of rows and columns of subtables.
+% \item[\env{keysubfloats}:] A float of arbitrary type containing a group of rows and columns of subfloats.
+% \item[\env{keywrap}:] Wraps a keyfloat around an environment of text.  Usable inside a list.
+% \item[\env{marginfigure}:] A figure environment placed into
 %	the margin.\footnote{\env{marginfigure} and \env{margintable}: The environments
 %	provided by the |tufte-book| class are used if loaded,
 %	otherwise \pkg{keyfloat} provides its own versions.}
-% \item[margintable:] A table environment placed in the margin.
+% \item[\env{margintable}:] A table environment placed in the margin.
 % \end{description}
 %
 % Additional features include:
@@ -542,13 +559,13 @@
 % \item Dynamic layout: The number of columns is specified. Extra
 % 	floats are placed onto additional rows as needed, with the final row
 % 	adjusted to compensate for leftovers.
-% \item Floats may be placed [H]ere.
-% \item Floats may be placed in the [M]argin.
-% \item Floats may be placed with text [W]rapped around them.
+% \item Floats may be placed \optn{[H]}ere.
+% \item Floats may be placed in the \optn{[M]}argin.
+% \item Floats may be placed with text \optn{[W]}rapped around them.
 % \item Floats may be starred to span two columns.
 % \item Continued floats may be used to repeat the previous float number.
 % \item A figure may contain an image, with additional sizing, rotation, and a frame.
-% \item Tables may be stretched.
+% \item Tables may be stretched. (\cs{arraystretch})
 % \item Boxes of arbitrary contents may be assigned a width and framed.
 % \item Floats may be moved into and out of the grouping environments as needed.
 % \item An artist/author's name may be added to a figure and the index.
@@ -582,7 +599,7 @@
 %
 % \section{Using the \pkg{keyfloat} package}
 %
-% \subsection{Loading \pkg{keyfloat}}
+% \subsection{Loading \pkg{keyfloat} and related packages}
 %
 % \pkg{keyfloat} is loaded with the usual command:
 % \begin{sourcedisplay}
@@ -589,22 +606,65 @@
 % 	\cs{usepackage}\{keyfloat\}
 % \end{sourcedisplay}
 %
-% If you wish to have artist's names appear in the table of contents,
+%
+% If you wish to have artist's names appear in the list of figures,
+% \DescribePackage{tocdata}
+% \DescribePackage{tocloft}
+% \DescribePackage{titletoc}
 % as provided by the \pkg{tocdata} package,
-% load either \pkg{tocloft} or \pkg{titletoc},
-% followed by \pkg{tocdata}, then \pkg{keyfloat}:
+% load \pkg{tocdata},
+% optionally followed by either \pkg{tocloft} or \pkg{titletoc},
+% then \pkg{keyfloat}:
 % \begin{sourcedisplay}
-% 	\cs{usepackage}\{titletoc\}\% or titletoc \\
 % 	\cs{usepackage}\{tocdata\} \\
+%   \cs{usepackage}\{titletoc\}\% or titletoc, or neither \\
 % 	\cs{usepackage}\{keyfloat\}
 % \end{sourcedisplay}
-% 
-% 
+%
+% To use custom float types, use the \pkg{newfloat} package:
+% \DescribePackage{newfloat}
+% \begin{sourceverb}
+% \usepackage{newfloat}
+% \DeclareFloatingEnvironment[
+%     fileext={lod},
+%     listname={List of Diagrams},
+%     name={Diagram},
+% ]{diagram}
+% \end{sourceverb}
+%
+% For the \pkg{caption} package, to have table captions appear above the tables, and
+% \DescribePackage{caption}
+% to use custom float types:
+% \begin{sourceverb}
+% \usepackage[tableposition=top]{caption}
+% \captionsetup[diagram]{
+%     style=default, justification=centering,
+%     margin=0pt, parskip=0pt, skip=1ex,
+%     labelfont={small,bf},textfont={small,bf}
+% }
+% \end{sourceverb}
+%
+% To use custom float and subfloat types with \pkg{cleveref}:
+% \DescribePackage{cleveref}
+% \begin{sourceverb}
+% \usepackage{cleveref}
+% \crefname{diagram}{diagram}{diagrams}
+% \crefname{subdiagram}{subdiagram}{subdiagrams}
+% \end{sourceverb}
+%
+%
 % \subsection{Macros and environments}
 %
 % \DescribeMacro{\keyfig} * \oarg{loc} \marg{\keyvalsarg} \marg{image filename} \\
 % A macro to generate a figure with an image from a file.
 %
+% \DescribeMacro{\keytab} * \oarg{loc} \marg{\keyvalsarg} \marg{tabular contents} \\
+% A macro to generate a table with tabular contents.
+% Usually use the \env{keytable} environment instead.
+%
+% \DescribeMacro{\keyflt} * \oarg{loc} \marg{float type} \marg{keys/values} \marg{contents} \\
+% A macro to generate an arbitrary float type with its contents.
+%
 % \DescribeMacro{\keyfigbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents} \\
 % A macro to generate a figure with arbitrary paragraph contents.
 % See \cref{ex:keyfigbox}.
@@ -615,10 +675,6 @@
 % Mostly useful to add supplemental information inside a row of floats or subfloats.
 % See \cref{ex:keyparbox}.
 %
-% \DescribeMacro{\keytab} * \oarg{loc} \marg{\keyvalsarg} \marg{tabular contents} \\
-% A macro to generate a table with tabular contents.
-% Usually use the \env{keytable} environment instead.
-%
 % \DescribeEnv{keyfigure} * \oarg{loc} \marg{\keyvalsarg} \\
 % An environment to generate a figure with arbitrary contents.
 % Useful for multi-paragraph contents.
@@ -629,6 +685,10 @@
 % Useful for larger tables.
 % See \cref{ex:keytable}.
 %
+% \DescribeEnv{keyfloat} * \oarg{loc} \marg{float type} \marg{\keyvalsarg} \\
+% An environment to generate an arbitrary float type with its contents.
+% Useful for multi-paragraph contents.
+%
 % \begin{docsidebar}
 % \textbf{The above macros and environments may be used by themselves,
 % or inside the following \env{keyfloats}, \env{keysubfigs}, or
@@ -650,6 +710,10 @@
 % May not be nested.
 % See \cref{ex:keysubtabs}.
 %
+% \DescribeEnv{keysubfloats} * \oarg{loc} \marg{float type} \marg{numcols} \marg{keys} \\
+% A group of subfloats typeset in rows.
+% May not be nested.
+%
 % \DescribeEnv{keywrap} \marg{width of keyfloat} \marg{keyfloat} \\
 % Displays a keyfloat next to an environment of text.  Usable inside a list item,
 % where [W] will not work.  \meta{keyfloat} may be any of \cs{keyfig}, \env{keyfigure},
@@ -690,6 +754,7 @@
 % a paragraph with contents large enough to wrap around the float.  Do not use this
 % inside a list environment.  Select placement with the |wp| key; see
 % the \pkg{wrapfig} package documentation for more information.
+% Watch the log for warnings from \pkg{wrapfig}.\watchout[\pkg{wrapfig} warnings]
 %
 % \DescribeArgument{{[loc]}}
 % The star and [loc] options are ignored for floats inside a \env{keyfloats},
@@ -707,6 +772,7 @@
 % \newcommand{\largebullet}{{\Large\textbullet}}
 %
 % \begin{keytable}[bp]{c={Keys and values — part I},l={tab:keyvals},stretch=1.5}
+% \centering
 % \index{keys>and values}
 % \begin{threeparttable}
 % \small
@@ -722,10 +788,10 @@
 % cont & \largebullet &  Continued float?  & cont \\
 % l & \largebullet &  The label.  Enclose in braces if a comma is included.
 %	Ignored in unnumbered floats. & l=fig:A name  \\
-% ap & \largebullet & Artist's prefix, such as ``Mr.''\tnote{b} & ap=Mr. \\
-% af & \largebullet & Artist's first name.\tnote{b} & af=First \\
-% al & \largebullet & Artist's last name.\tnote{b} & al=Last \\
-% as & \largebullet & Artist's suffix, such as |~III|.\tnote{b} & |al=~III| \\
+% ap, aup & \largebullet & Artist/author's prefix, such as ``Mr.''\tnote{b} & ap=Mr. \\
+% af, auf & \largebullet & Artist/author's first name.\tnote{b} & af=First \\
+% al, aul & \largebullet & Artist/author's last name.\tnote{b} & al=Last \\
+% as, aus & \largebullet & Artist/author's suffix, such as |~III|.\tnote{b} & |al=~III| \\
 % t & \largebullet &  Additional text.  May include paragraphs. \\
 % 	Enclose in braces if a comma is included. 
 %	May need \cs{protect} before macro calls.
@@ -739,8 +805,10 @@
 % \begin{tablenotes}
 % \item[a:] All the keys in Part I may be used with the
 %	\env{keysubfigs} and \env{keysubtabs} environments.
-% \item[b:] Artist keys: Only used in Figure floats.
-%	A fixed-width non-breakable space is placed between names, except that
+% \item[b:] Artist \Slash author keys:
+%   |al| is an artist's last name, |aul| is an author's last name, etc.
+%   Artists names are printed centered, authors are flush right.
+%	A fixed-width non-breakable space is placed between parts of names, except that
 %	the optional suffix is connected directly to the last name, allowing
 %	``|as={, Title}|'', for example.
 % \end{tablenotes}
@@ -754,6 +822,7 @@
 
 % \begin{keytable}{
 %	c={Keys and values — part II},cont,stretch=1.5}
+% \centering
 % \index{keys>and values}
 % \begin{threeparttable}
 % \small
@@ -820,6 +889,7 @@
 %
 % \begin{keytable}{c={Caption-related key combinations},l=tab:captions,stretch=1.5}
 % \index{caption>options}
+% \centering
 % \begin{threeparttable}
 % \small
 % \begin{tabular}{ccccc}
@@ -854,12 +924,13 @@
 %
 % \begin{keytable}{c={Wrapped float placement options},l=tab:wrapplacement}
 % \index{float>wrapped placement}\index{wrapped float placement}
+% \centering
 % \begin{tabular}{ccl}
 % \toprule
 % \multicolumn{2}{c}{Key} & Location \\
 % \cmidrule(r){1-2}\cmidrule{3-3}
-% r & R & to the right of the text \\
-% l & L & to the left of the text \\
+% r & R & to the right of the text body \\
+% l & L & to the left of the text body \\
 % i & I & to the inside margin \\
 % o & O & to the outside margin \\
 % \bottomrule
@@ -966,6 +1037,9 @@
 % The \env{keytable} environment is preferred over the \cs{keytab} macro
 % since most tables are multi-line creations.
 %
+% \cs{keytab} centers the table, but \env{keytable} does not.
+% Add \cs{centering} if desired.
+%
 % \clearpage
 %
 % \begin{dtxexample}[\Cref{fig:options}]{Figure with many options selected}
@@ -1344,6 +1418,7 @@
 %	{Using \env{keytable}\texttt{[M]} and an offset\label{ex:keytablem}}
 % \begin{keytable}[M]{c={A \env{keytable}\texttt{[M]}},
 % 	l=tab:keytablem,mo=-.9in}
+% \centering
 % \testwidetable
 % \end{keytable}
 % \end{dtxexample}
@@ -1399,6 +1474,7 @@
 %
 % \begin{keytable}[W]{c={A \env{keytable}\texttt{[W]}},
 % 	l=tab:keytablew,w=2in,wp=L,tc=Placed \texttt{L} and 2in wide.}
+% \centering
 % \testwidetable
 % \end{keytable}
 % \lipsum[2]
@@ -1408,7 +1484,7 @@
 % \clearpage
 %
 % \begin{dtxexample}[\Cref{fig:keywrapfig}]
-%	{Using \cs{keywrap} with a \cs{keyfig}\label{ex:keywrapkeyfig}}
+%	{Using \env{keywrap} with a \cs{keyfig}\label{ex:keywrapkeyfig}}
 % \begin{itemize}
 % \item First item.
 %     Several lines of text text text text text
@@ -1542,13 +1618,13 @@
 %
 %
 % \begin{dtxexample}[\Cref{fig:artistpar}]{Artist's name — arbitrary contents}
-% \tdnameright
+% \tdartistright
 % \begin{keyfigure}{f,ap=Mr.,al=Last,
 %	c=Artist's name — arbitrary contents,l=fig:artistpar}
 % \centering Some text, a quotation, a TikZ\ diagram —
 % anything not an image file.
 % \end{keyfigure}
-% \tdnamecenter
+% \tdartistcenter
 % \end{dtxexample}
 %
 % The artist's name and optional prefix/suffix are printed below the figure,
@@ -1691,10 +1767,76 @@
 % \section{Code}
 %
 %
+% \subsection{Older packages}
 %
+% Ensure that \pkg{tocdata}, if loaded, is new enough:
+%    \begin{macrocode}
+\@ifpackageloaded{tocdata}{
+    \@ifpackagelater{tocdata}{2019/03/21}{}{
+        \PackageError{keyfloat}
+        {%
+            The tocdata package is out of date.\MessageBreak
+            Update to tocdata v2.02 2019/03/21 or later\MessageBreak
+            to use use this version of keyfloat%
+        }
+        {%
+            Please update the tocdata package.  It's worth it!%
+        }
+    }
+}{}
+%    \end{macrocode}
 %
+% \subsection{Prohibited packages}
 %
+% Prohibits the use of a certain other packages.
 %
+% \begin{macro}{\KFLT@@prohibitpackage} \marg{packagename}
+%    \begin{macrocode}
+\newcommand*{\KFLT@@prohibitpackage}[2]{%
+\@ifpackageloaded{#1}
+{
+    \PackageError{keyfloat}
+    {%
+        The keyfloat package conflicts with the #1\MessageBreak
+        package. Remove #1 to use keyfloat.\MessageBreak
+        Alternative(s):\MessageBreak
+        \space\space#2%
+    }
+    {%
+        Keyfloat uses the caption, subcaption, newfloat, and wrapfig packages.%
+    }
+}{}
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\KFLT at prohibitpackage} \marg{packagename}
+%
+% Prohibits the use of another package, both now and also \cs{AtBeginDocument}.
+%
+% \changes{v2.00}{2019/03/11}{Improved package conflict detection.}
+%    \begin{macrocode}
+\newcommand*{\KFLT at prohibitpackage}[2]{
+    \KFLT@@prohibitpackage{#1}{#2}
+    \AtBeginDocument{\KFLT@@prohibitpackage{#1}{#2}}
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% The list of prohibited packages:
+%    \begin{macrocode}
+\KFLT at prohibitpackage{floatrow}{caption and subcaption}
+\KFLT at prohibitpackage{subfig}{subcaption}
+\KFLT at prohibitpackage{subfigure}{subcaption}
+\KFLT at prohibitpackage{subfloat}{subcaption}
+\KFLT at prohibitpackage{float}{newfloat}
+\KFLT at prohibitpackage{floatflt}{wrapfig}
+%    \end{macrocode}
+%
+%
+%
 % \subsection{Required packages}
 % \changes{v1.00}{2019/01/08}{Removed \pkg{xifthen} dependency.}
 %
@@ -1740,29 +1882,10 @@
 \RequirePackage{wrapfig}
 %    \end{macrocode}
 %
-%
-% Package error if floatrow was loaded:
-%
-% \changes{v0.13}{2017/01/12}{Error if \pkg{floatrow} was loaded.}
-%
-%    \begin{macrocode}
-\@ifpackageloaded{floatrow}
-{
-\PackageError{keyfloat}
-{%
-    The keyfloat package conflicts with the floatrow package.
-    Remove floatrow to use keyfloat.%
-}
-{%
-    Keyfloat uses the caption and subcaption packages to 
-    provide similar functionality to floatrow.%
-}
-}
-{}
-%    \end{macrocode}
 
 
 
+
 % \DescribePackage{gettitlestring} Used by \pkg{hyperref} and \pkg{nameref}.
 %
 % \changes{v0.13}{2017/01/14}{Fix: Expands names in references.}
@@ -1893,13 +2016,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\KFLT at listtype} List type: ``|lof|'', ``|lot|''
-%    \begin{macrocode}
-\newcommand*{\KFLT at listtype}{}
-%    \end{macrocode}
-% \end{macro}
 %
-%
 % \DescribeKey[main]{l} Label
 %    \begin{macrocode}
 \define at key{KFLT at keys}{l}{\renewcommand{\KFLT at l}{#1}}
@@ -1959,10 +2076,54 @@
 % \end{macro}
 %
 %
+% \DescribeKey[main]{aup} Author prefix
+%    \begin{macrocode}
+\define at key{KFLT at keys}{aup}{\renewcommand{\KFLT at aup}{#1}}
+%    \end{macrocode}
 %
+% \begin{macro}{\KFLT at aup} Storage for author prefix
+%    \begin{macrocode}
+\newcommand*{\KFLT at aup}{}
+%    \end{macrocode}
+% \end{macro}
 %
+% \DescribeKey[main]{auf} Author first name
+%    \begin{macrocode}
+\define at key{KFLT at keys}{auf}{\renewcommand{\KFLT at auf}{#1}}
+%    \end{macrocode}
 %
+% \begin{macro}{\KFLT at auf} Storage for author first name
+%    \begin{macrocode}
+\newcommand*{\KFLT at auf}{}
+%    \end{macrocode}
+% \end{macro}
 %
+% \DescribeKey[main]{aul} Author last name
+%    \begin{macrocode}
+\define at key{KFLT at keys}{aul}{\renewcommand{\KFLT at aul}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at al} Storage for author last name
+%    \begin{macrocode}
+\newcommand*{\KFLT at aul}{}
+%    \end{macrocode}
+% \end{macro}
+%
+% \DescribeKey[main]{aus} Author suffix
+%    \begin{macrocode}
+\define at key{KFLT at keys}{aus}{\renewcommand{\KFLT at aus}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at aus} Storage for author suffix
+%    \begin{macrocode}
+\newcommand*{\KFLT at aus}{}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
+%
+%
 % \begin{macro}{\KFLT at textalign} Storage for text alignment.
 %
 % Used for the additional text in the float.
@@ -1982,15 +2143,24 @@
 %
 % Create replacement macros in case \pkg{tocdata} is not loaded:
 % \changes{v0.12}{2016/12/02}{Adapts to older version of tocdata.}
+% \changes{v2.00}{2019/03/20}{Adjustments for \pkg{tocdata} v2.00.}
 %    \begin{macrocode}
-\providecommand{\tdtextjustify}{}
-\providecommand{\tdtextcenter}{}
-\providecommand{\tdtextleft}{}
-\providecommand{\tdtextright}{}
-\providecommand{\tdnamejustify}{}
-\providecommand{\tdnamecenter}{}
-\providecommand{\tdnameleft}{}
-\providecommand{\tdnameright}{}
+\providecommand{\tdartisttextjustify}{}
+\providecommand{\tdartisttextcenter}{}
+\providecommand{\tdartisttextleft}{}
+\providecommand{\tdartisttextright}{}
+\providecommand{\tdauthortextjustify}{}
+\providecommand{\tdauthortextcenter}{}
+\providecommand{\tdauthortextleft}{}
+\providecommand{\tdauthortextright}{}
+\providecommand{\tdartistjustify}{}
+\providecommand{\tdartistcenter}{}
+\providecommand{\tdartistleft}{}
+\providecommand{\tdartistright}{}
+\providecommand{\tdauthorjustify}{}
+\providecommand{\tdauthorcenter}{}
+\providecommand{\tdauthorleft}{}
+\providecommand{\tdauthorright}{}
 %    \end{macrocode}
 %
 % \DescribeKey[main]{t} Additional text, justified alignment.
@@ -1998,7 +2168,6 @@
 \define at key{KFLT at keys}{t}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{}%
-    \tdtextjustify%
 }
 %    \end{macrocode}
 %
@@ -2007,7 +2176,6 @@
 \define at key{KFLT at keys}{tc}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{\centering}%
-    \tdtextcenter%
 }
 %    \end{macrocode}
 %
@@ -2016,7 +2184,6 @@
 \define at key{KFLT at keys}{tr}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{\raggedleft}%
-    \tdtextright%
 }
 %    \end{macrocode}
 %
@@ -2025,19 +2192,11 @@
 \define at key{KFLT at keys}{tl}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{\raggedright}%
-    \tdtextleft%
 }
 %    \end{macrocode}
 %
 %
 %
-% \begin{macro}{\KFLT at i} Image filename storage
-%    \begin{macrocode}
-\newcommand*{\KFLT at i}{}
-%    \end{macrocode}
-% \end{macro}
-%
-%
 % \DescribeKey[main]{lw} Fraction of \cs{linewidth}
 %    \begin{macrocode}
 \define at key{KFLT at keys}{lw}{%
@@ -2263,32 +2422,8 @@
 %    \end{macrocode}
 % \end{macro}
 
-% \begin{macro}{\KFLT at subgrptype} Subfloats collection list type storage:
-%	``|lof|'', ``|lot|''
-%    \begin{macrocode}
-\newcommand*{\KFLT at subgrplisttype}{}
-%    \end{macrocode}
-% \end{macro}
 
-% \begin{macro}{\KFLT at setsubgrpfigure} Set to figure type
-%    \begin{macrocode}
-\newcommand*{\KFLT at setsubgrpfigure}{%
-    \renewcommand{\KFLT at subgrptype}{figure}%
-    \renewcommand{\KFLT at subgrplisttype}{lof}%
-}
-%    \end{macrocode}
-% \end{macro}
-
-% \begin{macro}{\KFLT at setsubgrptable} Set to table type
-%    \begin{macrocode}
-\newcommand*{\KFLT at setsubgrptable}{%
-    \renewcommand{\KFLT at subgrptype}{table}%
-    \renewcommand{\KFLT at subgrplisttype}{lot}%
-}
-%    \end{macrocode}
-% \end{macro}
 %
-%
 % \DescribeKey[subfloat container]{l} Label
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{l}{\renewcommand{\KFLT at subgrpl}{#1}}
@@ -2319,7 +2454,6 @@
 \define at key{KFLT at subgrpkeys}{t}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{}%
-    \tdtextjustify%
 }
 %    \end{macrocode}
 %
@@ -2328,7 +2462,6 @@
 \define at key{KFLT at subgrpkeys}{tc}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{\centering}%
-    \tdtextcenter%
 }
 %    \end{macrocode}
 %
@@ -2337,7 +2470,6 @@
 \define at key{KFLT at subgrpkeys}{tl}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{\raggedright}%
-    \tdtextleft%
 }
 %    \end{macrocode}
 %
@@ -2346,7 +2478,6 @@
 \define at key{KFLT at subgrpkeys}{tr}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{\raggedleft}%
-    \tdtextright%
 }
 %    \end{macrocode}
 %
@@ -2398,6 +2529,49 @@
 %    \end{macrocode}
 % \end{macro}
 
+% \DescribeKey[subfloat container]{aup} Author prefix
+%    \begin{macrocode}
+\define at key{KFLT at subgrpkeys}{aup}{\renewcommand{\KFLT at subgrpaup}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at subgrpaup} Storage for author prefix
+%    \begin{macrocode}
+\newcommand*{\KFLT at subgrpaup}{}
+%    \end{macrocode}
+% \end{macro}
+%
+% \DescribeKey[subfloat container]{auf} Author first name
+%    \begin{macrocode}
+\define at key{KFLT at subgrpkeys}{auf}{\renewcommand{\KFLT at subgrpauf}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at subgrpauf} Storage for author first name
+%    \begin{macrocode}
+\newcommand*{\KFLT at subgrpauf}{}
+%    \end{macrocode}
+% \end{macro}
+%
+% \DescribeKey[subfloat container]{aul} Author last name
+%    \begin{macrocode}
+\define at key{KFLT at subgrpkeys}{aul}{\renewcommand{\KFLT at subgrpaul}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at subgrpaul} Storage for author last name
+%    \begin{macrocode}
+\newcommand*{\KFLT at subgrpaul}{}
+%    \end{macrocode}
+% \end{macro}
+%
+% \DescribeKey[subfloat container]{aus} Author suffix
+%    \begin{macrocode}
+\define at key{KFLT at subgrpkeys}{aus}{\renewcommand{\KFLT at subgrpaus}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at subgrpaus} Storage for author suffix
+%    \begin{macrocode}
+\newcommand*{\KFLT at subgrpaus}{}
+%    \end{macrocode}
+% \end{macro}
 
 
 % \subsection{Computing image width}
@@ -2439,8 +2613,8 @@
 % Use full \cs{linewidth} or only a fraction:
 %    \begin{macrocode}
             \ifcsempty{\KFLT at lw}%
-            {\setlength{\KFLT at imagewidth}{\KFLT at boxwidth}}%
-            {\setlength{\KFLT at imagewidth}{\KFLT at lw\KFLT at boxwidth}}%
+                {\setlength{\KFLT at imagewidth}{\KFLT at boxwidth}}%
+                {\setlength{\KFLT at imagewidth}{\KFLT at lw\KFLT at boxwidth}}%
         }% width not given
 }
 %    \end{macrocode}
@@ -2453,10 +2627,10 @@
 % A user-redefinable macro and length to tightly frame the contents.
 %
 % \cs{KFLTtightframe} may be redefined to a macro which frames its contents.
-% \cs{KFLTtightframewidth} should be redefine to the total width of the new
+% \cs{KFLTtightframewidth} should be redefined to the total width of the new
 % frame and its separation.
 %
-% \begin{macro}{\KFLT at tightframe} \marg{contents}
+% \begin{macro}{\KFLTtightframe} \marg{contents}
 %    \begin{macrocode}
 \newcommand{\KFLTtightframe}[1]{%
     \setlength{\fboxsep}{0pt}%
@@ -2467,7 +2641,8 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeLength{\KFLTtightframewidth} Combined width of the frame and separation.
+% \DescribeLength{\KFLTtightframewidth} Must be set to the combined width of
+%   the tight frame and separation used by \cs{KFLTtightframe}.
 %    \begin{macrocode}
 \newlength{\KFLTtightframewidth}
 \setlength{\KFLTtightframewidth}{.4pt}
@@ -2491,7 +2666,8 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeLength{\KFLTlooseframewidth} Combined width of the frame and separation.
+% \DescribeLength{\KFLTlooseframewidth} Must be set to the combined width of
+% the loose frame and separation used by \cs{KFLTlooseframe}.
 %    \begin{macrocode}
 \newlength{\KFLTlooseframewidth}
 \setlength{\KFLTlooseframewidth}{3.4pt}
@@ -2537,9 +2713,13 @@
 %
 % \subsection{A graphics image from a file}
 %
-% \begin{macro}{\KFLT at onefigureimage} Create a stand-alone figure with an image.
+% \begin{macro}{\KFLT at onefigureimage} \marg{filename}
+%
+% Create an image with size, frame, and turn.
+%
+% \changes{v2.00}{2019/03/12}{Filename in arg instead of \cs{KFLT at i}.}
 %    \begin{macrocode}
-\NewDocumentCommand{\KFLT at onefigureimage}{}
+\NewDocumentCommand{\KFLT at onefigureimage}{m}%
 {%
 %    \end{macrocode}
 % Several possible combinations of linewidth, width, and height are available,
@@ -2564,7 +2744,7 @@
             {% w and h
                 \includegraphics%
                 [scale=\KFLT at s,%
-                width=\KFLT at imagewidth,height=\KFLT at h]{\KFLT at i}%
+                width=\KFLT at imagewidth,height=\KFLT at h]{#1}%
             }% w and h
 %    \end{macrocode}
 % Only width:
@@ -2571,7 +2751,7 @@
 %    \begin{macrocode}
             {% only w
                 \includegraphics%
-                [scale=\KFLT at s,width=\KFLT at imagewidth]{\KFLT at i}%
+                [scale=\KFLT at s,width=\KFLT at imagewidth]{#1}%
             }% only w
         }% width is given
 %    \end{macrocode}
@@ -2582,15 +2762,15 @@
 %    \end{macrocode}
 % |h| was given:
 %    \begin{macrocode}
-                {\includegraphics[scale=\KFLT at s,height=\KFLT at h]{\KFLT at i}}%
+                {\includegraphics[scale=\KFLT at s,height=\KFLT at h]{#1}}%
 %    \end{macrocode}
 % If none were given, use the image's natural size:
 %    \begin{macrocode}
-                {\includegraphics[scale=\KFLT at s]{\KFLT at i}}%
+                {\includegraphics[scale=\KFLT at s]{#1}}%
         }% width is not given
     }% not linewidth
     {% linewidth given
-        \includegraphics[scale=\KFLT at s,width=\KFLT at imagewidth]{\KFLT at i}%
+        \includegraphics[scale=\KFLT at s,width=\KFLT at imagewidth]{#1}%
     }%
     \end{lrbox}%
     \unskip%
@@ -2609,24 +2789,6 @@
 % \subsection{Printing the caption}
 %
 %
-% \begin{macro}{\KFLT at captioniftype} \marg{|figure| or |table|} \marg{\mainsubarg}
-%
-% Create a caption only if is of this float type.
-%
-% The second argument is |{}| if a regular float, or
-% |subgrp| if \cs{keysubfigs} or \cs{keysubtabs}.
-%    \begin{macrocode}
-\newcommand*{\KFLT at captioniftype}[2]{%
-    \ifcsstring{KFLT@#2type}{#1}%
-        {\KFLT at caption{#2}}%
-        {}%
-}
-%    \end{macrocode}
-% \end{macro}
-
-
-
-
 % \begin{macro}{\KFLT at dosimplecaption} \marg{star?} \marg{short cap or |-NO VALUE-|} \marg{caption}
 %
 % Calls \cs{caption} depending on several combinations of star and short captions
@@ -2644,8 +2806,71 @@
 %
 %
 %
-% \begin{macro}{\KFLT at docaption} * \oarg{short caption} \marg{caption} \marg{\mainsubarg}
+% There are two versions of \cs{KFLT at docaption},
+% depending on whether \pkg{tocdata} is loaded.
 %
+%    \begin{macrocode}
+\@ifpackageloaded{tocdata}
+{% tocdata loaded
+%    \end{macrocode}
+%
+%
+% \begin{macro}{\KFLT@@docaption} {1: artist/author} \marg{2: empty or ''u''}
+%       \marg{3: star?}
+%       \marg{4: short caption} \marg{5: caption}
+%       \marg{6: \mainsubarg}
+% \changes{v2.00}{2019/03/19}{Factored.}
+%    \begin{macrocode}
+\newcommand*{\KFLT@@docaption}[6]{%
+%    \end{macrocode}
+% (\pkg{tocdata} does not expand its text argument before checking for empty.)
+%    \begin{macrocode}
+\addvspace{\smallskipamount}%
+\ifcsempty{KFLT@#6t}{%
+    \IfBooleanTF{#3}%
+    {%
+        \csuse{caption#1}*[#4]{#5}%
+            []%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }{%
+        \csuse{caption#1}[#4]{#5}%
+            []%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }%
+}{%
+    \ifcsstring{KFLT@#6textalign}{}{\csuse{td#1textjustify}}{}%
+    \ifcsstring{KFLT@#6textalign}{\centering}{\csuse{td#1textcenter}}{}%
+    \ifcsstring{KFLT@#6textalign}{\raggedleft}{\csuse{td#1textright}}{}%
+    \ifcsstring{KFLT@#6textalign}{\raggedright}{\csuse{td#1textleft}}{}%
+    \IfBooleanTF{#3}%
+    {%
+        \csuse{caption#1}*[#4]{#5}%
+            [\csuse{KFLT@#6t}]%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }{%
+        \csuse{caption#1}[#4]{#5}%
+            [\csuse{KFLT@#6t}]%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }%
+}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\KFLT at docaption} * \oarg{2:short caption} \marg{3:caption} \marg{4: \mainsubarg}
+%
 % Depending on whether the \pkg{tocdata} package is present,
 % and an artist is specified,
 % use either \cs{caption} or \cs{captionartist}.
@@ -2658,62 +2883,49 @@
 %
 % \changes{v0.14}{2017/02/09}{Fix: No index entry if no artist given.}
 %
-% There are two versions, depending on whether \pkg{tocdata} is loaded.
+% With \pkg{tocdata}:
+%
 %    \begin{macrocode}
-\@ifpackageloaded{tocdata}
-{% tocdata loaded
-%    \end{macrocode}
-% \pkg{tocdata} is loaded:
-%    \begin{macrocode}
 \NewDocumentCommand{\KFLT at docaption}{s o m m}
 {%
 %    \end{macrocode}
-% Is this a figure?
-%    \begin{macrocode}
-    \ifcsstring{KFLT@#4type}{figure}%
-    {% figure
-%    \end{macrocode}
 % Is the last name empty?  Assume no artist if so.
 %    \begin{macrocode}
-        \ifcsempty{KFLT@#4al}%
-        {% figure w/o artist
+    \ifcsempty{KFLT@#4al}%
+    {% figure w/o artist
+        \ifcsempty{KFLT@#4aul}%
+        {% figure w/o artist or author
 %    \end{macrocode}
-% A figure without an artist uses the simple caption.
+% A figure without an artist or author uses the simple caption.
 %    \begin{macrocode}
             \KFLT at dosimplecaption{#1}{#2}{#3}%
-        }% figure w/o artist
-        {% figure with an artist
+        }% figure w/o artist or author
 %    \end{macrocode}
-% A figure with an artist uses the \pkg{tocdata} \cs{captionartist} macro,
+% A figure with an author uses the \pkg{tocdata} \cs{captionauthor} macro,
 % which also creates an index entry.
 %    \begin{macrocode}
-            \IfBooleanTF{#1}{% star
-                \captionartist*[#2]{#3}%
-                    [\csname KFLT@#4t\endcsname]%
-                    [\csname KFLT@#4ap\endcsname]%
-                    {\csname KFLT@#4af\endcsname}%
-                    {\csname KFLT@#4al\endcsname}%
-                    [\csname KFLT@#4as\endcsname]%
-            }% star
-            {% no star
-                \captionartist[#2]{#3}%
-                    [\csname KFLT@#4t\endcsname]%
-                    [\csname KFLT@#4ap\endcsname]%
-                    {\csname KFLT@#4af\endcsname}%
-                    {\csname KFLT@#4al\endcsname}%
-                    [\csname KFLT@#4as\endcsname]%
-            }% no star
-        }% figure with an artist
-    }% figure
-    {% not a figure, ignore artist information:
+        {% figure w/ author
+            \KFLT@@docaption{author}{u}{#1}{#2}{#3}{#4}%
+        }% figure w/ author
+    }% figure w/o artist
+    {% figure with an artist
 %    \end{macrocode}
-% If it isn't a figure, ignore artist information and create a simple caption:
+% A figure with an artist uses the \pkg{tocdata} \cs{captionartist} macro,
+% which also creates an index entry.
 %    \begin{macrocode}
-        \KFLT at dosimplecaption{#1}{#2}{#3}%
-    }% not a figure
+        \KFLT@@docaption{artist}{}{#1}{#2}{#3}{#4}%
+    }% figure with an artist
 }% KFLT at tocdata
 }% tocdata loaded
 {% no tocdata
+%    \end{macrocode}
+% \end{macro}
+%
+% Without \pkg{tocdata}:
+%
+% \begin{macro}{\KFLT at docaption} * \oarg{2:short caption} \marg{3:caption} \marg{4: \mainsubarg}
+% \changes{v2.00}{2019/03/19}{Added support for authors.}
+%    \begin{macrocode}
 \NewDocumentCommand{\KFLT at docaption}{s o m m}
 {%
 %    \end{macrocode}
@@ -2724,11 +2936,19 @@
 % Create an index entry depending on whether there is a last, first name:
 %    \begin{macrocode}
     \ifcsempty{KFLT@#4al}%
-    {}% no artist
+    {%
+        \ifcsempty{KFLT@#4aul}%
+        {}%
+        {% yes author
+            \ifcsempty{KFLT@#4auf}%
+                {\index{\csuse{KFLT@#4aul}}}%
+                {\index{\csuse{KFLT@#4aul}, \csuse{KFLT@#4auf}}}%
+        }% yes author
+    }% no artist
     {% yes artist
         \ifcsempty{KFLT@#4af}%
-            {\index{\csname KFLT@#4al\endcsname}}%
-            {\index{\csname KFLT@#4al\endcsname, \csname KFLT@#4af\endcsname}}%
+            {\index{\csuse{KFLT@#4al}}}%
+            {\index{\csuse{KFLT@#4al}, \csuse{KFLT@#4af}}}%
     }% yes artist
 }% KFLT at docaption
 }% no tocdata
@@ -2772,15 +2992,17 @@
             {}%
 %    \end{macrocode}
 % Both |cstar| and |sc| were given, so add a \acro{LOF} entry:
+% \changes{v2.00}{2019/01/22}{Generalized for float type.}
 %    \begin{macrocode}
             {% non-empty cstar and sc:
-                \addcontentsline{\KFLT at listtype}%
-                {\csname KFLT@#1type\endcsname}{\KFLT at sc}%
+                \edef\KFLT at listtype{\csuse{KFLT@#1type}}%
+                \addcontentsline{\csuse{ext@\KFLT at listtype}}%
+                    {\csuse{KFLT@#1type}}{\KFLT at sc}%
             }% non-empty cstar and sc
 %    \end{macrocode}
 % |cstar| was given, so create an unnumbered caption:
 %    \begin{macrocode}
-            \KFLT at docaption*{\csname KFLT@#1c\endcsname}{#1}%
+            \KFLT at docaption*{\csuse{KFLT@#1c}}{#1}%
         }%
     }% starred caption
 %    \end{macrocode}
@@ -2789,11 +3011,11 @@
     {% unstarred caption
         \ifcsempty{KFLT@#1sc}%
         {% no short cap
-            \KFLT at docaption{\csname KFLT@#1c\endcsname}{#1}%
+            \KFLT at docaption{\csuse{KFLT@#1c}}{#1}%
         }% no short cap
         {% short cap
-            \KFLT at docaption[\csname KFLT@#1sc\endcsname]%
-            {\csname KFLT@#1c\endcsname}{#1}%
+            \KFLT at docaption[\csuse{KFLT@#1sc}]%
+            {\csuse{KFLT@#1c}}{#1}%
         }% short cap
 %    \end{macrocode}
 % Optional label:
@@ -2800,7 +3022,7 @@
 %    \begin{macrocode}
         \ifcsempty{KFLT@#1l}%
         {}%
-        {\label{\csname KFLT@#1l\endcsname}}%
+        {\label{\csuse{KFLT@#1l}}}%
     }% unstarred caption
 }
 %    \end{macrocode}
@@ -2818,16 +3040,17 @@
     \renewcommand{\KFLT at sc}{}%
     \setboolean{KFLT at scgiven}{false}%
     \renewcommand{\KFLT at type}{figure}%
-    \renewcommand{\KFLT at listtype}{lof}%
     \renewcommand{\KFLT at l}{}%
     \renewcommand{\KFLT at ap}{}%
     \renewcommand{\KFLT at af}{}%
     \renewcommand{\KFLT at al}{}%
     \renewcommand{\KFLT at as}{}%
+    \renewcommand{\KFLT at aup}{}%
+    \renewcommand{\KFLT at auf}{}%
+    \renewcommand{\KFLT at aul}{}%
+    \renewcommand{\KFLT at aus}{}%
     \renewcommand{\KFLT at t}{}%
     \renewcommand{\KFLT at textalign}{}%
-    \tdtextjustify%
-    \renewcommand{\KFLT at i}{}%
     \renewcommand{\KFLT at lw}{}%
     \setlength{\KFLT at w}{0pt}%
     \setlength{\KFLT at h}{0pt}%
@@ -2867,9 +3090,8 @@
     \ifnumless{\value{KFLT at thiscol}}{\value{KFLT at numcols}}%
     {}% thiscol < numcols
     {% >=
-
-        \addvspace{.75\floatsep}
-
+        \par%
+        \addvspace{.75\floatsep}%
         \defcounter{KFLT at thiscol}{0}%
     }%
 }%
@@ -2886,13 +3108,13 @@
 
 % \begin{macro}{\KFLT at trackrows} Tracks and spaces rows and columns.
 %    \begin{macrocode}
-\newcommand{\KFLT at trackrows}
+\newcommand{\KFLT at trackrows}%
 {%
 %    \end{macrocode}
 % If are nested inside a keyfloats or a subfloat:
 %    \begin{macrocode}
     \ifboolexpr{%
-        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or
+        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or%
         bool{KFLT at inkeysubfloats}%
     }%
     {% nested
@@ -2936,13 +3158,12 @@
 %    \end{macrocode}
 % Add some space, then create a full-width minipage to contain the text:
 %    \begin{macrocode}
-        \unskip%
-        \addvspace{2ex}%
+        \addvspace{\smallskipamount}%
         \begin{minipage}{\linewidth}%
 %    \end{macrocode}
 % Set the alignment and some text parameters:
 %    \begin{macrocode}
-        \csname KFLT@#1textalign\endcsname%
+        \csuse{KFLT@#1textalign}%
         \footnotesize%
         \setlength{\parskip}{1.5ex}%
         \setlength{\parindent}{0em}%
@@ -2949,7 +3170,7 @@
 %    \end{macrocode}
 % Typeset the actual text:
 %    \begin{macrocode}
-        \csname KFLT@#1t\endcsname%
+        \csuse{KFLT@#1t}%
 %    \end{macrocode}
 % Close it all out with a little more space:
 %    \begin{macrocode}
@@ -2981,7 +3202,7 @@
 %
 % \begin{macro}{\KFLT at addartisttext} \marg{\mainsubarg}
 %
-% Adds optional artist's name and add'l text.
+% Adds optional additional text.
 %
 % The argument is |{}| if a regular float, or
 % |subgrp| if \cs{keysubfigs} or \cs{keysubtabs}.
@@ -2989,11 +3210,10 @@
 % One of two versions is used, depending on whether the \pkg{tocdata}
 % package is available.
 %
-% If \pkg{tocdata} is loaded, this float is a figure, and artist information
-% is given, then the float's artist's information and optional text will be printed
-% elsewhere by \cs{KFLT at caption}.  Otherwise, it is printed here along with the text.
-%    \begin{macrocode}
-%    \end{macrocode}
+% If \pkg{tocdata} is loaded and this float has an artist or author,
+% then the float's artist's information and optional text will be printed
+% elsewhere by \cs{KFLT at caption}.  Otherwise, the text is printed here.
+%
 % Two versions, depending on whether \pkg{tocdata} is loaded:
 %    \begin{macrocode}
 \@ifpackageloaded{tocdata}
@@ -3004,33 +3224,51 @@
 \newcommand{\KFLT at addartisttext}[1]
 {%
 %    \end{macrocode}
-% Only use the artist name if this is a figure:
+% Only add text if is a figure without an artist or author name.
+% If an artist or author is given, the name and text will be added
+% by \pkg{tocdata}.
 %    \begin{macrocode}
-    \ifcsstring{KFLT@#1type}{figure}%
-    {% figure
+    \ifcsempty{KFLT@#1al}% artist last name
+        {%
+            \ifcsempty{KFLT@#1aul}% author last name
+                {\KFLT at addtext{#1}}
+                {}%
+        }%
+        {}% fig w/ artist: text will be added by \captionartist in \KFLT at caption
+}% KFLT at addartisttext
+}% tocdata loaded
 %    \end{macrocode}
-% Only use the artist name if a last name is given:
+% If \pkg{tocdata} is not loaded, the name and text are added here:
 %    \begin{macrocode}
-        \ifcsempty{KFLT@#1al}%
+{% tocdata not loaded
 %    \end{macrocode}
-% A figure but no artist:
+
+% Factored from \cs{KFLT at addartisttext}
 %    \begin{macrocode}
-            {\KFLT at addtext{#1}}%
+\newcommand*{\KFLT@@addartisttext}[3]{%
 %    \end{macrocode}
-% A figure with an artist: will be handled by \pkg{tocdata} when the caption is created.
+% Add space and create the name inside a full-width minipage:
 %    \begin{macrocode}
-            {}% fig w/ artist: text will be added by \captionartist in \KFLT at caption
-    }% figure
+        \addvspace{\medskipamount}%
+    \begin{minipage}{\linewidth}%
 %    \end{macrocode}
-% If not a figure, ignore artist information:
+% Text alignment is |#3|, and depends on artist or author:
 %    \begin{macrocode}
-    {\KFLT at addtext{#1}}%
-}% KFLT at addartisttext
-}% tocdata loaded
+    #3%
 %    \end{macrocode}
-% If \pkg{tocdata} is not loaded:
+% |#1| is empty or '|subgrp'| \\
+% |#2| is empty for artist, `|u|' for author:
 %    \begin{macrocode}
-{% tocdata not loaded
+    \footnotesize\textsc{%
+        \KFLT at optionalname{\csuse{KFLT@#1a#2p}}%
+        \KFLT at optionalname{\csuse{KFLT@#1a#2f}}%
+        \csuse{KFLT@#1a#2l}%
+        \csuse{KFLT@#1a#2s}%
+    }%
+    \end{minipage}%
+    \par\addvspace{2ex}%
+}
+
 \newcommand{\KFLT at addartisttext}[1]
 {%
 %    \end{macrocode}
@@ -3037,25 +3275,17 @@
 % Only use the artist information if a last name is given:
 %    \begin{macrocode}
     \ifcsempty{KFLT@#1al}%
-    {}% last name not given
-    {% last name given
+    {% artist last name not given
+        \ifcsempty{KFLT@#1aul}%
+        {}% author last name not given
+        {% author last name given
+            \KFLT@@addartisttext{#1}{u}{\raggedleft}%
+        }% author last name given
+    }% artist last name not given
+    {% artist last name given
+        \KFLT@@addartisttext{#1}{}{\centering}%
+    }%
 %    \end{macrocode}
-% Add space and create the name inside a full-width minipage:
-%    \begin{macrocode}
-        \addvspace{2ex}%
-        \begin{minipage}{\linewidth}%
-%    \end{macrocode}
-% If \pkg{tocdata} is not used, the artist's name is always centered:
-%    \begin{macrocode}
-        \centering\footnotesize\textsc{%
-        \KFLT at optionalname{\csname KFLT@#1ap\endcsname}%
-        \KFLT at optionalname{\csname KFLT@#1af\endcsname}%
-        \csname KFLT@#1al\endcsname\csname KFLT@#1as\endcsname%
-        }%
-        \end{minipage}%
-        \par\addvspace{2ex}%
-    }% last name given
-%    \end{macrocode}
 % Any additional text follows the artist's name:
 %    \begin{macrocode}
     \KFLT at addtext{#1}%
@@ -3117,21 +3347,20 @@
 %    \begin{macrocode}
     \end{lrbox}%
     \KFLT at frame{\usebox{\KFLT at envbox}}%
-    \par\addvspace{2ex}%
+    \par%
 }% endkeyboxinner
 %    \end{macrocode}
 % \end{environment}
 
 
-% \begin{macro}{\KFLT at boxkeys} \marg{keys} \marg{|figure|/|table|} \marg{|lof|/|lot|}
+% \begin{macro}{\KFLT at boxkeys} \marg{keys} \marg{float type}
 %
 % Default the options, adjust for a table, then parse the keys:
 %    \begin{macrocode}
-\NewDocumentCommand{\KFLT at boxkeys}{+m m m}
+\NewDocumentCommand{\KFLT at boxkeys}{+m m}
 {%
     \KFLT at defaults%
     \renewcommand{\KFLT at type}{#2}%
-    \renewcommand{\KFLT at listtype}{#3}%
     \setkeys{KFLT at keys}{#1}%
 }
 %    \end{macrocode}
@@ -3138,8 +3367,21 @@
 % \end{macro}
 
 
-% \begin{environment}{KFLT at boxouter}
-%	\marg{star?} \marg{loc}
+% \begin{macro}{\KFLT at LWR@hook at boxouter} Used by \pkg{lwarp}.
+%    \begin{macrocode}
+\newcommand*{\KFLT at LWR@hook at boxouter}{}%
+%    \end{macrocode}
+% \end{macro}
+
+% \begin{environment}{KFLT at LWR@hook at boxouter@minipage} Used by \pkg{lwarp}.
+%    \begin{macrocode}
+\newenvironment*{KFLT at LWR@hook at boxouter@minipage}[2][]
+    {\minipage[#1]{#2}}
+    {\endminipage}
+%    \end{macrocode}
+% \end{environment}
+
+% \begin{environment}{KFLT at boxouter} \marg{star?} \marg{loc}
 %
 % Boxes the contents of figures and floats.
 %
@@ -3160,7 +3402,7 @@
 % Start the new subfigure or subtable, of the given width:
 %    \begin{macrocode}
     \ifbool{KFLT at inkeysubfloats}%
-    {\csname sub\KFLT at type\endcsname{\KFLT at rowboxwidth}}% subfloat
+    {\csuse{sub\KFLT at type}{\KFLT at rowboxwidth}}% subfloat
 %    \end{macrocode}
 % If \env{keyfloats}, place the contents inside a \env{minipage}:
 %    \begin{macrocode}
@@ -3168,12 +3410,16 @@
         \ifnumgreater{\value{KFLT at keyfloatdepth}}{0}%
         {% keyfloats
             \ifbool{KFLT at keywrap}%
-                {\minipage[t]{\KFLT at rowboxwidth}}%
+                {\KFLT at LWR@hook at boxouter@minipage[t]{\KFLT at rowboxwidth}}%
                 {\minipage[\KFLT at va]{\KFLT at rowboxwidth}}%
             \captionsetup*{type=\KFLT at type}%
         }% keyfloats
         {% not keyfloats
 %    \end{macrocode}
+% A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
+%    \begin{macrocode}
+            \KFLT at LWR@hook at boxouter%
+%    \end{macrocode}
 %
 % Not a subfloat or \env{keyfloats}, so create a single float.
 %
@@ -3183,7 +3429,8 @@
             \ifbool{KFLT at keywrap}%
             {%
                 \par\addvspace{\baselineskip}%
-                \noindent\minipage[t]{\linewidth}%
+                \noindent%
+                \KFLT at LWR@hook at boxouter@minipage[t]{\linewidth}%
                 \captionsetup{type=\KFLT at type}%
             }%
             {% not a keywrap
@@ -3202,14 +3449,14 @@
 % and make the wrapped figure environment as wide as the
 % desired image size plus frame:
 %    \begin{macrocode}
-                \KFLT at findwidths%
-                \csname wrap\KFLT at type\endcsname{\KFLT at wp}%
-                {\KFLT at imagewidth+2\KFLTlooseframewidth}%
+                    \KFLT at findwidths%
+                    \wrapfloat{\KFLT at type}{\KFLT at wp}%
+                    {\KFLT at imagewidth+2\KFLTlooseframewidth}%
 %    \end{macrocode}
 % Change the interior image to the discovered fixed width.
 %    \begin{macrocode}
-                \renewcommand{\KFLT at lw}{}%
-                \renewcommand{\KFLT at w}{\KFLT at imagewidth}%
+                    \renewcommand{\KFLT at lw}{}%
+                    \renewcommand{\KFLT at w}{\KFLT at imagewidth}%
                 }% [W]
                 {% not [W]
 %    \end{macrocode}
@@ -3219,9 +3466,10 @@
                     \ifstrequal{#2}{M}%
 %    \end{macrocode}
 % Place [M], so create a marginfloat:
+% \changes{v2.00}{2019/03/18}{Added custom float types.}
 %    \begin{macrocode}
                     {% [M]
-                        \csname margin\KFLT at type\endcsname[\KFLT at mo]%
+                        \KFLT at marginfloat[\KFLT at mo]{\KFLT at type}%
                         \captionsetup{type=\KFLT at type}%
                     }% [M]
                     {% not [M}
@@ -3244,8 +3492,8 @@
 %    \begin{macrocode}
                         {% not [H]
                             \IfBooleanTF{#1}%
-                                {\csname \KFLT at type*\endcsname[#2]}%
-                                {\csname \KFLT at type\endcsname[#2]}%
+                                {\csuse{\KFLT at type*}[#2]}%
+                                {\csuse{\KFLT at type}[#2]}%
                         }% not [H]
                     }% not [M]
                 }% not [W]
@@ -3261,9 +3509,9 @@
 %    \begin{macrocode}
     \KFLT at findwidths%
 %    \end{macrocode}
-% If a table, place the caption above the contents:
+% Place the caption above the contents depending on \pkg{caption} \optn{position} option:
 %    \begin{macrocode}
-    \KFLT at captioniftype{table}{}%
+    \caption at iftop{\KFLT at caption{}}{}%
 %    \end{macrocode}
 % Typeset the contents:
 %    \begin{macrocode}
@@ -3276,24 +3524,27 @@
 %    \begin{macrocode}
 {% endboxouter
     \endcenter\unskip%
+    \addvspace{\smallskipamount}%
 %    \end{macrocode}
 % Optionally print artist's name and additional text:
 %    \begin{macrocode}
     \KFLT at addartisttext{}%
 %    \end{macrocode}
-% If a figure, typeset the caption below the contents:
+% Place the caption below the contents depending on \pkg{caption} \optn{position} option:
 %    \begin{macrocode}
-    \KFLT at captioniftype{figure}{}%
+    \caption at iftop{}{\KFLT at caption{}}%
 %    \end{macrocode}
 % If are inside \env{keysubtabs}, end the subtable:
 %    \begin{macrocode}
     \ifbool{KFLT at inkeysubfloats}%
     {%
-        \csname endsub\KFLT at type\endcsname%
+        \csuse{endsub\KFLT at type}%
     }% subfloat
     {% not subfloat
         \ifnumgreater{\value{KFLT at keyfloatdepth}}{0}% keyfloats?
-        {\endminipage}% keyfloats
+        {%
+            \endminipage%
+        }% keyfloats
         {% not keyfloats
 %    \end{macrocode}
 %
@@ -3304,7 +3555,7 @@
 % See if in a \env{keywrap}:
 %    \begin{macrocode}
             \ifbool{KFLT at keywrap}{%
-                \endminipage%
+                \endKFLT at LWR@hook at boxouter@minipage%
                 \par\addvspace{\baselineskip}%
             }%
             {% not keywrap
@@ -3317,7 +3568,7 @@
 % Place [W], so close the wrap float:
 %    \begin{macrocode}
                 {% [W]
-                    \csname endwrap\KFLT at type\endcsname%
+                    \endwrapfloat%
                 }% [W]
                 {% not[W]
 %    \end{macrocode}
@@ -3327,9 +3578,10 @@
                     \ifstrequal{#2}{M}%
 %    \end{macrocode}
 % Place [M], so close the marginfloat:
+% \changes{v2.00}{2019/03/18}{Added custom float types.}
 %    \begin{macrocode}
                     {% [M]
-                        \csname endmargin\KFLT at type\endcsname%
+                        \endKFLT at marginfloat%
                     }% [M]
                     {% not [M]
                         \ifstrequal{#2}{H}%
@@ -3339,8 +3591,8 @@
                         }%
                         {% not [H]
                             \IfBooleanTF{#1}% starred float?
-                                {\csname end\KFLT at type*\endcsname}%
-                                {\csname end\KFLT at type\endcsname}%
+                                {\csuse{end\KFLT at type*}}%
+                                {\csuse{end\KFLT at type}}%
                         }% not [H]
                     }% not [M]
                 }% not [W]
@@ -3352,7 +3604,173 @@
 % \end{environment}
 
 
+% \begin{macro}{\KFLT@@ignorespaces} \marg{commandname}
+% Only do command if not nested inside something.
+% \changes{v2.00}{2019/01/22}{Added.}
+%    \begin{macrocode}
+\newcommand*{\KFLT@@ignorespaces}[1]{%
+    \ifboolexpr{%
+        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or%
+        bool{KFLT at inkeysubfloats}%
+    }{}{\csuse{#1}}%
+}
+%    \end{macrocode}
+% \end{macro}
 
+
+% \begin{macro}{\KFLT at ignorespaces}
+% Only \cs{ignorespaces} if not nested inside something.
+% \changes{v2.00}{2019/01/22}{Added.}
+%    \begin{macrocode}
+\newcommand*{\KFLT at ignorespaces}{%
+    \KFLT@@ignorespaces{ignorespaces}%
+}
+%    \end{macrocode}
+% \end{macro}
+
+
+% \begin{macro}{\KFLT at envignorespaces}
+% Only \cs{ignorespaces} if not nested inside something.
+% \changes{v2.00}{2019/01/22}{Added.}
+%    \begin{macrocode}
+\newcommand*{\KFLT at envignorespaces}{%
+    \KFLT@@ignorespaces{ignorespacesafterend}%
+}
+%    \end{macrocode}
+% \end{macro}
+
+
+% \subsection{The \cs{KFLT at keyflt} macro}
+%
+% \begin{macro}{\KFLT at keyflt}
+%   \marg{1:star} \marg{2:loc} \marg{3:type} \marg{4:\keyvalsarg} \marg{5:contents}
+%
+% A lower-level macro to generate a float with its contents.
+% This is used by \cs{keyfig} and \cs{keyflt}.
+%
+% \changes{v2.00}{2019/03/17}{Added.}
+%    \begin{macrocode}
+\NewDocumentCommand{\KFLT at keyflt}{m m m +m +m}
+{%
+    \ifcsdef{l@#3}{}{%
+        \PackageError{keyfloat}%
+        {%
+            \protect\keyflt: Invalid float type.\MessageBreak%
+            \protect\keyflt*[loc]{type}{keys/values}{contents}\MessageBreak%
+            Also, \protect\keyflt\space is not an environment
+        }%
+        {%
+            Check argument order and float type.
+        }%
+    }%
+    \KFLT at ignorespaces%
+    \KFLT at trackrows%
+    \KFLT at boxkeys{#4}{#3}%
+    \begingroup%
+    \KFLT at boxouter{#1}{#2}%
+    #5%
+    \endKFLT at boxouter%
+    \endgroup%
+    \KFLT at ignorespaces%
+}
+%    \end{macrocode}
+% \end{macro}
+
+
+% \subsection{The \cs{keyflt} macro}
+
+% \begin{macro}{\keyflt} * \oarg{loc} \marg{type} \marg{\keyvalsarg} \marg{contents}
+%
+% A user-level macro to generate a float with its contents
+% centered inside an inner box.
+% This may be used by itself, or inside a \env{keyfloats} or
+% \env{keysubtabs} environment.
+%
+% \changes{v0.12}{2016/12/03}{Group around contents.}
+% \changes{v2.00}{2019/03/17}{Added.}
+%    \begin{macrocode}
+\NewDocumentCommand{\keyflt}{s O{tbp} m +m +m}
+{%
+    \KFLT at keyflt{#1}{#2}{#3}{#4}{%
+        \KFLT at boxinner%
+        \centering%
+        #5%
+        \endKFLT at boxinner%
+    }%
+}
+%    \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\endkeyflt}
+%
+% Generates an error in case the user tried to use \cs{keyflt} as an environment.
+% \changes{v2.00}{2019/03/17}{Added.}
+%    \begin{macrocode}
+\def\endkeyflt{%
+    \PackageError{keyfloat}
+    {%
+        \protect\end{keyflt}:\MessageBreak
+        \protect\keyflt\space is a macro, not an environment.\MessageBreak
+        Perhaps you want the keyfloat environment instead%
+    }
+    {%
+        Use \protect\begin{keyfloat} ... \protect\end{keyfloat}.
+    }
+}
+%    \end{macrocode}
+% \end{macro}
+
+
+% \subsection{The \env{keyfloat} environment}
+
+% \begin{macro}{\KFLT at keyfloatstart} \marg{star?} \marg{loc} \marg{float type} \marg{\keyvalsarg}
+% \changes{v2.00}{2019/03/18}{Factored.}
+%    \begin{macrocode}
+\newcommand{\KFLT at keyfloatstart}[4]{%
+    \KFLT at envignorespaces%
+    \KFLT at boxkeys{#4}{#3}%
+    \KFLT at boxouter{#1}{#2}%
+    \KFLT at boxinner%
+}
+%    \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\KFLT at keyfloatend}
+% \changes{v2.00}{2019/03/18}{Factored.}
+%    \begin{macrocode}
+\newcommand{\KFLT at keyfloatend}{%
+    \endKFLT at boxinner%
+    \endKFLT at boxouter%
+    \KFLT at envignorespaces%
+}
+%    \end{macrocode}
+% \end{macro}
+
+% \begin{environment}{keyfloat} * \oarg{loc} \marg{float type} \marg{\keyvalsarg}
+% \changes{v2.00}{2019/03/18}{Added.}
+%    \begin{macrocode}
+\NewDocumentEnvironment{keyfloat}{s O{tbp} m +m}
+{%
+    \KFLT at keyfloatstart{#1}{#2}{#3}{#4}%
+}%
+{%
+    \KFLT at keyfloatend%
+}
+%    \end{macrocode}
+% \end{environment}
+
+% Extra code to track rows outside of the \env{keyfloat} environment,
+% \DescribeObject{Before \env{keyfloat}}
+% before it starts.  This is done to allow nesting without losing track
+% of the prior level.
+%
+%    \begin{macrocode}
+\BeforeBeginEnvironment{keyfloat}{%
+    \KFLT at trackrows%
+}
+%    \end{macrocode}
+
+
 % \subsection{The \env{keyfigure} environment}
 
 % \begin{environment}{keyfigure} * \oarg{loc} \marg{\keyvalsarg}
@@ -3359,13 +3777,10 @@
 %    \begin{macrocode}
 \NewDocumentEnvironment{keyfigure}{s O{tbp} +m}
 {%
-    \KFLT at boxkeys{#3}{figure}{lof}%
-    \KFLT at boxouter{#1}{#2}%
-    \KFLT at boxinner%
+    \KFLT at keyfloatstart{#1}{#2}{figure}{#3}%
 }%
 {%
-    \endKFLT at boxinner%
-    \endKFLT at boxouter%
+    \KFLT at keyfloatend%
 }
 %    \end{macrocode}
 % \end{environment}
@@ -3384,27 +3799,19 @@
 
 % \subsection{The \cs{keyfig} macro}
 
-% \begin{macro}{\keyfig} * \oarg{2: loc} \marg{3: \keyvalsarg} \marg{4: image filename}
+% \begin{macro}{\keyfig} * \oarg{2:loc} \marg{3:\keyvalsarg} \marg{4:image filename}
 %
 % A user-level macro to generate a figure with an image.
 % This may be used by itself, or inside a \env{keyfloats} or
 % \env{keysubfigs} environment.
 %
-% \changes{v0.12}{2016/12/03}{Group around contents.}
+% \changes{v2.00}{2019/03/17}{Factored.}
 %    \begin{macrocode}
 \NewDocumentCommand{\keyfig}{s O{tbp} +m m}
 {%
-    \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{figure}{lof}%
-%    \end{macrocode}
-% After setting default values, override with the filename:
-%    \begin{macrocode}
-    \renewcommand{\KFLT at i}{#4}%
-    \begingroup%
-    \KFLT at boxouter{#1}{#2}%
-    \KFLT at onefigureimage%
-    \endKFLT at boxouter%
-    \endgroup%
+    \KFLT at keyflt{#1}{#2}{figure}{#3}{%
+        \KFLT at onefigureimage{#4}%
+    }%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3423,8 +3830,9 @@
 %    \begin{macrocode}
 \NewDocumentCommand{\keyfigbox}{s O{tbp} +m +m}
 {%
+    \KFLT at ignorespaces%
     \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{figure}{lof}%
+    \KFLT at boxkeys{#3}{figure}%
     \begingroup%
     \KFLT at boxouter{#1}{#2}%
     \KFLT at boxinner%
@@ -3432,6 +3840,7 @@
     \endKFLT at boxinner%
     \endKFLT at boxouter%
     \endgroup%
+    \KFLT at ignorespaces%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3451,8 +3860,9 @@
 %    \begin{macrocode}
 \NewDocumentCommand{\keyparbox}{s O{tbp} +m +m}
 {%
+    \KFLT at ignorespaces%
     \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{figure}{lof}%
+    \KFLT at boxkeys{#3}{figure}%
 %    \end{macrocode}
 % Force |cstar={}|:
 %    \begin{macrocode}
@@ -3468,6 +3878,7 @@
     \endKFLT at boxinner%
     \endKFLT at boxouter%
     \endgroup%
+    \KFLT at ignorespaces%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3481,20 +3892,15 @@
 % This may be used by itself, or inside a \env{keyfloats} or
 % \env{keysubtabs} environment.
 %
-% \changes{v0.12}{2016/12/03}{Group around contents.}
-%    \begin{macrocode}+
+% \changes{v2.00}{2019/03/17}{Factored.}
+%    \begin{macrocode}
 \NewDocumentCommand{\keytab}{s O{tbp} +m +m}
 {%
-    \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{table}{lot}%
-    \begingroup%
-    \KFLT at boxouter{#1}{#2}%
-    \KFLT at boxinner%
-    \centering%
-    #4%
-    \endKFLT at boxinner%
-    \endKFLT at boxouter%
-    \endgroup%
+    \IfBooleanTF{#1}{%
+        \keyflt*[#2]{table}{#3}{#4}%
+    }{%
+        \keyflt[#2]{table}{#3}{#4}%
+    }%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3506,14 +3912,10 @@
 %    \begin{macrocode}
 \NewDocumentEnvironment{keytable}{s O{tbp} +m}
 {%
-    \KFLT at boxkeys{#3}{table}{lot}%
-    \KFLT at boxouter{#1}{#2}%
-    \KFLT at boxinner%
-    \centering%
+    \KFLT at keyfloatstart{#1}{#2}{table}{#3}%
 }%
 {%
-    \endKFLT at boxinner%
-    \endKFLT at boxouter%
+    \KFLT at keyfloatend%
 }
 %    \end{macrocode}
 % \end{environment}
@@ -3543,13 +3945,14 @@
     {%
         \PackageError{keyfloat}%
         {%
-            Cannot nest keysubfigs or keysubtabs.%
+            Cannot nest keysubfigs or keysubtabs.\MessageBreak%
             (Not in outer par mode.)%
         }%
         {%
-            The subcaption package do not support nested environments, so%
-            the keyfloat package cannot place a keysubfigs or keysubtabs%
-            environment inside another, or inside a keyfloats.%
+            The subcaption package do not support nested environments,\MessageBreak
+            so the keyfloat package cannot place a\MessageBreak
+            keysubfigs or keysubtabs environment inside another,\MessageBreak
+            or inside a keyfloats.%
         }%
     }%
     {}%
@@ -3558,6 +3961,22 @@
 % \end{macro}
 
 
+% \begin{macro}{\KFLT at LWR@hook at keyfloats} Used by \pkg{lwarp}.
+%    \begin{macrocode}
+\newcommand*{\KFLT at LWR@hook at keyfloats}{}%
+%    \end{macrocode}
+% \end{macro}
+
+
+% \begin{environment}{KFLT at LWR@hook at keyfloatsminipage} Modified by \pkg{lwarp}.
+%    \begin{macrocode}
+\newenvironment*{KFLT at LWR@hook at keyfloatsminipage}[1]
+    {\noindent\minipage{#1}}
+    {\endminipage}%
+%    \end{macrocode}
+% \end{environment}
+
+
 % \begin{environment}{keyfloats} * \oarg{loc} \marg{num columns}
 %
 % User-level macro to create rows of figures/tables.
@@ -3580,9 +3999,14 @@
 %    \begin{macrocode}
 \NewDocumentEnvironment{keyfloats}{s O{tbp} m}
 {%
+    \KFLT at envignorespaces%
 %    \end{macrocode}
-% Nest the environment:
+% A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
 %    \begin{macrocode}
+    \KFLT at LWR@hook at keyfloats%
+%    \end{macrocode}
+% Track the depth:
+%    \begin{macrocode}
     \addtocounter{KFLT at keyfloatdepth}{1}%
 %    \end{macrocode}
 % If [H], nested, subfloats, or keywrap, use a minipage instead of a float:
@@ -3591,7 +4015,7 @@
         test {\ifstrequal{#2}{H}} or
         test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{1}} or
         bool {KFLT at inkeysubfloats} or
-        bool {KFLT at keywrap}
+        bool {KFLT at keywrap}%
     }%
 %    \end{macrocode}
 % Create an inline minipage:
@@ -3605,12 +4029,11 @@
             bool {KFLT at inkeysubfloats}
         }%
         {%
-            \noindent%
-            \begin{minipage}{\KFLT at rowboxwidth}%
+            \KFLT at LWR@hook at keyfloatsminipage{\KFLT at rowboxwidth}%
         }%
         {%
             \bigbreak%
-            \noindent\begin{minipage}{\linewidth}%
+            \KFLT at LWR@hook at keyfloatsminipage{\linewidth}%
         }%
 %    \end{macrocode}
 % If inside subfloats, generate subfigures by default:
@@ -3667,15 +4090,18 @@
         bool {KFLT at keywrap}
     }%
     {% was [H], etc.
-        \end{minipage}%
+        \endKFLT at LWR@hook at keyfloatsminipage%
+%         \end{minipage}%
 %    \end{macrocode}
 % Spacing if nested:
 %    \begin{macrocode}
-        \ifboolexpr{%
+        \ifboolexpr{
             test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or
             bool {KFLT at keywrap}
         }%
-        {}{\bigbreak}%
+        {}{%
+            \bigbreak%
+        }%
     }% was [H], etc.
 %    \end{macrocode}
 % Was not [H], so close a figure:
@@ -3688,6 +4114,7 @@
 % Unnest the environment:
 %    \begin{macrocode}
     \addtocounter{KFLT at keyfloatdepth}{-1}%
+    \KFLT at envignorespaces%
 }
 %    \end{macrocode}
 % \end{environment}
@@ -3701,21 +4128,7 @@
 %
 %    \begin{macrocode}
 \BeforeBeginEnvironment{keyfloats}{%
-%    \end{macrocode}
-% Track rows:
-%    \begin{macrocode}
-    \ifboolexpr{%
-        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or
-        bool {KFLT at inkeysubfloats}
-    }%
-        {\KFLT at maybestartfloatrow}%
-        {}%
-%    \end{macrocode}
-% Possibly fill space between columns:
-%    \begin{macrocode}
-    \ifnumgreater{\value{KFLT at thiscol}}{1}%
-        {\hfill}%
-        {}%
+    \KFLT at trackrows%
 }
 %    \end{macrocode}
 
@@ -3730,24 +4143,23 @@
     \setboolean{KFLT at subgrpcstar}{false}%
     \renewcommand{\KFLT at subgrpsc}{}%
     \setboolean{KFLT at subgrpscgiven}{false}%
-    \KFLT at setsubgrpfigure%
+    \renewcommand{\KFLT at subgrptype}{figure}%
     \renewcommand{\KFLT at subgrpl}{}%
     \renewcommand{\KFLT at subgrpap}{}%
     \renewcommand{\KFLT at subgrpaf}{}%
     \renewcommand{\KFLT at subgrpal}{}%
     \renewcommand{\KFLT at subgrpas}{}%
+    \renewcommand{\KFLT at subgrpaup}{}%
+    \renewcommand{\KFLT at subgrpauf}{}%
+    \renewcommand{\KFLT at subgrpaul}{}%
+    \renewcommand{\KFLT at subgrpaus}{}%
     \renewcommand{\KFLT at subgrpt}{}%
     \renewcommand{\KFLT at subgrptextalign}{}%
-    \tdtextjustify%
 }
 %    \end{macrocode}
 % \end{macro}
 
 
-
-
-
-
 % \begin{macro}{\KFLT at subfloats} \marg{starred?} \marg{loc} \marg{cols} \marg{\keyvalsarg}
 %
 % \changes{v0.13}{2017/01/16}{Fix: Subfloat type selection.}
@@ -3757,6 +4169,7 @@
 %    \begin{macrocode}
 \NewDocumentCommand{\KFLT at subfloats}{m m m +m}
 {%
+    \KFLT at envignorespaces%
 %    \end{macrocode}
 % Parse the key-value combinations:
 %    \begin{macrocode}
@@ -3806,9 +4219,9 @@
 %    \begin{macrocode}
     \center\unskip%
 %    \end{macrocode}
-% If this is a table, place the caption above the contents:
+% Place the caption above the contents depending on \pkg{caption} \optn{position} option:
 %    \begin{macrocode}
-    \KFLT at captioniftype{table}{subgrp}%
+    \caption at iftop{\KFLT at caption{subgrp}}{}%
 %    \end{macrocode}
 % Not yet started a row of subfloats.
 % The use of \cs{defcounter} makes these changes local.
@@ -3817,7 +4230,7 @@
     \defcounter{KFLT at thiscol}{0}%
 %    \end{macrocode}
 % Creat a group for the subfloats.
-% Necessary in case they change \cs{tdtextcenter}, etc.
+% Necessary in case they change \cs{tdartisttextcenter}, etc.
 %    \begin{macrocode}
     \begingroup%
 }
@@ -3835,7 +4248,8 @@
 % End the group containing the subfloats:
 %    \begin{macrocode}
     \endgroup%
-    \unskip\endcenter%
+    \unskip%
+    \endcenter%
 %    \end{macrocode}
 % A little extra space at the bottom:
 %    \begin{macrocode}
@@ -3845,9 +4259,9 @@
 %    \begin{macrocode}
     \KFLT at addartisttext{subgrp}%
 %    \end{macrocode}
-% If this was a figure, place the caption below the contents:
+% Place the caption below the contents depending on \pkg{caption} \optn{position} option:
 %    \begin{macrocode}
-    \KFLT at captioniftype{figure}{subgrp}%
+    \caption at iftop{}{\KFLT at caption{subgrp}}%
 %    \end{macrocode}
 % End the float or minipage:
 %    \begin{macrocode}
@@ -3865,17 +4279,24 @@
 % Unnest the environment:
 %    \begin{macrocode}
     \setboolean{KFLT at inkeysubfloats}{false}%
+    \KFLT at envignorespaces%
 }
 %    \end{macrocode}
 % \end{macro}
 
 
-% \begin{environment}{keysubfigs} * \oarg{loc} \marg{numcols} \marg{\keyvalsarg}
+% \begin{macro}{\KFLT at LWR@hook at keysubfloats} Used by \pkg{lwarp}.
+%    \begin{macrocode}
+\newcommand*{\KFLT at LWR@hook at keysubfloats}{}
+%    \end{macrocode}
+% \end{macro}
+
+% \begin{environment}{KFLT at keysubfloats} \marg{star?} \marg{loc} \marg{float type} \marg{numcols} \marg{\keyvalsarg}
 %
 % A group of subfigures typeset in rows.
 %
 %    \begin{macrocode}
-\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m}
+\NewDocumentEnvironment{KFLT at keysubfloats}{m m m m +m}
 {%
 %    \end{macrocode}
 % Error if trying to nest environments:
@@ -3882,13 +4303,21 @@
 %    \begin{macrocode}
     \KFLT at nonest%
 %    \end{macrocode}
+% A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
+%    \begin{macrocode}
+    \KFLT at LWR@hook at keysubfloats%
+%    \end{macrocode}
 % Default the options:
 %    \begin{macrocode}
     \KFLT at subgrpdefaults%
 %    \end{macrocode}
+% Default to figure float type:
+%    \begin{macrocode}
+    \renewcommand{\KFLT at subgrptype}{#3}%
+%    \end{macrocode}
 % Start of the environment:
 %    \begin{macrocode}
-    \KFLT at subfloats{#1}{#2}{#3}{#4}%
+    \KFLT at subfloats{#1}{#2}{#4}{#5}%
 }% the start of the environment
 %    \end{macrocode}
 % end of the environment:
@@ -3900,34 +4329,45 @@
 % \end{environment}
 
 
-% \begin{environment}{keysubtabs} * \oarg{loc} \marg{numcols} \marg{\keyvalsarg}
+% \begin{environment}{keysubfloats} * \oarg{loc} \marg{float type} \marg{numcols} \marg{\keyvalsarg}
 %
-% A group of subtables typeset in rows.
+% A group of subfloats typeset in rows.
+%
 %    \begin{macrocode}
-\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m}
+\NewDocumentEnvironment{keysubfloats}{s O{tbp} m m +m}
 {%
+    \KFLT at keysubfloats{#1}{#2}{#3}{#4}{#5}%
+}{%
+    \endKFLT at keysubfloats%
+}
 %    \end{macrocode}
-% Error if trying to nest environments:
+% \end{environment}
+
+
+% \begin{environment}{keysubfigs} * \oarg{loc} \marg{numcols} \marg{\keyvalsarg}
+%
+% A group of subfigures typeset in rows.
+%
 %    \begin{macrocode}
-    \KFLT at nonest%
+\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m}
+{%
+    \KFLT at keysubfloats{#1}{#2}{figure}{#3}{#4}%
+}{%
+    \endKFLT at keysubfloats%
+}
 %    \end{macrocode}
-% Default the options:
+% \end{environment}
+
+
+% \begin{environment}{keysubtabs} * \oarg{loc} \marg{numcols} \marg{\keyvalsarg}
+%
+% A group of subtables typeset in rows.
 %    \begin{macrocode}
-    \KFLT at subgrpdefaults%
-%    \end{macrocode}
-% Default to table float type:
-%    \begin{macrocode}
-    \KFLT at setsubgrptable%
-%    \end{macrocode}
-% Start of the environment:
-%    \begin{macrocode}
-    \KFLT at subfloats{#1}{#2}{#3}{#4}%
-}% the start of the environment
-%    \end{macrocode}
-% End of the environment:
-%    \begin{macrocode}
+\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m}
 {%
-    \KFLT at endsubfloats{#1}{#2}%
+    \KFLT at keysubfloats{#1}{#2}{table}{#3}{#4}%
+}{%
+    \endKFLT at keysubfloats%
 }
 %    \end{macrocode}
 % \end{environment}
@@ -3946,6 +4386,7 @@
 \NewDocumentEnvironment{KFLT at marginfloat}{O{-1.2ex} m}
 {% start
     \FloatBarrier% keep floats in order
+    \KFLT at envignorespaces%
     \begin{lrbox}{\KFLT at marginfloatbox}%
     \begin{minipage}{\marginparwidth}%
     \captionsetup{type=#2}%
@@ -3956,11 +4397,14 @@
     \end{minipage}%
     \end{lrbox}%
     \marginpar{\usebox{\KFLT at marginfloatbox}}%
+    \KFLT at envignorespaces%
 }% end
 %    \end{macrocode}
 % \end{environment}
 %
 %
+% Provided in case \pkg{tufte-book} is not loaded:
+%
 % \begin{environment}{marginfigure} \oarg{offset}
 % \changes{v0.12}{2016/12/03}{Added.}
 %    \begin{macrocode}
@@ -3983,8 +4427,8 @@
 %
 %
 %
+% \subsection{Wrapped floats}
 %
-%
 % \DescribeBoolean{KFL at keywrap} Tells the next keyfloat to wrap around some text.
 %    \begin{macrocode}
 \newboolean{KFLT at keywrap}

Modified: trunk/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty	2019-03-22 20:49:17 UTC (rev 50533)
+++ trunk/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty	2019-03-22 20:49:29 UTC (rev 50534)
@@ -18,11 +18,49 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{keyfloat}
-    [2019/01/11 v1.00 Key/value interface for floats and subfloats.]
+    [2019/03/21 v2.00 Key/value interface for floats and subfloats.]
 
 
 
 
+\@ifpackageloaded{tocdata}{
+    \@ifpackagelater{tocdata}{2019/03/21}{}{
+        \PackageError{keyfloat}
+        {%
+            The tocdata package is out of date.\MessageBreak
+            Update to tocdata v2.02 2019/03/21 or later\MessageBreak
+            to use use this version of keyfloat%
+        }
+        {%
+            Please update the tocdata package.  It's worth it!%
+        }
+    }
+}{}
+\newcommand*{\KFLT@@prohibitpackage}[2]{%
+\@ifpackageloaded{#1}
+{
+    \PackageError{keyfloat}
+    {%
+        The keyfloat package conflicts with the #1\MessageBreak
+        package. Remove #1 to use keyfloat.\MessageBreak
+        Alternative(s):\MessageBreak
+        \space\space#2%
+    }
+    {%
+        Keyfloat uses the caption, subcaption, newfloat, and wrapfig packages.%
+    }
+}{}
+}
+\newcommand*{\KFLT at prohibitpackage}[2]{
+    \KFLT@@prohibitpackage{#1}{#2}
+    \AtBeginDocument{\KFLT@@prohibitpackage{#1}{#2}}
+}
+\KFLT at prohibitpackage{floatrow}{caption and subcaption}
+\KFLT at prohibitpackage{subfig}{subcaption}
+\KFLT at prohibitpackage{subfigure}{subcaption}
+\KFLT at prohibitpackage{subfloat}{subcaption}
+\KFLT at prohibitpackage{float}{newfloat}
+\KFLT at prohibitpackage{floatflt}{wrapfig}
 \RequirePackage{etoolbox}[2011/01/03]%
 \RequirePackage{xparse}
 \RequirePackage{xkeyval}
@@ -33,19 +71,6 @@
 \RequirePackage{rotating}
 \RequirePackage{placeins}
 \RequirePackage{wrapfig}
-\@ifpackageloaded{floatrow}
-{
-\PackageError{keyfloat}
-{%
-    The keyfloat package conflicts with the floatrow package.
-    Remove floatrow to use keyfloat.%
-}
-{%
-    Keyfloat uses the caption and subcaption packages to
-    provide similar functionality to floatrow.%
-}
-}
-{}
 
 \PassOptionsToPackage{expand}{gettitlestring}
 
@@ -86,7 +111,6 @@
 \newcommand{\KFLT at sc}{}
 \newboolean{KFLT at scgiven}
 \newcommand*{\KFLT at type}{}
-\newcommand*{\KFLT at listtype}{}
 \define at key{KFLT at keys}{l}{\renewcommand{\KFLT at l}{#1}}
 \newcommand*{\KFLT at l}{}
 \define at key{KFLT at keys}{ap}{\renewcommand{\KFLT at ap}{#1}}
@@ -97,37 +121,48 @@
 \newcommand*{\KFLT at al}{}
 \define at key{KFLT at keys}{as}{\renewcommand{\KFLT at as}{#1}}
 \newcommand*{\KFLT at as}{}
+\define at key{KFLT at keys}{aup}{\renewcommand{\KFLT at aup}{#1}}
+\newcommand*{\KFLT at aup}{}
+\define at key{KFLT at keys}{auf}{\renewcommand{\KFLT at auf}{#1}}
+\newcommand*{\KFLT at auf}{}
+\define at key{KFLT at keys}{aul}{\renewcommand{\KFLT at aul}{#1}}
+\newcommand*{\KFLT at aul}{}
+\define at key{KFLT at keys}{aus}{\renewcommand{\KFLT at aus}{#1}}
+\newcommand*{\KFLT at aus}{}
 \newcommand*{\KFLT at textalign}{}
 \newcommand{\KFLT at t}{}
-\providecommand{\tdtextjustify}{}
-\providecommand{\tdtextcenter}{}
-\providecommand{\tdtextleft}{}
-\providecommand{\tdtextright}{}
-\providecommand{\tdnamejustify}{}
-\providecommand{\tdnamecenter}{}
-\providecommand{\tdnameleft}{}
-\providecommand{\tdnameright}{}
+\providecommand{\tdartisttextjustify}{}
+\providecommand{\tdartisttextcenter}{}
+\providecommand{\tdartisttextleft}{}
+\providecommand{\tdartisttextright}{}
+\providecommand{\tdauthortextjustify}{}
+\providecommand{\tdauthortextcenter}{}
+\providecommand{\tdauthortextleft}{}
+\providecommand{\tdauthortextright}{}
+\providecommand{\tdartistjustify}{}
+\providecommand{\tdartistcenter}{}
+\providecommand{\tdartistleft}{}
+\providecommand{\tdartistright}{}
+\providecommand{\tdauthorjustify}{}
+\providecommand{\tdauthorcenter}{}
+\providecommand{\tdauthorleft}{}
+\providecommand{\tdauthorright}{}
 \define at key{KFLT at keys}{t}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{}%
-    \tdtextjustify%
 }
 \define at key{KFLT at keys}{tc}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{\centering}%
-    \tdtextcenter%
 }
 \define at key{KFLT at keys}{tr}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{\raggedleft}%
-    \tdtextright%
 }
 \define at key{KFLT at keys}{tl}{%
     \renewcommand{\KFLT at t}{#1}%
     \renewcommand{\KFLT at textalign}{\raggedright}%
-    \tdtextleft%
 }
-\newcommand*{\KFLT at i}{}
 \define at key{KFLT at keys}{lw}{%
     \renewcommand{\KFLT at lw}{#1}%
     \setlength{\KFLT at w}{0pt}%
@@ -195,17 +230,6 @@
 
 \newcommand*{\KFLT at subgrptype}{}
 
-\newcommand*{\KFLT at subgrplisttype}{}
-
-\newcommand*{\KFLT at setsubgrpfigure}{%
-    \renewcommand{\KFLT at subgrptype}{figure}%
-    \renewcommand{\KFLT at subgrplisttype}{lof}%
-}
-
-\newcommand*{\KFLT at setsubgrptable}{%
-    \renewcommand{\KFLT at subgrptype}{table}%
-    \renewcommand{\KFLT at subgrplisttype}{lot}%
-}
 \define at key{KFLT at subgrpkeys}{l}{\renewcommand{\KFLT at subgrpl}{#1}}
 \newcommand*{\KFLT at subgrpl}{}
 \newcommand*{\KFLT at subgrptextalign}{}
@@ -213,22 +237,18 @@
 \define at key{KFLT at subgrpkeys}{t}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{}%
-    \tdtextjustify%
 }
 \define at key{KFLT at subgrpkeys}{tc}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{\centering}%
-    \tdtextcenter%
 }
 \define at key{KFLT at subgrpkeys}{tl}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{\raggedright}%
-    \tdtextleft%
 }
 \define at key{KFLT at subgrpkeys}{tr}{%
     \renewcommand{\KFLT at subgrpt}{#1}%
     \renewcommand{\KFLT at subgrptextalign}{\raggedleft}%
-    \tdtextright%
 }
 \define at key{KFLT at subgrpkeys}{ap}{\renewcommand{\KFLT at subgrpap}{#1}}
 \newcommand*{\KFLT at subgrpap}{}
@@ -239,7 +259,16 @@
 \define at key{KFLT at subgrpkeys}{as}{\renewcommand{\KFLT at subgrpas}{#1}}
 \newcommand*{\KFLT at subgrpas}{}
 
+\define at key{KFLT at subgrpkeys}{aup}{\renewcommand{\KFLT at subgrpaup}{#1}}
+\newcommand*{\KFLT at subgrpaup}{}
+\define at key{KFLT at subgrpkeys}{auf}{\renewcommand{\KFLT at subgrpauf}{#1}}
+\newcommand*{\KFLT at subgrpauf}{}
+\define at key{KFLT at subgrpkeys}{aul}{\renewcommand{\KFLT at subgrpaul}{#1}}
+\newcommand*{\KFLT at subgrpaul}{}
+\define at key{KFLT at subgrpkeys}{aus}{\renewcommand{\KFLT at subgrpaus}{#1}}
+\newcommand*{\KFLT at subgrpaus}{}
 
+
 \newlength{\KFLT at imagewidth}
 
 \newlength{\KFLT at boxwidth}
@@ -255,8 +284,8 @@
         {\setlength{\KFLT at imagewidth}{\KFLT at w}}%
         {% width not given
             \ifcsempty{\KFLT at lw}%
-            {\setlength{\KFLT at imagewidth}{\KFLT at boxwidth}}%
-            {\setlength{\KFLT at imagewidth}{\KFLT at lw\KFLT at boxwidth}}%
+                {\setlength{\KFLT at imagewidth}{\KFLT at boxwidth}}%
+                {\setlength{\KFLT at imagewidth}{\KFLT at lw\KFLT at boxwidth}}%
         }% width not given
 }
 \newcommand{\KFLTtightframe}[1]{%
@@ -294,7 +323,7 @@
                 {}% no frame
         }% not looseframe
 }
-\NewDocumentCommand{\KFLT at onefigureimage}{}
+\NewDocumentCommand{\KFLT at onefigureimage}{m}%
 {%
     \begin{lrbox}{\KFLT at envbox}%
     \ifdefempty{\KFLT at lw}%
@@ -305,21 +334,21 @@
             {% w and h
                 \includegraphics%
                 [scale=\KFLT at s,%
-                width=\KFLT at imagewidth,height=\KFLT at h]{\KFLT at i}%
+                width=\KFLT at imagewidth,height=\KFLT at h]{#1}%
             }% w and h
             {% only w
                 \includegraphics%
-                [scale=\KFLT at s,width=\KFLT at imagewidth]{\KFLT at i}%
+                [scale=\KFLT at s,width=\KFLT at imagewidth]{#1}%
             }% only w
         }% width is given
         {% width is not given
             \ifdimgreater{\KFLT at h}{0pt}%
-                {\includegraphics[scale=\KFLT at s,height=\KFLT at h]{\KFLT at i}}%
-                {\includegraphics[scale=\KFLT at s]{\KFLT at i}}%
+                {\includegraphics[scale=\KFLT at s,height=\KFLT at h]{#1}}%
+                {\includegraphics[scale=\KFLT at s]{#1}}%
         }% width is not given
     }% not linewidth
     {% linewidth given
-        \includegraphics[scale=\KFLT at s,width=\KFLT at imagewidth]{\KFLT at i}%
+        \includegraphics[scale=\KFLT at s,width=\KFLT at imagewidth]{#1}%
     }%
     \end{lrbox}%
     \unskip%
@@ -330,12 +359,6 @@
     \end{turn}%
 }
 
-\newcommand*{\KFLT at captioniftype}[2]{%
-    \ifcsstring{KFLT@#2type}{#1}%
-        {\KFLT at caption{#2}}%
-        {}%
-}
-
 \NewDocumentCommand{\KFLT at dosimplecaption}{m m m}
 {%
     \unskip%
@@ -345,36 +368,63 @@
 }
 \@ifpackageloaded{tocdata}
 {% tocdata loaded
+\newcommand*{\KFLT@@docaption}[6]{%
+\addvspace{\smallskipamount}%
+\ifcsempty{KFLT@#6t}{%
+    \IfBooleanTF{#3}%
+    {%
+        \csuse{caption#1}*[#4]{#5}%
+            []%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }{%
+        \csuse{caption#1}[#4]{#5}%
+            []%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }%
+}{%
+    \ifcsstring{KFLT@#6textalign}{}{\csuse{td#1textjustify}}{}%
+    \ifcsstring{KFLT@#6textalign}{\centering}{\csuse{td#1textcenter}}{}%
+    \ifcsstring{KFLT@#6textalign}{\raggedleft}{\csuse{td#1textright}}{}%
+    \ifcsstring{KFLT@#6textalign}{\raggedright}{\csuse{td#1textleft}}{}%
+    \IfBooleanTF{#3}%
+    {%
+        \csuse{caption#1}*[#4]{#5}%
+            [\csuse{KFLT@#6t}]%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }{%
+        \csuse{caption#1}[#4]{#5}%
+            [\csuse{KFLT@#6t}]%
+            [\csuse{KFLT@#6a#2p}]%
+            {\csuse{KFLT@#6a#2f}}%
+            {\csuse{KFLT@#6a#2l}}%
+            [\csuse{KFLT@#6a#2s}]%
+    }%
+}%
+}
 \NewDocumentCommand{\KFLT at docaption}{s o m m}
 {%
-    \ifcsstring{KFLT@#4type}{figure}%
-    {% figure
-        \ifcsempty{KFLT@#4al}%
-        {% figure w/o artist
+    \ifcsempty{KFLT@#4al}%
+    {% figure w/o artist
+        \ifcsempty{KFLT@#4aul}%
+        {% figure w/o artist or author
             \KFLT at dosimplecaption{#1}{#2}{#3}%
-        }% figure w/o artist
-        {% figure with an artist
-            \IfBooleanTF{#1}{% star
-                \captionartist*[#2]{#3}%
-                    [\csname KFLT@#4t\endcsname]%
-                    [\csname KFLT@#4ap\endcsname]%
-                    {\csname KFLT@#4af\endcsname}%
-                    {\csname KFLT@#4al\endcsname}%
-                    [\csname KFLT@#4as\endcsname]%
-            }% star
-            {% no star
-                \captionartist[#2]{#3}%
-                    [\csname KFLT@#4t\endcsname]%
-                    [\csname KFLT@#4ap\endcsname]%
-                    {\csname KFLT@#4af\endcsname}%
-                    {\csname KFLT@#4al\endcsname}%
-                    [\csname KFLT@#4as\endcsname]%
-            }% no star
-        }% figure with an artist
-    }% figure
-    {% not a figure, ignore artist information:
-        \KFLT at dosimplecaption{#1}{#2}{#3}%
-    }% not a figure
+        }% figure w/o artist or author
+        {% figure w/ author
+            \KFLT@@docaption{author}{u}{#1}{#2}{#3}{#4}%
+        }% figure w/ author
+    }% figure w/o artist
+    {% figure with an artist
+        \KFLT@@docaption{artist}{}{#1}{#2}{#3}{#4}%
+    }% figure with an artist
 }% KFLT at tocdata
 }% tocdata loaded
 {% no tocdata
@@ -382,11 +432,19 @@
 {%
     \KFLT at dosimplecaption{#1}{#2}{#3}%
     \ifcsempty{KFLT@#4al}%
-    {}% no artist
+    {%
+        \ifcsempty{KFLT@#4aul}%
+        {}%
+        {% yes author
+            \ifcsempty{KFLT@#4auf}%
+                {\index{\csuse{KFLT@#4aul}}}%
+                {\index{\csuse{KFLT@#4aul}, \csuse{KFLT@#4auf}}}%
+        }% yes author
+    }% no artist
     {% yes artist
         \ifcsempty{KFLT@#4af}%
-            {\index{\csname KFLT@#4al\endcsname}}%
-            {\index{\csname KFLT@#4al\endcsname, \csname KFLT@#4af\endcsname}}%
+            {\index{\csuse{KFLT@#4al}}}%
+            {\index{\csuse{KFLT@#4al}, \csuse{KFLT@#4af}}}%
     }% yes artist
 }% KFLT at docaption
 }% no tocdata
@@ -400,24 +458,25 @@
             \ifcsempty{KFLT@#1sc}%
             {}%
             {% non-empty cstar and sc:
-                \addcontentsline{\KFLT at listtype}%
-                {\csname KFLT@#1type\endcsname}{\KFLT at sc}%
+                \edef\KFLT at listtype{\csuse{KFLT@#1type}}%
+                \addcontentsline{\csuse{ext@\KFLT at listtype}}%
+                    {\csuse{KFLT@#1type}}{\KFLT at sc}%
             }% non-empty cstar and sc
-            \KFLT at docaption*{\csname KFLT@#1c\endcsname}{#1}%
+            \KFLT at docaption*{\csuse{KFLT@#1c}}{#1}%
         }%
     }% starred caption
     {% unstarred caption
         \ifcsempty{KFLT@#1sc}%
         {% no short cap
-            \KFLT at docaption{\csname KFLT@#1c\endcsname}{#1}%
+            \KFLT at docaption{\csuse{KFLT@#1c}}{#1}%
         }% no short cap
         {% short cap
-            \KFLT at docaption[\csname KFLT@#1sc\endcsname]%
-            {\csname KFLT@#1c\endcsname}{#1}%
+            \KFLT at docaption[\csuse{KFLT@#1sc}]%
+            {\csuse{KFLT@#1c}}{#1}%
         }% short cap
         \ifcsempty{KFLT@#1l}%
         {}%
-        {\label{\csname KFLT@#1l\endcsname}}%
+        {\label{\csuse{KFLT@#1l}}}%
     }% unstarred caption
 }
 
@@ -429,16 +488,17 @@
     \renewcommand{\KFLT at sc}{}%
     \setboolean{KFLT at scgiven}{false}%
     \renewcommand{\KFLT at type}{figure}%
-    \renewcommand{\KFLT at listtype}{lof}%
     \renewcommand{\KFLT at l}{}%
     \renewcommand{\KFLT at ap}{}%
     \renewcommand{\KFLT at af}{}%
     \renewcommand{\KFLT at al}{}%
     \renewcommand{\KFLT at as}{}%
+    \renewcommand{\KFLT at aup}{}%
+    \renewcommand{\KFLT at auf}{}%
+    \renewcommand{\KFLT at aul}{}%
+    \renewcommand{\KFLT at aus}{}%
     \renewcommand{\KFLT at t}{}%
     \renewcommand{\KFLT at textalign}{}%
-    \tdtextjustify%
-    \renewcommand{\KFLT at i}{}%
     \renewcommand{\KFLT at lw}{}%
     \setlength{\KFLT at w}{0pt}%
     \setlength{\KFLT at h}{0pt}%
@@ -462,18 +522,17 @@
     \ifnumless{\value{KFLT at thiscol}}{\value{KFLT at numcols}}%
     {}% thiscol < numcols
     {% >=
-
-        \addvspace{.75\floatsep}
-
+        \par%
+        \addvspace{.75\floatsep}%
         \defcounter{KFLT at thiscol}{0}%
     }%
 }%
 
 
-\newcommand{\KFLT at trackrows}
+\newcommand{\KFLT at trackrows}%
 {%
     \ifboolexpr{%
-        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or
+        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or%
         bool{KFLT at inkeysubfloats}%
     }%
     {% nested
@@ -491,14 +550,13 @@
     {}% no text
     {% text to add
         {% local
-        \unskip%
-        \addvspace{2ex}%
+        \addvspace{\smallskipamount}%
         \begin{minipage}{\linewidth}%
-        \csname KFLT@#1textalign\endcsname%
+        \csuse{KFLT@#1textalign}%
         \footnotesize%
         \setlength{\parskip}{1.5ex}%
         \setlength{\parindent}{0em}%
-        \csname KFLT@#1t\endcsname%
+        \csuse{KFLT@#1t}%
         \end{minipage}%
         \par\addvspace{2ex}%
         }% local
@@ -514,31 +572,44 @@
 {% tocdata loaded
 \newcommand{\KFLT at addartisttext}[1]
 {%
-    \ifcsstring{KFLT@#1type}{figure}%
-    {% figure
-        \ifcsempty{KFLT@#1al}%
-            {\KFLT at addtext{#1}}%
-            {}% fig w/ artist: text will be added by \captionartist in \KFLT at caption
-    }% figure
-    {\KFLT at addtext{#1}}%
+    \ifcsempty{KFLT@#1al}% artist last name
+        {%
+            \ifcsempty{KFLT@#1aul}% author last name
+                {\KFLT at addtext{#1}}
+                {}%
+        }%
+        {}% fig w/ artist: text will be added by \captionartist in \KFLT at caption
 }% KFLT at addartisttext
 }% tocdata loaded
 {% tocdata not loaded
+
+\newcommand*{\KFLT@@addartisttext}[3]{%
+        \addvspace{\medskipamount}%
+    \begin{minipage}{\linewidth}%
+    #3%
+    \footnotesize\textsc{%
+        \KFLT at optionalname{\csuse{KFLT@#1a#2p}}%
+        \KFLT at optionalname{\csuse{KFLT@#1a#2f}}%
+        \csuse{KFLT@#1a#2l}%
+        \csuse{KFLT@#1a#2s}%
+    }%
+    \end{minipage}%
+    \par\addvspace{2ex}%
+}
+
 \newcommand{\KFLT at addartisttext}[1]
 {%
     \ifcsempty{KFLT@#1al}%
-    {}% last name not given
-    {% last name given
-        \addvspace{2ex}%
-        \begin{minipage}{\linewidth}%
-        \centering\footnotesize\textsc{%
-        \KFLT at optionalname{\csname KFLT@#1ap\endcsname}%
-        \KFLT at optionalname{\csname KFLT@#1af\endcsname}%
-        \csname KFLT@#1al\endcsname\csname KFLT@#1as\endcsname%
-        }%
-        \end{minipage}%
-        \par\addvspace{2ex}%
-    }% last name given
+    {% artist last name not given
+        \ifcsempty{KFLT@#1aul}%
+        {}% author last name not given
+        {% author last name given
+            \KFLT@@addartisttext{#1}{u}{\raggedleft}%
+        }% author last name given
+    }% artist last name not given
+    {% artist last name given
+        \KFLT@@addartisttext{#1}{}{\centering}%
+    }%
     \KFLT at addtext{#1}%
 }% KFLT at addartisttext
 }% tocdata not loaded
@@ -560,49 +631,56 @@
     \endturn%
     \end{lrbox}%
     \KFLT at frame{\usebox{\KFLT at envbox}}%
-    \par\addvspace{2ex}%
+    \par%
 }% endkeyboxinner
 
-\NewDocumentCommand{\KFLT at boxkeys}{+m m m}
+\NewDocumentCommand{\KFLT at boxkeys}{+m m}
 {%
     \KFLT at defaults%
     \renewcommand{\KFLT at type}{#2}%
-    \renewcommand{\KFLT at listtype}{#3}%
     \setkeys{KFLT at keys}{#1}%
 }
 
+\newcommand*{\KFLT at LWR@hook at boxouter}{}%
+
+\newenvironment*{KFLT at LWR@hook at boxouter@minipage}[2][]
+    {\minipage[#1]{#2}}
+    {\endminipage}
+
 \NewDocumentEnvironment{KFLT at boxouter}{m m}
 {% boxouter
     \ifbool{KFLT at inkeysubfloats}%
-    {\csname sub\KFLT at type\endcsname{\KFLT at rowboxwidth}}% subfloat
+    {\csuse{sub\KFLT at type}{\KFLT at rowboxwidth}}% subfloat
     {% not subfloat:
         \ifnumgreater{\value{KFLT at keyfloatdepth}}{0}%
         {% keyfloats
             \ifbool{KFLT at keywrap}%
-                {\minipage[t]{\KFLT at rowboxwidth}}%
+                {\KFLT at LWR@hook at boxouter@minipage[t]{\KFLT at rowboxwidth}}%
                 {\minipage[\KFLT at va]{\KFLT at rowboxwidth}}%
             \captionsetup*{type=\KFLT at type}%
         }% keyfloats
         {% not keyfloats
+            \KFLT at LWR@hook at boxouter%
             \ifbool{KFLT at keywrap}%
             {%
                 \par\addvspace{\baselineskip}%
-                \noindent\minipage[t]{\linewidth}%
+                \noindent%
+                \KFLT at LWR@hook at boxouter@minipage[t]{\linewidth}%
                 \captionsetup{type=\KFLT at type}%
             }%
             {% not a keywrap
                 \ifstrequal{#2}{W}%
                 {% [W]
-                \KFLT at findwidths%
-                \csname wrap\KFLT at type\endcsname{\KFLT at wp}%
-                {\KFLT at imagewidth+2\KFLTlooseframewidth}%
-                \renewcommand{\KFLT at lw}{}%
-                \renewcommand{\KFLT at w}{\KFLT at imagewidth}%
+                    \KFLT at findwidths%
+                    \wrapfloat{\KFLT at type}{\KFLT at wp}%
+                    {\KFLT at imagewidth+2\KFLTlooseframewidth}%
+                    \renewcommand{\KFLT at lw}{}%
+                    \renewcommand{\KFLT at w}{\KFLT at imagewidth}%
                 }% [W]
                 {% not [W]
                     \ifstrequal{#2}{M}%
                     {% [M]
-                        \csname margin\KFLT at type\endcsname[\KFLT at mo]%
+                        \KFLT at marginfloat[\KFLT at mo]{\KFLT at type}%
                         \captionsetup{type=\KFLT at type}%
                     }% [M]
                     {% not [M}
@@ -614,8 +692,8 @@
                         }% [H]
                         {% not [H]
                             \IfBooleanTF{#1}%
-                                {\csname \KFLT at type*\endcsname[#2]}%
-                                {\csname \KFLT at type\endcsname[#2]}%
+                                {\csuse{\KFLT at type*}[#2]}%
+                                {\csuse{\KFLT at type}[#2]}%
                         }% not [H]
                     }% not [M]
                 }% not [W]
@@ -624,34 +702,37 @@
     }% not subfloat
     \ifbool{KFLT at cont}{\ContinuedFloat}{}%
     \KFLT at findwidths%
-    \KFLT at captioniftype{table}{}%
+    \caption at iftop{\KFLT at caption{}}{}%
     \center\unskip%
 }% boxouter
 {% endboxouter
     \endcenter\unskip%
+    \addvspace{\smallskipamount}%
     \KFLT at addartisttext{}%
-    \KFLT at captioniftype{figure}{}%
+    \caption at iftop{}{\KFLT at caption{}}%
     \ifbool{KFLT at inkeysubfloats}%
     {%
-        \csname endsub\KFLT at type\endcsname%
+        \csuse{endsub\KFLT at type}%
     }% subfloat
     {% not subfloat
         \ifnumgreater{\value{KFLT at keyfloatdepth}}{0}% keyfloats?
-        {\endminipage}% keyfloats
+        {%
+            \endminipage%
+        }% keyfloats
         {% not keyfloats
             \ifbool{KFLT at keywrap}{%
-                \endminipage%
+                \endKFLT at LWR@hook at boxouter@minipage%
                 \par\addvspace{\baselineskip}%
             }%
             {% not keywrap
                 \ifstrequal{#2}{W}%
                 {% [W]
-                    \csname endwrap\KFLT at type\endcsname%
+                    \endwrapfloat%
                 }% [W]
                 {% not[W]
                     \ifstrequal{#2}{M}%
                     {% [M]
-                        \csname endmargin\KFLT at type\endcsname%
+                        \endKFLT at marginfloat%
                     }% [M]
                     {% not [M]
                         \ifstrequal{#2}{H}%
@@ -661,8 +742,8 @@
                         }%
                         {% not [H]
                             \IfBooleanTF{#1}% starred float?
-                                {\csname end\KFLT at type*\endcsname}%
-                                {\csname end\KFLT at type\endcsname}%
+                                {\csuse{end\KFLT at type*}}%
+                                {\csuse{end\KFLT at type}}%
                         }% not [H]
                     }% not [M]
                 }% not [W]
@@ -671,18 +752,103 @@
     }% not subfloat
 }% endkeyboxouter
 
+\newcommand*{\KFLT@@ignorespaces}[1]{%
+    \ifboolexpr{%
+        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or%
+        bool{KFLT at inkeysubfloats}%
+    }{}{\csuse{#1}}%
+}
 
-\NewDocumentEnvironment{keyfigure}{s O{tbp} +m}
+\newcommand*{\KFLT at ignorespaces}{%
+    \KFLT@@ignorespaces{ignorespaces}%
+}
+
+\newcommand*{\KFLT at envignorespaces}{%
+    \KFLT@@ignorespaces{ignorespacesafterend}%
+}
+
+\NewDocumentCommand{\KFLT at keyflt}{m m m +m +m}
 {%
-    \KFLT at boxkeys{#3}{figure}{lof}%
+    \ifcsdef{l@#3}{}{%
+        \PackageError{keyfloat}%
+        {%
+            \protect\keyflt: Invalid float type.\MessageBreak%
+            \protect\keyflt*[loc]{type}{keys/values}{contents}\MessageBreak%
+            Also, \protect\keyflt\space is not an environment
+        }%
+        {%
+            Check argument order and float type.
+        }%
+    }%
+    \KFLT at ignorespaces%
+    \KFLT at trackrows%
+    \KFLT at boxkeys{#4}{#3}%
+    \begingroup%
     \KFLT at boxouter{#1}{#2}%
+    #5%
+    \endKFLT at boxouter%
+    \endgroup%
+    \KFLT at ignorespaces%
+}
+
+
+\NewDocumentCommand{\keyflt}{s O{tbp} m +m +m}
+{%
+    \KFLT at keyflt{#1}{#2}{#3}{#4}{%
+        \KFLT at boxinner%
+        \centering%
+        #5%
+        \endKFLT at boxinner%
+    }%
+}
+
+\def\endkeyflt{%
+    \PackageError{keyfloat}
+    {%
+        \protect\end{keyflt}:\MessageBreak
+        \protect\keyflt\space is a macro, not an environment.\MessageBreak
+        Perhaps you want the keyfloat environment instead%
+    }
+    {%
+        Use \protect\begin{keyfloat} ... \protect\end{keyfloat}.
+    }
+}
+
+
+\newcommand{\KFLT at keyfloatstart}[4]{%
+    \KFLT at envignorespaces%
+    \KFLT at boxkeys{#4}{#3}%
+    \KFLT at boxouter{#1}{#2}%
     \KFLT at boxinner%
-}%
-{%
+}
+
+\newcommand{\KFLT at keyfloatend}{%
     \endKFLT at boxinner%
     \endKFLT at boxouter%
+    \KFLT at envignorespaces%
 }
 
+\NewDocumentEnvironment{keyfloat}{s O{tbp} m +m}
+{%
+    \KFLT at keyfloatstart{#1}{#2}{#3}{#4}%
+}%
+{%
+    \KFLT at keyfloatend%
+}
+
+\BeforeBeginEnvironment{keyfloat}{%
+    \KFLT at trackrows%
+}
+
+
+\NewDocumentEnvironment{keyfigure}{s O{tbp} +m}
+{%
+    \KFLT at keyfloatstart{#1}{#2}{figure}{#3}%
+}%
+{%
+    \KFLT at keyfloatend%
+}
+
 \BeforeBeginEnvironment{keyfigure}{%
     \KFLT at trackrows%
 }
@@ -690,21 +856,17 @@
 
 \NewDocumentCommand{\keyfig}{s O{tbp} +m m}
 {%
-    \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{figure}{lof}%
-    \renewcommand{\KFLT at i}{#4}%
-    \begingroup%
-    \KFLT at boxouter{#1}{#2}%
-    \KFLT at onefigureimage%
-    \endKFLT at boxouter%
-    \endgroup%
+    \KFLT at keyflt{#1}{#2}{figure}{#3}{%
+        \KFLT at onefigureimage{#4}%
+    }%
 }
 
 
 \NewDocumentCommand{\keyfigbox}{s O{tbp} +m +m}
 {%
+    \KFLT at ignorespaces%
     \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{figure}{lof}%
+    \KFLT at boxkeys{#3}{figure}%
     \begingroup%
     \KFLT at boxouter{#1}{#2}%
     \KFLT at boxinner%
@@ -712,13 +874,15 @@
     \endKFLT at boxinner%
     \endKFLT at boxouter%
     \endgroup%
+    \KFLT at ignorespaces%
 }
 
 
 \NewDocumentCommand{\keyparbox}{s O{tbp} +m +m}
 {%
+    \KFLT at ignorespaces%
     \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{figure}{lof}%
+    \KFLT at boxkeys{#3}{figure}%
     \renewcommand{\KFLT at c}{}%
     \setboolean{KFLT at cstar}{true}%
     \begingroup%
@@ -728,34 +892,26 @@
     \endKFLT at boxinner%
     \endKFLT at boxouter%
     \endgroup%
+    \KFLT at ignorespaces%
 }
 
 
 \NewDocumentCommand{\keytab}{s O{tbp} +m +m}
 {%
-    \KFLT at trackrows%
-    \KFLT at boxkeys{#3}{table}{lot}%
-    \begingroup%
-    \KFLT at boxouter{#1}{#2}%
-    \KFLT at boxinner%
-    \centering%
-    #4%
-    \endKFLT at boxinner%
-    \endKFLT at boxouter%
-    \endgroup%
+    \IfBooleanTF{#1}{%
+        \keyflt*[#2]{table}{#3}{#4}%
+    }{%
+        \keyflt[#2]{table}{#3}{#4}%
+    }%
 }
 
 
 \NewDocumentEnvironment{keytable}{s O{tbp} +m}
 {%
-    \KFLT at boxkeys{#3}{table}{lot}%
-    \KFLT at boxouter{#1}{#2}%
-    \KFLT at boxinner%
-    \centering%
+    \KFLT at keyfloatstart{#1}{#2}{table}{#3}%
 }%
 {%
-    \endKFLT at boxinner%
-    \endKFLT at boxouter%
+    \KFLT at keyfloatend%
 }
 
 \BeforeBeginEnvironment{keytable}{%
@@ -771,26 +927,35 @@
     {%
         \PackageError{keyfloat}%
         {%
-            Cannot nest keysubfigs or keysubtabs.%
+            Cannot nest keysubfigs or keysubtabs.\MessageBreak%
             (Not in outer par mode.)%
         }%
         {%
-            The subcaption package do not support nested environments, so%
-            the keyfloat package cannot place a keysubfigs or keysubtabs%
-            environment inside another, or inside a keyfloats.%
+            The subcaption package do not support nested environments,\MessageBreak
+            so the keyfloat package cannot place a\MessageBreak
+            keysubfigs or keysubtabs environment inside another,\MessageBreak
+            or inside a keyfloats.%
         }%
     }%
     {}%
 }
 
+\newcommand*{\KFLT at LWR@hook at keyfloats}{}%
+
+\newenvironment*{KFLT at LWR@hook at keyfloatsminipage}[1]
+    {\noindent\minipage{#1}}
+    {\endminipage}%
+
 \NewDocumentEnvironment{keyfloats}{s O{tbp} m}
 {%
+    \KFLT at envignorespaces%
+    \KFLT at LWR@hook at keyfloats%
     \addtocounter{KFLT at keyfloatdepth}{1}%
     \ifboolexpr{%
         test {\ifstrequal{#2}{H}} or
         test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{1}} or
         bool {KFLT at inkeysubfloats} or
-        bool {KFLT at keywrap}
+        bool {KFLT at keywrap}%
     }%
     {% [H] or nested
         \ifboolexpr{%
@@ -798,12 +963,11 @@
             bool {KFLT at inkeysubfloats}
         }%
         {%
-            \noindent%
-            \begin{minipage}{\KFLT at rowboxwidth}%
+            \KFLT at LWR@hook at keyfloatsminipage{\KFLT at rowboxwidth}%
         }%
         {%
             \bigbreak%
-            \noindent\begin{minipage}{\linewidth}%
+            \KFLT at LWR@hook at keyfloatsminipage{\linewidth}%
         }%
         \ifbool{KFLT at inkeysubfloats}%
             {}%
@@ -832,12 +996,14 @@
         bool {KFLT at keywrap}
     }%
     {% was [H], etc.
-        \end{minipage}%
-        \ifboolexpr{%
+        \endKFLT at LWR@hook at keyfloatsminipage%
+        \ifboolexpr{
             test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or
             bool {KFLT at keywrap}
         }%
-        {}{\bigbreak}%
+        {}{%
+            \bigbreak%
+        }%
     }% was [H], etc.
     {% not [H], etc.
         \IfBooleanTF{#1}% starred figure?
@@ -844,18 +1010,11 @@
             {\end{figure*}}{\end{figure}}%
     }% not [H], etc.
     \addtocounter{KFLT at keyfloatdepth}{-1}%
+    \KFLT at envignorespaces%
 }
 
 \BeforeBeginEnvironment{keyfloats}{%
-    \ifboolexpr{%
-        test {\ifnumgreater{\value{KFLT at keyfloatdepth}}{0}} or
-        bool {KFLT at inkeysubfloats}
-    }%
-        {\KFLT at maybestartfloatrow}%
-        {}%
-    \ifnumgreater{\value{KFLT at thiscol}}{1}%
-        {\hfill}%
-        {}%
+    \KFLT at trackrows%
 }
 
 
@@ -865,19 +1024,23 @@
     \setboolean{KFLT at subgrpcstar}{false}%
     \renewcommand{\KFLT at subgrpsc}{}%
     \setboolean{KFLT at subgrpscgiven}{false}%
-    \KFLT at setsubgrpfigure%
+    \renewcommand{\KFLT at subgrptype}{figure}%
     \renewcommand{\KFLT at subgrpl}{}%
     \renewcommand{\KFLT at subgrpap}{}%
     \renewcommand{\KFLT at subgrpaf}{}%
     \renewcommand{\KFLT at subgrpal}{}%
     \renewcommand{\KFLT at subgrpas}{}%
+    \renewcommand{\KFLT at subgrpaup}{}%
+    \renewcommand{\KFLT at subgrpauf}{}%
+    \renewcommand{\KFLT at subgrpaul}{}%
+    \renewcommand{\KFLT at subgrpaus}{}%
     \renewcommand{\KFLT at subgrpt}{}%
     \renewcommand{\KFLT at subgrptextalign}{}%
-    \tdtextjustify%
 }
 
 \NewDocumentCommand{\KFLT at subfloats}{m m m +m}
 {%
+    \KFLT at envignorespaces%
     \setkeys{KFLT at subgrpkeys}{#4}%
     \setboolean{KFLT at inkeysubfloats}{true}%
     \IfBooleanTF{#1}%
@@ -900,7 +1063,7 @@
         {\ContinuedFloat}%
         {}%
     \center\unskip%
-    \KFLT at captioniftype{table}{subgrp}%
+    \caption at iftop{\KFLT at caption{subgrp}}{}%
     \defcounter{KFLT at numcols}{#3}%
     \defcounter{KFLT at thiscol}{0}%
     \begingroup%
@@ -908,10 +1071,11 @@
 
 \newcommand*{\KFLT at endsubfloats}[2]{%
     \endgroup%
-    \unskip\endcenter%
+    \unskip%
+    \endcenter%
     \par\addvspace{\bigskipamount}%
     \KFLT at addartisttext{subgrp}%
-    \KFLT at captioniftype{figure}{subgrp}%
+    \caption at iftop{}{\KFLT at caption{subgrp}}%
     \ifboolexpr{%
         test {\ifstrequal{#2}{H}} or
         bool{KFLT at keywrap}
@@ -923,33 +1087,49 @@
                 {\end{\KFLT at subgrptype}}%
         }% not [H]
     \setboolean{KFLT at inkeysubfloats}{false}%
+    \KFLT at envignorespaces%
 }
 
-\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m}
+\newcommand*{\KFLT at LWR@hook at keysubfloats}{}
+
+\NewDocumentEnvironment{KFLT at keysubfloats}{m m m m +m}
 {%
     \KFLT at nonest%
+    \KFLT at LWR@hook at keysubfloats%
     \KFLT at subgrpdefaults%
-    \KFLT at subfloats{#1}{#2}{#3}{#4}%
+    \renewcommand{\KFLT at subgrptype}{#3}%
+    \KFLT at subfloats{#1}{#2}{#4}{#5}%
 }% the start of the environment
 {%
     \KFLT at endsubfloats{#1}{#2}%
 }
 
-\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m}
+\NewDocumentEnvironment{keysubfloats}{s O{tbp} m m +m}
 {%
-    \KFLT at nonest%
-    \KFLT at subgrpdefaults%
-    \KFLT at setsubgrptable%
-    \KFLT at subfloats{#1}{#2}{#3}{#4}%
-}% the start of the environment
+    \KFLT at keysubfloats{#1}{#2}{#3}{#4}{#5}%
+}{%
+    \endKFLT at keysubfloats%
+}
+
+\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m}
 {%
-    \KFLT at endsubfloats{#1}{#2}%
+    \KFLT at keysubfloats{#1}{#2}{figure}{#3}{#4}%
+}{%
+    \endKFLT at keysubfloats%
 }
+
+\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m}
+{%
+    \KFLT at keysubfloats{#1}{#2}{table}{#3}{#4}%
+}{%
+    \endKFLT at keysubfloats%
+}
 \newsavebox{\KFLT at marginfloatbox}
 
 \NewDocumentEnvironment{KFLT at marginfloat}{O{-1.2ex} m}
 {% start
     \FloatBarrier% keep floats in order
+    \KFLT at envignorespaces%
     \begin{lrbox}{\KFLT at marginfloatbox}%
     \begin{minipage}{\marginparwidth}%
     \captionsetup{type=#2}%
@@ -960,6 +1140,7 @@
     \end{minipage}%
     \end{lrbox}%
     \marginpar{\usebox{\KFLT at marginfloatbox}}%
+    \KFLT at envignorespaces%
 }% end
 \ProvideDocumentEnvironment{marginfigure}{O{-1.2ex}}
   {\begin{KFLT at marginfloat}[#1]{figure}}



More information about the tex-live-commits mailing list