texlive[42662] Master/texmf-dist: keyfloat (9dec16)

commits+karl at tug.org commits+karl at tug.org
Fri Dec 9 23:52:39 CET 2016


Revision: 42662
          http://tug.org/svn/texlive?view=revision&revision=42662
Author:   karl
Date:     2016-12-09 23:52:39 +0100 (Fri, 09 Dec 2016)
Log Message:
-----------
keyfloat (9dec16)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/keyfloat/README
    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
===================================================================
--- trunk/Master/texmf-dist/doc/latex/keyfloat/README	2016-12-09 22:52:26 UTC (rev 42661)
+++ trunk/Master/texmf-dist/doc/latex/keyfloat/README	2016-12-09 22:52:39 UTC (rev 42662)
@@ -1,20 +1,20 @@
 The LaTeX keyfloat package
 Provides a key/value interface for generating floats.
 
-v0.11 — 2016/12/02
+v0.12 — 2016/12/09
 Copyright 2016 Brian Dunn — www.BDTechConcepts.com
 LaTeX Project Public License, version 1.3
 
 The keyfloat package provides a key/value user interface for quickly creating
 figures with a single image each, figures with arbitrary contents, tables,
-subfloats, rows of floats, and floats [H].
+subfloats, rows of floats, floats located [H]ere, floats in the [M]argin, and
+floats with text [W]rapped around them.
 
-Key/value combinations may specify a caption and label, a width
-proportional to \linewidth, a fixed width and/or height, rotation, scaling,
-a tight or loose frame, an \arraystretch, a continued float, additional
-supplemental text, and an artist/author's name with automatic index entry.
-When used with the tocdata package, the name also appears in the List of
-Figures.
+Key/value combinations may specify a caption and label, a width propor-
+tional to \linewidth, a fixed width and/or height, rotation, scaling, a tight
+or loose frame, an \arraystretch, a continued float, additional supplemental
+text, and an artist/author's name with automatic index entry. When used
+with the tocdata package, the name also appears in the List of Figures.
 
 Floats may be placed into a row environment, and are typeset to fit within
 the given number of columns, continuing to the next row if necessary. Nested

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	2016-12-09 22:52:26 UTC (rev 42661)
+++ trunk/Master/texmf-dist/source/latex/keyfloat/keyfloat.dtx	2016-12-09 22:52:39 UTC (rev 42662)
@@ -17,7 +17,7 @@
 % \iffalse
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>\ProvidesPackage{keyfloat}
-%<package>    [2016/12/02 v0.11 Key/value interface for floats and the subcaption package.]
+%<package>    [2016/12/09 v0.12 Key/value interface for floats and the subcaption package.]
 %
 %<*driver>
 \documentclass{ltxdoc}
@@ -25,7 +25,6 @@
 \newcommand*{\mypackagename}{keyfloat}
 \newcommand{\quicksummary}{Provides a key/value interface for generating floats.}
 
-\usepackage{fourier}% for the \danger symbol
 
 \usepackage{lmodern}
 % \usepackage{libertine}
@@ -33,6 +32,19 @@
 \usepackage[utf8]{inputenc}
 \usepackage{textcomp}	% provides \degree, \textquotesingle, \textmu
 
+
+\newcommand*{\TakeFourierOrnament}[1]{{%
+\fontencoding{U}\fontfamily{futs}\selectfont\char#1}}
+
+\newcommand*{\textwarning}{\TakeFourierOrnament{66}}
+
+% copy/paste special unicode symbols:
+\input{glyphtounicode}
+\pdfglyphtounicode{prime}{2032}% hex
+\pdfglyphtounicode{diameter}{2300}% diameter
+\pdfglyphtounicode{warningsign}{26A0}% warning sign
+\pdfgentounicode=1
+
 \usepackage{newunicodechar}
 \newunicodechar{ff}{ff}
 \newunicodechar{fi}{fi}
@@ -53,6 +65,7 @@
 % \newunicodechar{¶}{\P}
 % \newunicodechar{†}{\dag}
 \newunicodechar{‡}{\ddag}
+\newunicodechar{⚠}{\textwarning}
 
 \usepackage{microtype}
 
@@ -90,7 +103,7 @@
 placement=hbp
 ]{example}
 
-\captionsetup[example]{
+\captionsetup*[example]{
 format=hang,
 font=bf,
 justification=raggedright,
@@ -99,33 +112,56 @@
 position=top,
 }
 
-\captionsetup[figure]{
+\captionsetup{labelfont={small,bf},textfont={small,bf}}
+
+\captionsetup*[figure]{
 	style=default, justification=centering,
 	margin=0pt, parskip=0pt, skip=2ex,
 	labelfont={small,bf},textfont={small,bf}
 }
 
-\captionsetup[table]{
+\captionsetup*[table]{
 	style=default, justification=centering,
 	margin=0pt, parskip=0pt, skip=1ex,
 	labelfont={small,bf},textfont={small,bf}
 }
 
-\captionsetup[subfigure]{
+\captionsetup*[subfigure]{
 	style=default, justification=centering,
 	margin=0pt, parskip=0pt, skip=2ex,
 	labelfont={small},textfont={small}
 }
 
-\captionsetup[subtable]{
+\captionsetup*[subtable]{
 	style=default, justification=centering,
 	margin=0pt, parskip=0pt, skip=1ex,
 	labelfont={small},textfont={small}
 }
 
+\captionsetup*[example]{
+	format=plain, justification=justified,
+	margin=0pt, parskip=0pt, skip=0ex,
+	labelfont={bf},textfont={bf}
+}
 
+\captionsetup*[wrapfigure]{
+	style=default, justification=centering,
+	margin=0pt, parskip=0pt, skip=2ex,
+	labelfont={small,bf},textfont={small,bf}
+}
 
+\captionsetup*[wraptable]{
+	style=default, justification=centering,
+	margin=0pt, parskip=0pt, skip=1ex,
+	labelfont={small,bf},textfont={small,bf}
+}
 
+
+
+\usepackage{lipsum}
+
+
+
 \usepackage{tikz}
 \usetikzlibrary{positioning,fit,backgrounds,calc,shapes.geometric,shadows}
 
@@ -182,24 +218,9 @@
 \pagestyle{pageheadfoot}
 
 
+\usepackage{dtxdescribe}
 
 
-\usepackage[pdftex,bookmarks=true,hidelinks,%
-colorlinks,linkcolor=mylinkcolor,urlcolor=myurlcolor,%
-pageanchor=true,hyperindex=false,
-]{hyperref}
-
-\hypersetup{%
-pdfinfo={%
-Title={The LaTeX \mypackagename\ package},%
-Author={Brian Dunn},%
-Subject={A key/value interface for LaTeX floats.},%
-Keywords={LaTeX, floats, key/val, subcaption, rows}%
-}}
-
-
-\usepackage{cleveref}
-
 \newcommand*{\lmacro}[1]{\textbackslash#1}
 \newcommand*{\cmds}[1]{\texttt{#1}}
 \newcommand*{\env}[1]{\texttt{#1}}
@@ -208,105 +229,6 @@
 
 
 
-% \begin{newexample}[cross-reference commands / notes]{caption}
-% code listing to be typeset and then executed
-% \end{example}
-%
-% Using a minipage to keep the results on one page,
-% reads the code listing as a verbatim input using
-% the fancybox package, then displays the code listing
-% as a verbatim output, and also executes the code
-% and displays the result immediatly
-% after the environment, followed by a closing \cs{hrule}.
-% A title caption is specified,
-% along with optional cross-referencing commands to
-% refer to the resulting float if there is one.
-
-\definecolor{examplerulecolor}{rgb}{.9,.9,.9}
-
-\NewDocumentEnvironment{newexample}{+O{} m}
-{%
-% Copy the environment's contents to the file kf_cut.tex:
-\VerbatimOut[gobble=2,tabsize=4]{kf_cut.tex}}
-{\endVerbatimOut
-% Typeset the example:
-\addvspace{2ex}
-\minipage{\linewidth}
-\captionsetup{type=example}%
-\bigskip\hrule\medskip
-\caption{#2}
-\textcolor{examplerulecolor}{\smallskip\hrule}
-% Typeset the contents as verbatim:
-\VerbatimInput[tabsize=4]{kf_cut.tex}
-\unskip
-\ifstrempty{#1}
-{}
-{{\textcolor{examplerulecolor}{\hrule}\medskip\itshape\small #1}}
-\par\smallskip\hrule height .8pt\medskip
-\endminipage
-}
-
-% Outside of the environment's scope, input the example to generate its output
-% and labels:
-\AfterEndEnvironment{newexample}
-{\par\unskip\input{kf_cut.tex}%
-}
-
-
-
-
-
-% Indexing improvements:
-\makeatletter
-
-\newcommand*{\Desc at Type}[1]{\raggedleft{\scriptsize#1}\quad}
-
-% \Describe at Usage{name}{margin tag}{index tag}
-\newcommand*{\Describe at Usage}[3]{%
-% \@bsphack%
-\leavevmode\marginpar{\Desc at Type{#2}\texttt{#1}}%
-\index{#1\actualchar{\protect\ttfamily#1} (#3)\encapchar usage}%
-\index{#3s:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar usage}%
-% \@esphack%
-\ignorespaces%
-}
-
-% \Describe at CmdUsage{name}{margin tag}{index tag}
-% where name is a \macro
-\newcommand*{\Describe at CmdUsage}[3]{%
-% \@bsphack%
-\leavevmode\marginpar{\Desc at Type{#2}\cmd{#1}}%
-\SpecialIndex@{#1}{ (#3)\encapchar usage}%
-\index{#3s:\levelchar\cmd{#1}\encapchar usage}\ignorespaces%
-% \@esphack%
-\ignorespaces%
-}
-
-\newcommand*{\DescribeCommand}[1]{\Describe at Usage{#1}{Cmd}{command}}
-\newcommand*{\DescribeFile}[1]{\Describe at Usage{#1}{File}{file}}
-\newcommand*{\DescribePackage}[1]{\Describe at Usage{#1}{Pkg}{package}}
-\newcommand*{\DescribeOption}[1]{\Describe at Usage{#1}{Opt}{option}}
-\newcommand*{\DescribeArgument}[1]{\Describe at Usage{#1}{Arg}{argument}}
-\newcommand*{\DescribeBoolean}[1]{\Describe at Usage{#1}{Bool}{boolean}}
-\newcommand*{\DescribeLength}[1]{\Describe at CmdUsage{#1}{Len}{length}}
-\newcommand*{\DescribeCounter}[1]{\Describe at Usage{#1}{Ctr}{counter}}
-\newcommand*{\DescribeSimple}[1]{\leavevmode\marginpar{\raggedleft\texttt{#1}}\index{#1=\texttt{#1}}\ignorespaces}
-\renewcommand{\PrintEnvName}[1]{\strut \MacroFont {\scriptsize{}Env\quad}#1\ }
-\renewcommand{\PrintDescribeEnv}[1]{\strut \MacroFont {\scriptsize{}Env\quad}#1\ }
-
-\newcommand*{\DescribeKey}[1]{%
-\Describe at Usage{#1}{Key}{key}%
-}
-
-
-\newcommand{\margintag}[1]{%
-\marginpar{\raggedleft\textcolor{blue!70!black}{#1}}%
-\ignorespaces%
-}
-
-\makeatother
-
-
 % \newcommand*{\tikz}{Ti\textit{k}z}
 \newcommand*{\htmlfive}{\acro{HTML}\oldstylenums{5}}
 \newcommand*{\cssthree}{\acro{CSS}\oldstylenums{3}}
@@ -318,20 +240,12 @@
 \hfill\minipage{.9\linewidth}\raggedright#1\smallskip\hrule\medskip}
 {\smallskip\hrule\endminipage\hspace*{\fill}\par\addvspace{1.5ex}}
 
-\makeatletter
-\newcommand{\watchout}[1][]{%
-\@bsphack%
-\marginpar{\hspace*{\fill}%\includegraphics[height=3ex]{symbol_warning.pdf}
-\textcolor{DarkRed}{\large\danger\normalsize\quad#1}}%
-\@esphack%
-}
-\makeatother
 
 
 
 
 % \setlength{\marginparsep}{1em}
-% \setlength{\marginparpush}{.7ex}
+\setlength{\marginparpush}{2.5ex}
 \setlength{\parindent}{0em}
 \setlength{\parskip}{2ex}
 \setlength{\IndexMin}{40ex}
@@ -364,9 +278,27 @@
 \setlength{\dblfloatsep}{5ex plus 1ex minus 1ex}
 
 
-
 \usepackage{\mypackagename}
 
+
+\usepackage[pdftex,bookmarks=true,hidelinks,%
+colorlinks,linkcolor=mylinkcolor,urlcolor=myurlcolor,%
+pageanchor=true,hyperindex=true,
+]{hyperref}
+
+\hypersetup{%
+pdfinfo={%
+Title={The LaTeX \mypackagename\ package},%
+Author={Brian Dunn},%
+Subject={A key/value interface for LaTeX floats.},%
+Keywords={LaTeX, floats, key/val, subcaption, rows}%
+}}
+
+
+\usepackage{cleveref}
+
+
+
 \setcounter{IndexColumns}{2}
 
 \DisableCrossrefs
@@ -384,7 +316,7 @@
 %<*package>
 % \fi
 %
-% \CheckSum{0}
+% \CheckSum{1013}
 %
 % \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
@@ -404,9 +336,13 @@
 
 % \changes{v0.10}{2016/12/01}{\ 2016/12/01 Initial ver.}
 % \changes{v0.11}{2016/12/02}{\ 2016/12/02}
+% \changes{v0.12}{2016/12/09}{\ 2016/12/09}
+% \changes{v0.12}{2016/12/02}{Docs: Loading keyfloat.}
+% \changes{v0.12}{2016/12/05}{Docs: Improved index.}
 
 
 
+
 % \GetFileInfo{\mypackagename.sty}
 %
 % \DoNotIndex{\newcommand,\renewcommand,\addtocounter,\begin,\end,\begingroup,\endgroup}
@@ -448,11 +384,13 @@
 %
 % \vfill
 %
+%
 % \begin{abstract}
 % \noindent
 % The \pkg{keyfloat} package provides a key/value user interface for quickly
 % creating figures with a single image each, figures with arbitrary contents,
-% tables, subfloats, rows of floats, and floats [H].
+% tables, subfloats, rows of floats, floats located [H]ere,
+% floats in the [M]argin, and floats with text [W]rapped around them.
 %
 % Key/value combinations may specify a caption and label, a width proportional
 % to \cs{linewidth}, a fixed width and/or height, rotation, scaling, a
@@ -567,6 +505,11 @@
 % \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[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 into the margin.
 % \end{description}
 %
 % Additional features include:
@@ -577,7 +520,8 @@
 % or \env{keysubtabs} environment.
 % \item The number of columns is specified, and extra
 % floats are placed onto additional rows.
-% \item Floats may be placed [H]ere
+% \item Floats may be placed [H]ere.
+% \item Floats may be placed in the [M]argin.
 % \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.
@@ -615,7 +559,24 @@
 %
 % \section{Using the \pkg{keyfloat} Package}
 %
+% \subsection{Loading \pkg{keyfloat}}
+%
+% \pkg{keyfloat} is loaded with the usual command:
+% \begin{verbatim}
+% 	\usepackage{keyfloat}
+% \end{verbatim}
+%
+% If you wish to have artist's names appear in the table of contents,
+% as provided by the \pkg{tocdata} package,
+% load either \pkg{tocloft} or \pkg{titletoc},
+% followed by \pkg{tocdata}, then \pkg{keyfloat}:
+% \begin{verbatim}
+% 	\usepackage{titletoc}% or titletoc
+% 	\usepackage{tocdata}
+% 	\usepackage{keyfloat}
+% \end{verbatim}
 % 
+% 
 % \subsection{Macros and Environments}
 %
 % \DescribeMacro{\keyfig} * \oarg{loc} \marg{\keyvalsarg} \marg{image filename} \\
@@ -657,24 +618,52 @@
 % See \cref{ex:keyfloats}.
 %
 % \DescribeEnv{keysubfigs} * \oarg{loc} \marg{numcols} \marg{keys} \\
+% A group of subfigures typeset in rows.
+% May not be nested.
+% See \cref{ex:keysubfigs}.
+%
 % \DescribeEnv{keysubtabs} * \oarg{loc} \marg{numcols} \marg{keys} \\
-% A group of subfigures or subtables typeset in rows.
+% A group of subtables typeset in rows.
 % May not be nested.
 % See \cref{ex:keysubfigs}.
 %
+% \DescribeEnv{marginfigure} \oarg{offset} \\
+% A figure placed into the margin, with an optional vertical offset.
+% \cs{keyfloat} uses the version provided by the |tufte-book| class if available,
+% or provides its own version otherwise.
+% See \cref{ex:marginfigure}.
+%
+% \DescribeEnv{margintable} \oarg{offset} \\
+% A table placed into the margin, with an optional vertical offset.
+% \cs{keyfloat} uses the version provided by the |tufte-book| class if available,
+% or provides its own version otherwise.
+% See \cref{ex:margintable}.
+%
 % \bigskip\hrule
 %
+% \DescribeArgument{*}
 % The star option create floats which span both columns in a two-column
-% \DescribeArgument{*}
 % document.
 %
-% The [H] location may be used to force a figure to be ``Here'', in the
 % \DescribeArgument{{[H]}}
-% form of a minipage instead of a float.  A caption and label may
+% The |[H]| location forces a figure to be ``Here'', in the
+% form of a minipage instead of a float.  A caption, label, etc.\ may
 % still be assigned.
 %
+% \DescribeArgument{{[M]}}
+% The |[M]| location places the float into the margin.  When the |tufte-book| class
+% is used, its \env{marginfigure} and \env{margintable} environments are used,
+% otherwise \pkg{keyfloat} provides and uses its own versions of the same environments.
+% See \cref{ex:keyfigm,ex:keytablem}.
+%
+% \DescribeArgument{{[W]}}\DescribePackage{wrapfig}
+% The |[W]| location wraps text around the float.  Use this just before the start of
+% 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.
+%
+% \DescribeArgument{{[loc]}}
 % The star and [loc] options are ignored for floats inside a \env{keyfloats},
-% \DescribeArgument{{[loc]}}
 % \env{keysubfigs}, or \env{keysubtabs} environment.  Note that these
 % container environments may have their own star and [loc] options.
 %
@@ -681,8 +670,8 @@
 %
 %
 %
+% \clearpage
 %
-%
 % \subsection{Keys and Values}
 %
 %
@@ -755,6 +744,11 @@
 % ft &  Selects a tight frame with no \cs{fboxsep}.  Useful for photographs,
 % 	or diagrams which already have some margin built in. & ft \\
 % stretch & Sets \cs{arraystretch} inside the float. & stretch=1.5 \\
+% mo & Sets the vertical offset for a margin float. & mo=-1.2ex \\
+% wp & Sets the wrap placement for a wrapped float. The default
+%	is |O|, which places the wrapped float at the outside edge of the text.
+%	See \cref{tab:wrapplacement}.
+%	& wp=I \\
 % \bottomrule
 % \end{tabular}
 % \begin{tablenotes}
@@ -821,9 +815,33 @@
 % \end{keytable}
 %
 %
+% \Cref{tab:wrapplacement} shows the wrapped-float placement
+% \margintag{wrapped float placement}
+% options for the |wp| key
+% for floats placed |[W]|.
 %
+% \begin{keytable}{c=Wrapped-Float Placement Options,l=tab:wrapplacement}
+% \index{float>wrapped placement}\index{wrapped float placement}
+% \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 \\
+% i & I & to the inside margin \\
+% o & O & to the outside margin \\
+% \bottomrule
+% \end{tabular}
 %
+% \raggedright\small
+% The un-capitalized key attempts to place the float ``here'', and
+% the capitalized key allows \LaTeX\ to try to find the best location.
+% The default is |O|.
+% \end{keytable}
+
 %
+%
+%
 % \clearpage
 %
 % \subsection{Examples}
@@ -832,9 +850,9 @@
 % \subsubsection{Single Floats}
 %
 %
-% \begin{newexample}[\Cref{fig:simple}]{Figure with an image from a file}
+% \begin{dtxexample}[\Cref{fig:simple}]{Figure with an image from a file}
 % \keyfig{c=A \cs{keyfig} with an image,l=fig:simple}{image}
-% \end{newexample}
+% \end{dtxexample}
 %
 % This float (\cref{fig:simple}) is shown at its natural size
 % \margintag{natural size}
@@ -843,10 +861,10 @@
 % \index{image>natural size}
 %
 %
-% \begin{newexample}[\Cref{fig:figbox}]{Figure with arbitrary contents\label{ex:keyfigbox}}
+% \begin{dtxexample}[\Cref{fig:figbox}]{Figure with arbitrary contents\label{ex:keyfigbox}}
 % \keyfigbox{f,c={A \cs{keyfigbox}},l=fig:figbox}
 % 	{Some text.  More text. \par  Another paragraph.}
-% \end{newexample}
+% \end{dtxexample}
 %
 % The \cs{keyfigbox} creates a figure with a box of arbitrary contents, instead of
 % an image from a file.  Its default width is the full \cs{linewidth},\margintag{default width}
@@ -854,7 +872,7 @@
 % unless |w| or |lw| keys are used.
 %
 %
-% \begin{newexample}[\Cref{fig:environment}]
+% \begin{dtxexample}[\Cref{fig:environment}]
 % {Figure environment with arbitrary contents\label{ex:keyfigure}}
 % \begin{keyfigure}{f,c={A \env{keyfigure} environment},
 % 	l=fig:environment}
@@ -862,14 +880,14 @@
 % 
 % Including multiple paragraphs.
 % \end{keyfigure}
-% \end{newexample}
+% \end{dtxexample}
 %
 % The \env{keyfigure} environment is preferred over the \cs{keyfigbox} macro when
 % multiple lines of contents are to be included.
 %
-% \begin{newexample}[\Cref{tab:simpletable}]{Table macro}
+% \begin{dtxexample}[\Cref{tab:simpletable}]{Table macro}
 % \keytab{c=A \cs{keytab} table,l=tab:simpletable}{\testtable}
-% \end{newexample}
+% \end{dtxexample}
 %
 % Do not try to use tables which overflow the page.
 %
@@ -881,15 +899,15 @@
 % \index{troubleshooting>large tables}
 %
 %
-% \begin{newexample}[\Cref{tab:environment}]
+% \begin{dtxexample}[\Cref{tab:environment}]
 % {Table environment with arbitrary contents\label{ex:keytable}}
 % \begin{keytable}{f,c={A \env{keytable} environment},
 % 	l=tab:environment}
-% Arbitrary contents may go here.
+% Arbitrary contents may go here.\footnote{A footnote.}
 %
 % \testtable
 % \end{keytable}
-% \end{newexample}
+% \end{dtxexample}
 %
 % The \env{keytable} environment is preferred over the \cs{keytab} macro
 % since most tables are multi-line creations.
@@ -896,7 +914,7 @@
 %
 % \clearpage
 %
-% \begin{newexample}[\Cref{fig:options}]{Figure with many options selected}
+% \begin{dtxexample}[\Cref{fig:options}]{Figure with many options selected}
 % \keyfig{
 % 	w=2in,ft,r=15,
 % 	c=A figure with many options,
@@ -908,7 +926,7 @@
 % 	instead of \texttt{t}},
 % 	l=fig:options
 % }{image}
-% \end{newexample}
+% \end{dtxexample}
 %
 % Width is fixed at 2\,in, a tight frame is specified (\cs{fboxsep} of 0\,pt),
 % a short caption appears in the List of Figures, and the additional text
@@ -919,9 +937,9 @@
 %
 % \clearpage
 %
-% \begin{newexample}[\Cref{fig:linewidth}]{Using \cs{linewidth}}
+% \begin{dtxexample}[\Cref{fig:linewidth}]{Using \cs{linewidth}}
 % \keyfig{lw=.5,c=Half of \cs{linewidth},l=fig:linewidth}{image}
-% \end{newexample}
+% \end{dtxexample}
 %
 % \Cref{fig:linewidth} is half of \cs{linewidth} in size.
 % \margintag{\cs{linewidth}}
@@ -938,7 +956,7 @@
 %
 % \clearpage
 %
-% \begin{newexample}[\Cref%
+% \begin{dtxexample}[\Cref%
 %     {fig:looseframe,fig:tightframe,tab:looseframe,tab:tightframe}%
 % ]{Using frames}
 % \begin{keyfloats}[hbp]{4}
@@ -947,7 +965,7 @@
 % \keytab{f,c=Loosely-framed table,l=tab:looseframe}{\testtable}
 % \keytab{ft,c=Tightly-framed table,l=tab:tightframe}{\testtable}
 % \end{keyfloats}
-% \end{newexample}
+% \end{dtxexample}
 %
 % The |f| key adds a loose frame with the current \cs{fboxsep}.
 % This is desirable in most cases.
@@ -964,12 +982,12 @@
 %
 % \clearpage
 %
-% \begin{newexample}[\Cref{tab:rotated}]{Using rotation with boxes}
+% \begin{dtxexample}[\Cref{tab:rotated}]{Using rotation with boxes}
 % \keytab{f,w=.8in,c={Table, rotated},
 % 	r=70,l=tab:rotated,
 % 	tc=(Framed to show box width.)}
 % 	{\testwidetable}
-% \end{newexample}
+% \end{dtxexample}
 %
 % Unless a width is given, a box is the full \cs{linewidth}.
 % \margintag{rotated whitespace}
@@ -986,9 +1004,9 @@
 % \margintag{frame rotation}\index{frame>rotation}
 % \index{troubleshooting>rotating>frame}
 %
-% \begin{newexample}[\Cref{fig:here}]{Located [H]ere}
+% \begin{dtxexample}[\Cref{fig:here}]{Located [H]ere}
 % \keytab[H]{c={A table [H]},l=fig:here}{\testtable}
-% \end{newexample}
+% \end{dtxexample}
 %
 % \Cref{fig:here} is to be placed ``[H]ere'', and therefore may appear
 % \watchout[Out of sequence]
@@ -998,9 +1016,9 @@
 %
 %
 %
-% \begin{newexample}[See fig: ``A starred caption''.]{Unnumbered float}
+% \begin{dtxexample}[See fig: ``A starred caption''.]{Unnumbered float}
 % \keyfig[H]{f,cstar={A starred caption}}{image}
-% \end{newexample}
+% \end{dtxexample}
 %
 % A starred caption creates a float without a number, and without
 % an entry in the List of Figures unless there is a non-empty short caption.
@@ -1011,7 +1029,7 @@
 % \index{troubleshooting>missing label}
 %
 %
-% \begin{newexample}
+% \begin{dtxexample}
 % 	[See fig: ``Starred caption with a short caption''.]
 % 	{Unnumbered float with a \acro{LOF} entry}
 % \keyfig{
@@ -1018,19 +1036,19 @@
 % 	f,cstar={Starred caption with a short caption.},
 % 	sc={Starred short caption}
 % }{image}
-% \end{newexample}
+% \end{dtxexample}
 %
 % A starred caption with a non-empty short caption creates an
 % unnumbered entry in the List of Figures.
 %
 %
-% \begin{newexample}
+% \begin{dtxexample}
 % 	[See fig: ``Optional text which is not a caption.'']
 % 	{An unnumbered in-text image}
 % \keyfig[H]{f,cstar={},
 % 	tc={Optional text which is not a caption.}
 % }{image2}
-% \end{newexample}
+% \end{dtxexample}
 %
 % By using [H] and |cstar={}|, the image is placed inline
 % without a number or \acro{LOF} entry.
@@ -1038,7 +1056,7 @@
 % Also see \cref{ex:keyparbox}.
 %
 %
-% \begin{newexample}[\Cref{fig:nexttoparbox}, and the box to its left.]
+% \begin{dtxexample}[\Cref{fig:nexttoparbox}, and the box to its left.]
 % 	{A box without a caption.\label{ex:keyparbox}}
 % \begin{keyfloats}{2}
 % \keyparbox{
@@ -1048,7 +1066,7 @@
 % \keyfig{c=Next to a \cs{keyparbox},l=fig:nexttoparbox}{image}
 % \end{keyfloats}
 % \keyparbox[H]{f,lw=.5}{A \cs{keyparbox} [H], outside the floatrow.}
-% \end{newexample}
+% \end{dtxexample}
 %
 % A \cs{keyparbox} is a \cs{keyfigbox} with |cstar={}|,
 % and is mostly useful as an information box inside a row or a set of subfloats.
@@ -1060,7 +1078,7 @@
 %
 % \subsubsection{Groups of Floats}
 %
-% \begin{newexample}[\Cref{fig:firstinrow} to \Cref{tab:seventhinrow}]{Groups of figures — \env{keyfloats} environment\label{ex:keyfloats}}
+% \begin{dtxexample}[\Cref{fig:firstinrow} to \Cref{tab:seventhinrow}]{Groups of figures — \env{keyfloats} environment\label{ex:keyfloats}}
 % \begin{keyfloats}{2}
 % \keyfig{lw=1,f,c={First in a group},
 % 	l=fig:firstinrow,tl={\cs{raggedright} text}
@@ -1077,7 +1095,7 @@
 % \end{keyfloats}
 % \keytab{c={Seventh in a group},l=tab:seventhinrow}{\testwidetable}
 % \end{keyfloats}
-% \end{newexample}
+% \end{dtxexample}
 %
 % 
 % \Cref{fig:firstinrow} to \cref{tab:seventhinrow} are in a \env{keyfloats} environment.
@@ -1116,7 +1134,7 @@
 %
 %
 %
-% \begin{newexample}[\Cref{fig:subfigs}]{Subfigures — \env{keysubfigs} environment\label{ex:keysubfigs}}
+% \begin{dtxexample}[\Cref{fig:subfigs}]{Subfigures — \env{keysubfigs} environment\label{ex:keysubfigs}}
 % \begin{keysubfigs}{3}{c=Subfigures,l=fig:subfigs}
 % \keyfig{lw=1,f,c={First Subfigure},
 % 	l=fig:firstsubfig,t=Some Text}{image}
@@ -1130,7 +1148,7 @@
 % \keyfig{lw=.5,f,c={Fifth subfigure},l=fig:fifthsubfig}{image}
 % \end{keyfloats}
 % \end{keysubfigs}
-% \end{newexample}
+% \end{dtxexample}
 % 
 % \Crefrange{fig:firstsubfig}{fig:fifthsubfig} are in
 % the \cref{fig:subfigs} \env{keysubfigs} environment.
@@ -1181,12 +1199,12 @@
 % The label may be placed in a continued float, and will still
 % receive the same float number as the prior non-continued float.
 %
-% \begin{newexample}[\Cref{fig:firstcontinued}]{Continued figure}
+% \begin{dtxexample}[\Cref{fig:firstcontinued}]{Continued figure}
 % \begin{keyfloats}{2}
 % \keyfig{,c=Figure to be continued}{image}
 % \keyfig{c={\dots continued},cont,l=fig:firstcontinued}{image2}
 % \end{keyfloats}
-% \end{newexample}
+% \end{dtxexample}
 %
 %
 % \clearpage
@@ -1197,7 +1215,7 @@
 % The containing environment's float receives the same number as the previous float
 % (presumably another subfloat container).
 %
-% \begin{newexample}[\Cref{fig:continuedfigures}]{Continued subfloats}
+% \begin{dtxexample}[\Cref{fig:continuedfigures}]{Continued subfloats}
 % \begin{keysubfigs}{2}{c={A set of figures},l=fig:continuedfigures}
 % \keyfig{c={First of a set},l=fig:contfirst}{image}
 % \keyfig{c={Second of a set},l=fig:contsecond}{image}
@@ -1206,15 +1224,124 @@
 % \keyfig{c={Third of a set},l=fig:contthird}{image2}
 % \keyfig{c={Fourth of a set},l=fig:contfourth}{image2}
 % \end{keysubfigs}
-% \end{newexample}
+% \end{dtxexample}
 %
 %
+% \clearpage
+% \subsubsection{Margin Floats}
+% \changes{v0.12}{2016/12/02}{Docs: Margin float examples.}
 %
+% When a keyfloat is located [M], it will be placed in the margin.
+%
+% \DescribeClass{tufte-book}
+% When the |tufte-book| class is used, its \env{marginfigure} or \env{margintable}
+% environments will be used, otherwise \pkg{keyfloat} provides environments
+% of the same name and uses those instead.
+%
+% \begin{dtxexample}[\Cref{fig:marginfigure}]{The \env{marginfigure} environment\label{ex:marginfigure}}
+% \begin{marginfigure}
+% \centering
+% \includegraphics[width=.75\linewidth]{image}
+%
+% Some text added by hand.
+% \caption{A \env{marginfigure}}
+% \label{fig:marginfigure}
+% \end{marginfigure}
+% \end{dtxexample}
+%
+%
+% \begin{dtxexample}[\Cref{fig:margintable}]{The \env{margintable} environment\label{ex:margintable}}
+% \begin{margintable}
+% \centering
+% \testwidetable
+% \caption{A \env{margintable}}
+% \label{fig:margintable}
+% \end{margintable}
+% \end{dtxexample}
+%
+%
+% \begin{dtxexample}[\Cref{fig:keyfigm}]{Using \cs{keyfig}\texttt{[M]}\label{ex:keyfigm}}
+% \keyfig[M]{c={A \cs{keyfig}\texttt{[M]}},l=fig:keyfigm,ft,
+% 	t=Additional text.
+% 	Text text text text text text.
+% 
+% 	More paragraphs.
+% }{image2}
+% \end{dtxexample}
+%
+%
+% \begin{dtxexample}[\Cref{tab:keytablem}]
+%	{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}
+% \testwidetable
+% \end{keytable}
+% \end{dtxexample}
+%
+% A negative offset was used to shift the table upwards
+% \margintag{margin float offset}
+% to the top of the example.
+%
+% To set the minimum-allowed distance between \cs{marginpar}s and margin floats:
+% \margintag{distance between floats}
+% \index{distance between floats}\index{float>distance between}
+% \begin{verbatim}
+% \setlength{\marginparpush}{3ex}
+% \end{verbatim}
+%
+%
+%
 % \clearpage
+% \subsubsection{Wrapped Floats}
+% \changes{v0.12}{2016/12/03}{Docs: Wrapped float examples.}
+%
+% \begin{dtxexample}[\Cref{fig:keyfigw,tab:keytabw}]
+%	{Using \cs{keyfig}\texttt{[W]} and \cs{keytab}\texttt{[W]}\label{ex:keyfigw}}
+% \keyfig[W]{c={A \cs{keyfig}\texttt{[W]}},
+% 	l=fig:keyfigw,ft,lw=.4,wp=I,
+% 	t={.4\cs{linewidth} wide, placed \texttt{I}.}
+% }{image2}
+% \lipsum[1]
+% \keytab[W]{c={A \cs{keytab}\texttt{[W]}},l=tab:keytabw,w=.75in,
+% }{\testtable}
+% \lipsum[2]
+% \end{dtxexample}
+%
+% \begin{dtxexample}[\Cref{fig:keyfigboxw} and the \cs{keyparbox}.]
+%	{Using \cs{keyfigbox}\texttt{[W]} and \cs{keyparbox}\texttt{[W]}\label{ex:keyfigboxw}}
+% \keyfigbox[W]{c={A \cs{keyfigbox}\texttt{[W]}},
+% 	l=fig:keyfigboxw,f,lw=.25,wp=I,
+% 	t=Text text text text text text text text text
+% }{The contents.}
+% \lipsum[1]
+% \keyparbox[W]{w=.75in}{\centering A \cs{keyparbox.}}
+% \lipsum[2]
+% \end{dtxexample}
+%
+%
+% \begin{dtxexample}[\Cref{fig:keyfigurew,tab:keytablew}]
+%	{Using \cs{keyfigure}\texttt{[W]} and \cs{keytable}[W]\label{ex:keyfiguretablew}}
+% \begin{keyfigure}[W]{c={A \cs{keyfigure}\texttt{[W]}},
+% 	l=fig:keyfigurew,f,w=1.5in}
+% This is a keyfigure.
+% \end{keyfigure}
+% \lipsum[1]
+%
+% \begin{keytable}[W]{c={A \env{keytable}\texttt{[W]}},
+% 	l=tab:keytablew,w=2in,wp=L,tc=Placed \texttt{L} and 2in wide.}
+% \testwidetable
+% \end{keytable}
+% \lipsum[2]
+% \end{dtxexample}
+%
+%
+%
+%
+% \clearpage
 % \subsubsection{Custom Frames}
 %
 % 
-% \begin{newexample}[\Cref{fig:customframe,fig:customlooseframe}]
+% \begin{dtxexample}[\Cref{fig:customframe,fig:customlooseframe}]
 %	{Custom frames with \pkg{mdframed}\label{ex:customframe}}
 % \renewcommand{\KFLTtightframe}[1]{%
 % \begin{mdtightframe}%
@@ -1233,7 +1360,7 @@
 % \keyfig{ft,c=Custom-framed image,l=fig:customframe}{image}
 % \keyfigbox{f,c=Custom loosely-framed box,
 % 	l=fig:customlooseframe}{A loosely-framed box.}
-% \end{newexample}
+% \end{dtxexample}
 %
 % \DescribePackage{mdframed}
 % \Cref{ex:customframe} shows custom frames
@@ -1247,7 +1374,7 @@
 %
 % See \cref{sec:customframes} for more details.
 %
-% \begin{newexample}[\Cref{fig:customshadow,fig:customlooseshadow}]
+% \begin{dtxexample}[\Cref{fig:customshadow,fig:customlooseshadow}]
 %	{Custom shadows with \pkg{fancybox}\label{ex:customshadow}}
 % \renewcommand{\KFLTtightframe}[1]{%
 % \setlength{\fboxrule}{.4pt}
@@ -1268,7 +1395,7 @@
 % \keyfig{ft,c=Custom shadow,l=fig:customshadow}{image}
 % \keyfigbox{f,c=Custom loosely-framed shadow,lw=.5,
 % 	l=fig:customlooseshadow}{A loosely-framed shadow box.}
-% \end{newexample}
+% \end{dtxexample}
 %
 % \DescribePackage{fancybox}
 % \Cref{ex:customshadow} shows custom shadow frames
@@ -1302,14 +1429,14 @@
 % \clearpage
 % \subsubsection{Artist's Name}
 %
-% \begin{newexample}[\Cref{fig:artist}]{Artist's name — image}
+% \begin{dtxexample}[\Cref{fig:artist}]{Artist's name — image}
 % \keyfig{ft,ap=Mr.,af=First,al=Last,as={~III},
 %	tc={\textit{About the illustration.}},
 %	c=Artist's name — image,l=fig:artist}{image}
-% \end{newexample}
+% \end{dtxexample}
 %
 %
-% \begin{newexample}[\Cref{fig:artistpar}]{Artist's name — arbitary contents}
+% \begin{dtxexample}[\Cref{fig:artistpar}]{Artist's name — arbitary contents}
 % \tdnameright
 % \begin{keyfigure}{f,ap=Mr.,al=Last,
 %	c=Artist's name — arbitrary contents,l=fig:artistpar}
@@ -1317,7 +1444,7 @@
 % anything not an image file.
 % \end{keyfigure}
 % \tdnamecenter
-% \end{newexample}
+% \end{dtxexample}
 %
 % The artist's name and optional prefix/suffix are printed below the figure,
 % and an index entry is made for the name in (Last, First) format,
@@ -1329,7 +1456,7 @@
 %
 % \clearpage
 %
-% \begin{newexample}[\Cref{fig:artistcollection}]{Subfloats with an artist}
+% \begin{dtxexample}[\Cref{fig:artistcollection}]{Subfloats with an artist}
 % \begin{keysubfigs}{2}{
 % 	c=Artist's collection, l=fig:artistcollection,
 % 	t={Some fully-justified text just for illustrative purposes,
@@ -1342,7 +1469,7 @@
 % 	\keyfig{c=Artist's Second Work,
 % 		tc={Commentary about the work.}}{image2}
 % \end{keysubfigs}
-% \end{newexample}
+% \end{dtxexample}
 %
 % A group of figures may be placed into a subfloat container,
 % which may have its own artist keys and additional text.
@@ -1421,9 +1548,12 @@
 % \index{caption>formatting}
 % The settings used in this documentation are:
 % \begin{verbatim}
+% % default applied to margin floats:
+% \captionsetup{labelfont={small,bf},textfont={small,bf}}
+% 
 % \captionsetup[figure]{
 % 	style=default, justification=centering,
-% 	margin=0pt, parskip=0pt, skip=1ex,
+% 	margin=0pt, parskip=0pt, skip=2ex,
 % 	labelfont={small,bf},textfont={small,bf}
 % }
 % 
@@ -1435,7 +1565,7 @@
 % 
 % \captionsetup[subfigure]{
 % 	style=default, justification=centering,
-% 	margin=0pt, parskip=0pt, skip=1ex,
+% 	margin=0pt, parskip=0pt, skip=2ex,
 % 	labelfont={small},textfont={small}
 % }
 % 
@@ -1496,7 +1626,16 @@
 %    \begin{macrocode}
 \RequirePackage{rotating}
 %    \end{macrocode}
+% \DescribePackage{placeins} Provides \FloatBarrier to process existing floats before adding new ones.
+%    \begin{macrocode}
+\RequirePackage{placeins}
+%    \end{macrocode}
+% \DescribePackage{wrapfig} Provides figure wrapping code.
+%    \begin{macrocode}
+\RequirePackage{wrapfig}
+%    \end{macrocode}
 
+
 % Rows of floats are created by a simple \env{minipage} environment,
 % instead of relying on a preexisting package.  This proved to be
 % advantageous when support was added for multiple rows in one
@@ -1547,6 +1686,10 @@
 \newlength{\KFLT at rowboxwidth}
 %    \end{macrocode}
 
+
+
+
+
 % \subsection{Float Key Handling}
 
 % \DescribeBoolean{KFLT at cont} Continued float?
@@ -1554,7 +1697,7 @@
 \newboolean{KFLT at cont}{}
 %    \end{macrocode}
 %
-% \DescribeKey{cont} Continued float?
+% \DescribeKey[main]{cont} Continued float?
 %
 %    \begin{macrocode}
 \define at key{KFLT at keys}{cont}[true]{\setboolean{KFLT at cont}{#1}}
@@ -1571,7 +1714,7 @@
 \newboolean{KFLT at cstar}
 %    \end{macrocode}
 %
-% \DescribeKey{c} Caption
+% \DescribeKey[main]{c} Caption
 %
 %    \begin{macrocode}
 \define at key{KFLT at keys}{c}%
@@ -1578,7 +1721,7 @@
 	{\renewcommand{\KFLT at c}{#1}\setboolean{KFLT at cstar}{false}}
 %    \end{macrocode}
 %
-% \DescribeKey{cstar} Caption starred?
+% \DescribeKey[main]{cstar} Caption starred?
 %
 %    \begin{macrocode}
 \define at key{KFLT at keys}{cstar}%
@@ -1585,7 +1728,7 @@
 	{\renewcommand{\KFLT at c}{#1}\setboolean{KFLT at cstar}{true}}
 %    \end{macrocode}
 %
-% \DescribeKey{sc} Short caption
+% \DescribeKey[main]{sc} Short caption
 %
 %    \begin{macrocode}
 \define at key{KFLT at keys}{sc}{%
@@ -1618,7 +1761,7 @@
 % \end{macro}
 %
 %
-% \DescribeKey{l} Label
+% \DescribeKey[main]{l} Label
 %    \begin{macrocode}
 \define at key{KFLT at keys}{l}{\renewcommand{\KFLT at l}{#1}}
 %    \end{macrocode}
@@ -1630,9 +1773,9 @@
 % \end{macro}
 %
 %
-% For the \pkg{tocdata} package:
+% For the artist/author keys:
 %
-% \DescribeKey{ap} Artist prefix
+% \DescribeKey[main]{ap} Artist prefix
 %    \begin{macrocode}
 \define at key{KFLT at keys}{ap}{\renewcommand{\KFLT at ap}{#1}}
 %    \end{macrocode}
@@ -1643,7 +1786,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{af} Artist first name
+% \DescribeKey[main]{af} Artist first name
 %    \begin{macrocode}
 \define at key{KFLT at keys}{af}{\renewcommand{\KFLT at af}{#1}}
 %    \end{macrocode}
@@ -1654,7 +1797,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{al} Artist last name
+% \DescribeKey[main]{al} Artist last name
 %    \begin{macrocode}
 \define at key{KFLT at keys}{al}{\renewcommand{\KFLT at al}{#1}}
 %    \end{macrocode}
@@ -1665,7 +1808,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{as} Artist suffix
+% \DescribeKey[main]{as} Artist suffix
 %    \begin{macrocode}
 \define at key{KFLT at keys}{as}{\renewcommand{\KFLT at as}{#1}}
 %    \end{macrocode}
@@ -1698,23 +1841,20 @@
 % \end{macro}
 %
 %
-% Create replacement macros if \pkg{tocdata} is not loaded:
+% Create replacement macros in case \pkg{tocdata} is not loaded:
+% \changes{v0.12}{2016/12/02}{Adapts to older version of tocdata.}
 %    \begin{macrocode}
-\@ifpackageloaded{tocdata}
-{}
-{
-\newcommand{\tdtextjustify}{}
-\newcommand{\tdtextcenter}{}
-\newcommand{\tdtextleft}{}
-\newcommand{\tdtextright}{}
-\newcommand{\tdnamejustify}{}
-\newcommand{\tdnamecenter}{}
-\newcommand{\tdnameleft}{}
-\newcommand{\tdnameright}{}
-}
+\providecommand{\tdtextjustify}{}
+\providecommand{\tdtextcenter}{}
+\providecommand{\tdtextleft}{}
+\providecommand{\tdtextright}{}
+\providecommand{\tdnamejustify}{}
+\providecommand{\tdnamecenter}{}
+\providecommand{\tdnameleft}{}
+\providecommand{\tdnameright}{}
 %    \end{macrocode}
 %
-% \DescribeKey{t} Additional text, justified alignment.
+% \DescribeKey[main]{t} Additional text, justified alignment.
 %    \begin{macrocode}
 \define at key{KFLT at keys}{t}{
 \renewcommand{\KFLT at t}{#1}
@@ -1723,7 +1863,7 @@
 }
 %    \end{macrocode}
 %
-% \DescribeKey{tc} Additional text, centered alignment.
+% \DescribeKey[main]{tc} Additional text, centered alignment.
 %    \begin{macrocode}
 \define at key{KFLT at keys}{tc}{
 \renewcommand{\KFLT at t}{#1}
@@ -1732,7 +1872,7 @@
 }
 %    \end{macrocode}
 %
-% \DescribeKey{tr} Additional text, aligned to the right.
+% \DescribeKey[main]{tr} Additional text, aligned to the right.
 %    \begin{macrocode}
 \define at key{KFLT at keys}{tr}{
 \renewcommand{\KFLT at t}{#1}
@@ -1741,7 +1881,7 @@
 }
 %    \end{macrocode}
 %
-% \DescribeKey{tl} Additional text, aligned to the left.
+% \DescribeKey[main]{tl} Additional text, aligned to the left.
 %    \begin{macrocode}
 \define at key{KFLT at keys}{tl}{
 \renewcommand{\KFLT at t}{#1}
@@ -1759,7 +1899,7 @@
 % \end{macro}
 %
 %
-% \DescribeKey{lw} Fraction of \cs{linewidth}
+% \DescribeKey[main]{lw} Fraction of \cs{linewidth}
 %    \begin{macrocode}
 \define at key{KFLT at keys}{lw}{%
 \renewcommand{\KFLT at lw}{#1}%
@@ -1773,7 +1913,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{w} Fixed width
+% \DescribeKey[main]{w} Fixed width
 %    \begin{macrocode}
 \define at key{KFLT at keys}{w}{%
 \setlength{\KFLT at w}{#1}%
@@ -1787,7 +1927,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{h} Fixed height
+% \DescribeKey[main]{h} Fixed height
 %    \begin{macrocode}
 \define at key{KFLT at keys}{h}{\setlength{\KFLT at h}{#1}}
 %    \end{macrocode}
@@ -1798,7 +1938,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{s} Scale
+% \DescribeKey[main]{s} Scale
 %    \begin{macrocode}
 \define at key{KFLT at keys}{s}{\renewcommand{\KFLT at s}{#1}}
 %    \end{macrocode}
@@ -1809,7 +1949,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{r} Angle.  90 is counter-clockwise 90 degrees.
+% \DescribeKey[main]{r} Angle.  90 is counter-clockwise 90 degrees.
 %    \begin{macrocode}
 \define at key{KFLT at keys}{r}{\renewcommand{\KFLT at r}{#1}}
 %    \end{macrocode}
@@ -1820,7 +1960,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{f} Frame the image with \cs{KFLTlooseframe}.
+% \DescribeKey[main]{f} Frame the image with \cs{KFLTlooseframe}.
 %    \begin{macrocode}
 \define at key{KFLT at keys}{f}[true]{\setboolean{KFLT at f}{#1}}
 %    \end{macrocode}
@@ -1830,7 +1970,7 @@
 \newboolean{KFLT at f}
 %    \end{macrocode}
 
-% \DescribeKey{ft} Tightly frame the image using \cs{KFLTtightframe}.
+% \DescribeKey[main]{ft} Tightly frame the image using \cs{KFLTtightframe}.
 %	This is useful for photographs, or diagrams which
 %	already have built-in margins.
 %    \begin{macrocode}
@@ -1843,7 +1983,7 @@
 %    \end{macrocode}
 
 
-% \DescribeKey{stretch} Set \cs{arraystretch} inside the table environment.
+% \DescribeKey[main]{stretch} Set \cs{arraystretch} inside the table environment.
 %    \begin{macrocode}
 \define at key{KFLT at keys}{stretch}{\renewcommand{\KFLT at stretch}{#1}}
 %    \end{macrocode}
@@ -1855,8 +1995,38 @@
 % \end{macro}
 
 
+% \DescribeKey[main]{mo} Set vertical offset for a margin float.
+% \changes{v0.12}{2016/12/03}{Added \texttt{mo} key.}
+%    \begin{macrocode}
+\define at key{KFLT at keys}{mo}{\setlength{\KFLT at mo}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at mo} Storage for the vertical margin offset.
+%    \begin{macrocode}
+\newlength{\KFLT at mo}
+%    \end{macrocode}
+% \end{macro}
 
 
+% \DescribeKey[main]{wp} Set wrap placement for a wrapped float.
+%
+% See \cref{tab:wrapplacement} on \cpageref{tab:wrapplacement}.
+% 
+% \changes{v0.12}{2016/12/03}{Added \texttt{wp} key.}
+%    \begin{macrocode}
+\define at key{KFLT at keys}{wp}{\renewcommand{\KFLT at wp}{#1}}
+%    \end{macrocode}
+%
+% \begin{macro}{\KFLT at wp} Storage for the vertical margin offset.
+%    \begin{macrocode}
+\newcommand{\KFLT at wp}{O}
+%    \end{macrocode}
+% \end{macro}
+
+
+
+
+
 % \subsection{Nesting Control}
 
 % \DescribeCounter{KFLT at keyfloatdepth} Depth inside a keyfigs environment
@@ -1882,7 +2052,7 @@
 \newboolean{KFLT at subgrpcont}{}
 %    \end{macrocode}
 %
-% \DescribeKey{cont} Continued float
+% \DescribeKey[subfloat container]{cont} Continued float
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{cont}[true]{%
 \setboolean{KFLT at subgrpcont}{#1}%
@@ -1900,19 +2070,19 @@
 \newboolean{KFLT at subgrpcstar}
 %    \end{macrocode}
 %
-% \DescribeKey{c} Caption
+% \DescribeKey[subfloat container]{c} Caption
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{c}
 	{\renewcommand{\KFLT at subgrpc}{#1}\setboolean{KFLT at subgrpcstar}{false}}
 %    \end{macrocode}
 %
-% \DescribeKey{cstar} Starred caption?
+% \DescribeKey[subfloat container]{cstar} Starred caption?
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{cstar}
 	{\renewcommand{\KFLT at subgrpc}{#1}\setboolean{KFLT at subgrpcstar}{true}}
 %    \end{macrocode}
 %
-% \DescribeKey{sc} Short caption
+% \DescribeKey[subfloat container]{sc} Short caption
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{sc}{%
 \renewcommand{\KFLT at subgrpsc}{#1}%
@@ -1964,7 +2134,7 @@
 % \end{macro}
 %
 %
-% \DescribeKey{l} Label
+% \DescribeKey[subfloat container]{l} Label
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{l}{\renewcommand{\KFLT at subgrpl}{#1}}
 \newcommand*{\KFLT at subgrpl}{}
@@ -1989,7 +2159,7 @@
 % \end{macro}
 %
 %
-% \DescribeKey{t} Additional text — full justification
+% \DescribeKey[subfloat container]{t} Additional text — full justification
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{t}{
 \renewcommand{\KFLT at subgrpt}{#1}
@@ -1998,7 +2168,7 @@
 }
 %    \end{macrocode}
 %
-% \DescribeKey{t} Additional text — center justification
+% \DescribeKey[subfloat container]{t} Additional text — center justification
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{tc}{
 \renewcommand{\KFLT at subgrpt}{#1}
@@ -2007,7 +2177,7 @@
 }
 %    \end{macrocode}
 %
-% \DescribeKey{t} Additional text — aligned left
+% \DescribeKey[subfloat container]{t} Additional text — aligned left
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{tl}{
 \renewcommand{\KFLT at subgrpt}{#1}
@@ -2016,7 +2186,7 @@
 }
 %    \end{macrocode}
 %
-% \DescribeKey{t} Additional text — aligned right
+% \DescribeKey[subfloat container]{t} Additional text — aligned right
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{tr}{
 \renewcommand{\KFLT at subgrpt}{#1}
@@ -2029,7 +2199,7 @@
 %
 % For the \pkg{tocdata} package:
 %
-% \DescribeKey{ap} Artist prefix
+% \DescribeKey[subfloat container]{ap} Artist prefix
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{ap}{\renewcommand{\KFLT at subgrpap}{#1}}
 %    \end{macrocode}
@@ -2040,7 +2210,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{af} Artist first name
+% \DescribeKey[subfloat container]{af} Artist first name
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{af}{\renewcommand{\KFLT at subgrpaf}{#1}}
 %    \end{macrocode}
@@ -2051,7 +2221,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{al} Artist last name
+% \DescribeKey[subfloat container]{al} Artist last name
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{al}{\renewcommand{\KFLT at subgrpal}{#1}}
 %    \end{macrocode}
@@ -2062,7 +2232,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \DescribeKey{as} Artist suffix
+% \DescribeKey[subfloat container]{as} Artist suffix
 %    \begin{macrocode}
 \define at key{KFLT at subgrpkeys}{as}{\renewcommand{\KFLT at subgrpas}{#1}}
 %    \end{macrocode}
@@ -2292,8 +2462,6 @@
 \end{minipage}%
 \unskip%
 \end{turn}%
-\par%
-\addvspace{2ex}%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -2530,6 +2698,8 @@
 \setboolean{KFLT at f}{false}%
 \setboolean{KFLT at ft}{false}%
 \renewcommand{\KFLT at stretch}{1}%
+\setlength{\KFLT at mo}{-1.2ex}%
+\renewcommand{\KFLT at wp}{O}%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -2798,7 +2968,7 @@
 %    \begin{macrocode}
 \end{lrbox}%
 \KFLT at frame{\usebox{\KFLT at envbox}}%
-\par\addvspace{\medskipamount}%
+\par\addvspace{2ex}%
 }% endkeyboxinner
 %    \end{macrocode}
 % \end{environment}
@@ -2825,12 +2995,13 @@
 % Boxes the contents of figures and floats.
 %
 % Not used by subfigures.
+%
+% \changes{v0.12}{2016/12/03}{[M] and [W] floats.}
 %    \begin{macrocode}
 \NewDocumentEnvironment{KFLT at boxouter}{m m}
-{% keyboxouter
+{% boxouter
 %    \end{macrocode}
-% The \env{keytable} environment boxes the contents inside an optional frame of hrules,
-% then handles them in either of
+% The \env{keytable} environment handles the contents in either of
 % three possible ways, depending on whether it is
 % called alone, inside a \env{keyfloats} environment, or
 % inside a \env{keysubtabs} environment.
@@ -2846,7 +3017,7 @@
 \ifthenelse{\cnttest{\value{KFLT at keyfloatdepth}}>{0}}%
 {% keyfloats
 \minipage{\KFLT at rowboxwidth}%
-\captionsetup{type=\KFLT at type}%
+\captionsetup*{type=\KFLT at type}%
 }% keyfloats
 {% not keyfloats
 %    \end{macrocode}
@@ -2853,6 +3024,42 @@
 %
 % Not a subfloat or \env{keyfloats}, so create a single float.
 %
+% See if the float should [W]rap:
+%    \begin{macrocode}
+\ifthenelse{\equal{#2}{W}}%
+%    \end{macrocode}
+% Place [W], so create a wrapfloat:
+%    \begin{macrocode}
+{% [W]
+%    \end{macrocode}
+% Temporarily figure out \cs{KFLT at imagewidth},
+% 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}%
+%    \end{macrocode}
+% The interior contents default to the full linewidth.
+% This may be changed by a fixed width when
+% \cs{KFLT at findwidths} is about to be done again.
+%    \begin{macrocode}
+\renewcommand{\KFLT at lw}{1}%
+}% [W]
+{% not [W]
+%
+% See if the float should be positioned in the [M]argin:
+%    \begin{macrocode}
+\ifthenelse{\equal{#2}{M}}%
+%    \end{macrocode}
+% Place [M], so create a marginfloat:
+%    \begin{macrocode}
+{% [M]
+\csname margin\KFLT at type\endcsname[\KFLT at mo]%
+\captionsetup{type=\KFLT at type}%
+}% [M]
+{% not [M}
+%
 % See if the float should be positioned [H]ere:
 %    \begin{macrocode}
 \ifthenelse{\equal{#2}{H}}%
@@ -2871,6 +3078,8 @@
 \IfBooleanTF{#1}%
 {\csname \KFLT at type*\endcsname[#2]}{\csname \KFLT at type\endcsname[#2]}%
 }% not [H]
+}% not [M]
+}% not [W]
 }% not keyfloats
 }% not subfloat
 %    \end{macrocode}
@@ -2892,16 +3101,16 @@
 \unskip%
 \minipage{\linewidth}%
 \centering%
-}% keyboxouter
+}% boxouter
 %    \end{macrocode}
 %
-% End of the keyboxouter environment:
+% End of the KFLT at boxouter environment:
 %
 %    \begin{macrocode}
 {% endboxouter
 \endminipage%
 \end{center}%
-\unskip\addvspace{\medskipamount}%
+\unskip\addvspace{2ex}%
 %    \end{macrocode}
 % Optionally print artist's name and additional text:
 %    \begin{macrocode}
@@ -2916,7 +3125,7 @@
 \ifthenelse{\boolean{KFLT at inkeysubfloats}}%
 {\csname endsub\KFLT at type\endcsname}% subfloat
 {% not subfloat
-\ifthenelse{\cnttest{\value{KFLT at keyfloatdepth}}>{0}}% keyfloat?
+\ifthenelse{\cnttest{\value{KFLT at keyfloatdepth}}>{0}}% keyfloats?
 {\endminipage}% keyfloats
 {% not keyfloats
 %    \end{macrocode}
@@ -2924,15 +3133,38 @@
 % Not subfloat or \env{keyfloats}, so is an individual float.
 %
 % Close the minipage or float:
+%
+% See if the float should [W]rap:
 %    \begin{macrocode}
+\ifthenelse{\equal{#2}{W}}%
+%    \end{macrocode}
+% Place [W], so close the wrap float:
+%    \begin{macrocode}
+{% [W]
+\csname endwrap\KFLT at type\endcsname%
+}% [W]
+{% not[W]
+%
+% See if the float should be positioned in the [M]argin:
+%    \begin{macrocode}
+\ifthenelse{\equal{#2}{M}}%
+%    \end{macrocode}
+% Place [M], so close the marginfloat:
+%    \begin{macrocode}
+{% [M]
+\csname endmargin\KFLT at type\endcsname%
+}% [M]
+{% not [M]
 \ifthenelse{\equal{#2}{H}}%
 {%
 \endminipage% [H]
 }%
 {% not [H]
-\IfBooleanTF{#1}% starred table?
+\IfBooleanTF{#1}% starred float?
 {\csname end\KFLT at type*\endcsname}{\csname end\KFLT at type\endcsname}%
 }% not [H]
+}% not [M]
+}% not [W]
 }% not keyfloats
 }% not subfloat
 }% endkeyboxouter
@@ -2959,7 +3191,7 @@
 % \end{environment}
 
 % Extra code to track rows outside of the \env{keyfigure} environment,
-% \DescribeSimple{Before \env{keyfigure}}
+% \DescribeObject{Before \env{keyfigure}}
 % before it starts.  This is done to allow nesting without losing track
 % of the prior level.
 %
@@ -2977,6 +3209,8 @@
 % 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.}
 %    \begin{macrocode}
 \NewDocumentCommand{\keyfig}{s O{tbp} +m m}
 {%
@@ -2986,9 +3220,11 @@
 % After setting default values, overridge with the filename:
 %    \begin{macrocode}
 \renewcommand{\KFLT at i}{#4}%
+\begingroup%
 \KFLT at boxouter{#1}{#2}%
 \KFLT at onefigureimage%
 \endKFLT at boxouter%
+\endgroup%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3002,16 +3238,20 @@
 % A user-level macro to generate a figure with arbitrary paragraph contents.
 % 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}
 \NewDocumentCommand{\keyfigbox}{s O{tbp} +m +m}
 {%
 \KFLT at trackrows%
 \KFLT at boxkeys{#3}{figure}{lof}%
+\begingroup%
 \KFLT at boxouter{#1}{#2}%
 \KFLT at boxinner%
 #4%
 \endKFLT at boxinner%
 \endKFLT at boxouter%
+\endgroup%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3026,6 +3266,8 @@
 % This is equal to a \cs{keyfigbox} with |cstar={}|.
 % 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}
 \NewDocumentCommand{\keyparbox}{s O{tbp} +m +m}
 {%
@@ -3039,11 +3281,13 @@
 %    \end{macrocode}
 % Continue like \cs{figbox}:
 %    \begin{macrocode}
+\begingroup%
 \KFLT at boxouter{#1}{#2}%
 \KFLT at boxinner%
 #4%
 \endKFLT at boxinner%
 \endKFLT at boxouter%
+\endgroup%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3056,11 +3300,14 @@
 % A user-level macro to generate a table with tabular contents.
 % 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}+
 \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%
@@ -3067,6 +3314,7 @@
 #4%
 \endKFLT at boxinner%
 \endKFLT at boxouter%
+\endgroup%
 }
 %    \end{macrocode}
 % \end{macro}
@@ -3091,7 +3339,7 @@
 % \end{environment}
 
 % Extra code to track rows outside of the \env{keytable} environment,
-% \DescribeSimple{Before \env{keytable}}
+% \DescribeObject{Before \env{keytable}}
 % before it starts.  This is done to allow nesting without losing track
 % of the prior level.
 %
@@ -3175,7 +3423,7 @@
 % If inside subfloats, generate subfigures by default:
 %    \begin{macrocode}
 \ifthenelse{\boolean{KFLT at inkeysubfloats}}%
-{}{\captionsetup{type=figure}}%
+{}{\captionsetup*{type=figure}}%
 }% [H] or nested
 %    \end{macrocode}
 % Isn't [H] or nested, so create a figure:
@@ -3247,7 +3495,7 @@
 
 
 % Extra code to track rows outside of the \env{keyfloats} environment,
-% \DescribeSimple{Before \env{keyfloats}}
+% \DescribeObject{Before \env{keyfloats}}
 % before it starts.  This is done to allow nesting without losing track
 % of the prior level.
 %
@@ -3270,7 +3518,7 @@
 %    \end{macrocode}
 
 
-% \subsection{Subfigures}
+% \subsection{Subfloats}
 
 % \begin{macro}{\KFLT at subgrpdefaults} Sets defaults before reading the keys.
 %    \begin{macrocode}
@@ -3338,7 +3586,7 @@
 %    \end{macrocode}
 % Set the caption type:
 %    \begin{macrocode}
-\captionsetup{type=\KFLT at subgrptype}%
+\captionsetup*{type=\KFLT at subgrptype}%
 %    \end{macrocode}
 % Process continued floats:
 %    \begin{macrocode}
@@ -3468,10 +3716,58 @@
 }
 %    \end{macrocode}
 % \end{environment}
+%
+%
+%
+%
+%
+%
+% \subsection{Margin Floats}
+%
+% \begin{environment}{KFLT at marginfloat} \oarg{offset} \marg{type}
+%    \begin{macrocode}
+\newsavebox{\KFLT at marginfloatbox}
 
+\NewDocumentEnvironment{KFLT at marginfloat}{O{-1.2ex} m}
+{% start
+\FloatBarrier% keep floats in order
+\begin{lrbox}{\KFLT at marginfloatbox}%
+\begin{minipage}{\marginparwidth}%
+\captionsetup{type=#2}%
+\hbox{}\vspace*{#1}%
+\noindent%
+}% start
+{\end{minipage}%
+\end{lrbox}%
+\marginpar{\usebox{\KFLT at marginfloatbox}}%
+}
+%    \end{macrocode}
+% \end{environment}
+%
+%
+% \begin{environment}{marginfigure} \oarg{offset}
+% \changes{v0.12}{2016/12/03}{Added.}
+%    \begin{macrocode}
+\ProvideDocumentEnvironment{marginfigure}{O{-1.2ex}}
+  {\begin{KFLT at marginfloat}[#1]{figure}}
+  {\end{KFLT at marginfloat}}
+%    \end{macrocode}
+% \end{environment}
+%
+%
+% \begin{environment}{margintable} \oarg{offset}
+% \changes{v0.12}{2016/12/03}{Added.}
+%    \begin{macrocode}
+\ProvideDocumentEnvironment{margintable}{O{-1.2ex}}
+  {\begin{KFLT at marginfloat}[#1]{table}}
+  {\end{KFLT at marginfloat}}
+%    \end{macrocode}
+% \end{environment}
 
 
 
+
+
 %
 %
 % \iffalse
@@ -3488,6 +3784,7 @@
 % \renewcommand{\thepart}{}
 % \part{Change History and Index}
 %
+%
 % \Finale
-
+%
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty	2016-12-09 22:52:26 UTC (rev 42661)
+++ trunk/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty	2016-12-09 22:52:39 UTC (rev 42662)
@@ -19,11 +19,12 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{keyfloat}
-    [2016/12/02 v0.11 Key/value interface for floats and the subcaption package.]
+    [2016/12/09 v0.12 Key/value interface for floats and the subcaption package.]
 
 
 
 
+
 \RequirePackage{etoolbox}[2011/01/03]%
 
 \RequirePackage{xparse}
@@ -35,6 +36,8 @@
 \RequirePackage{subcaption}
 \RequirePackage{calc}
 \RequirePackage{rotating}
+\RequirePackage{placeins}
+\RequirePackage{wrapfig}
 
 
 
@@ -84,18 +87,14 @@
 \newcommand*{\KFLT at as}{}
 \newcommand*{\KFLT at textalign}{}
 \newcommand{\KFLT at t}{}
-\@ifpackageloaded{tocdata}
-{}
-{
-\newcommand{\tdtextjustify}{}
-\newcommand{\tdtextcenter}{}
-\newcommand{\tdtextleft}{}
-\newcommand{\tdtextright}{}
-\newcommand{\tdnamejustify}{}
-\newcommand{\tdnamecenter}{}
-\newcommand{\tdnameleft}{}
-\newcommand{\tdnameright}{}
-}
+\providecommand{\tdtextjustify}{}
+\providecommand{\tdtextcenter}{}
+\providecommand{\tdtextleft}{}
+\providecommand{\tdtextright}{}
+\providecommand{\tdnamejustify}{}
+\providecommand{\tdnamecenter}{}
+\providecommand{\tdnameleft}{}
+\providecommand{\tdnameright}{}
 \define at key{KFLT at keys}{t}{
 \renewcommand{\KFLT at t}{#1}
 \renewcommand{\KFLT at textalign}{}
@@ -142,7 +141,13 @@
 \define at key{KFLT at keys}{stretch}{\renewcommand{\KFLT at stretch}{#1}}
 \newcommand*{\KFLT at stretch}{1}
 
+\define at key{KFLT at keys}{mo}{\setlength{\KFLT at mo}{#1}}
+\newlength{\KFLT at mo}
 
+\define at key{KFLT at keys}{wp}{\renewcommand{\KFLT at wp}{#1}}
+\newcommand{\KFLT at wp}{O}
+
+
 \newcounter{KFLT at keyfloatdepth}
 \setcounter{KFLT at keyfloatdepth}{0}
 
@@ -310,8 +315,6 @@
 \end{minipage}%
 \unskip%
 \end{turn}%
-\par%
-\addvspace{2ex}%
 }
 
 \newcommand*{\KFLT at captioniftype}[2]{%
@@ -431,6 +434,8 @@
 \setboolean{KFLT at f}{false}%
 \setboolean{KFLT at ft}{false}%
 \renewcommand{\KFLT at stretch}{1}%
+\setlength{\KFLT at mo}{-1.2ex}%
+\renewcommand{\KFLT at wp}{O}%
 }
 
 
@@ -537,7 +542,7 @@
 \endturn%
 \end{lrbox}%
 \KFLT at frame{\usebox{\KFLT at envbox}}%
-\par\addvspace{\medskipamount}%
+\par\addvspace{2ex}%
 }% endkeyboxinner
 
 \NewDocumentCommand{\KFLT at boxkeys}{+m m m}
@@ -549,7 +554,7 @@
 }
 
 \NewDocumentEnvironment{KFLT at boxouter}{m m}
-{% keyboxouter
+{% boxouter
 \ifthenelse{\boolean{KFLT at inkeysubfloats}}%
 {\csname sub\KFLT at type\endcsname{\KFLT at rowboxwidth}}% subfloat
 {% not subfloat:
@@ -556,9 +561,23 @@
 \ifthenelse{\cnttest{\value{KFLT at keyfloatdepth}}>{0}}%
 {% keyfloats
 \minipage{\KFLT at rowboxwidth}%
-\captionsetup{type=\KFLT at type}%
+\captionsetup*{type=\KFLT at type}%
 }% keyfloats
 {% not keyfloats
+\ifthenelse{\equal{#2}{W}}%
+{% [W]
+\KFLT at findwidths%
+\csname wrap\KFLT at type\endcsname{\KFLT at wp}%
+{\KFLT at imagewidth+2\KFLTlooseframewidth}%
+\renewcommand{\KFLT at lw}{1}%
+}% [W]
+{% not [W]
+\ifthenelse{\equal{#2}{M}}%
+{% [M]
+\csname margin\KFLT at type\endcsname[\KFLT at mo]%
+\captionsetup{type=\KFLT at type}%
+}% [M]
+{% not [M}
 \ifthenelse{\equal{#2}{H}}%
 {% [H]
 \noindent\minipage{\linewidth}%
@@ -568,6 +587,8 @@
 \IfBooleanTF{#1}%
 {\csname \KFLT at type*\endcsname[#2]}{\csname \KFLT at type\endcsname[#2]}%
 }% not [H]
+}% not [M]
+}% not [W]
 }% not keyfloats
 }% not subfloat
 \ifthenelse{\boolean{KFLT at cont}}{\ContinuedFloat}{}%
@@ -577,27 +598,39 @@
 \unskip%
 \minipage{\linewidth}%
 \centering%
-}% keyboxouter
+}% boxouter
 {% endboxouter
 \endminipage%
 \end{center}%
-\unskip\addvspace{\medskipamount}%
+\unskip\addvspace{2ex}%
 \KFLT at addartisttext{}%
 \KFLT at captioniftype{figure}{}%
 \ifthenelse{\boolean{KFLT at inkeysubfloats}}%
 {\csname endsub\KFLT at type\endcsname}% subfloat
 {% not subfloat
-\ifthenelse{\cnttest{\value{KFLT at keyfloatdepth}}>{0}}% keyfloat?
+\ifthenelse{\cnttest{\value{KFLT at keyfloatdepth}}>{0}}% keyfloats?
 {\endminipage}% keyfloats
 {% not keyfloats
+\ifthenelse{\equal{#2}{W}}%
+{% [W]
+\csname endwrap\KFLT at type\endcsname%
+}% [W]
+{% not[W]
+\ifthenelse{\equal{#2}{M}}%
+{% [M]
+\csname endmargin\KFLT at type\endcsname%
+}% [M]
+{% not [M]
 \ifthenelse{\equal{#2}{H}}%
 {%
 \endminipage% [H]
 }%
 {% not [H]
-\IfBooleanTF{#1}% starred table?
+\IfBooleanTF{#1}% starred float?
 {\csname end\KFLT at type*\endcsname}{\csname end\KFLT at type\endcsname}%
 }% not [H]
+}% not [M]
+}% not [W]
 }% not keyfloats
 }% not subfloat
 }% endkeyboxouter
@@ -624,9 +657,11 @@
 \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%
 }
 
 
@@ -634,11 +669,13 @@
 {%
 \KFLT at trackrows%
 \KFLT at boxkeys{#3}{figure}{lof}%
+\begingroup%
 \KFLT at boxouter{#1}{#2}%
 \KFLT at boxinner%
 #4%
 \endKFLT at boxinner%
 \endKFLT at boxouter%
+\endgroup%
 }
 
 
@@ -648,11 +685,13 @@
 \KFLT at boxkeys{#3}{figure}{lof}%
 \renewcommand{\KFLT at c}{}%
 \setboolean{KFLT at cstar}{true}%
+\begingroup%
 \KFLT at boxouter{#1}{#2}%
 \KFLT at boxinner%
 #4%
 \endKFLT at boxinner%
 \endKFLT at boxouter%
+\endgroup%
 }
 
 
@@ -660,6 +699,7 @@
 {%
 \KFLT at trackrows%
 \KFLT at boxkeys{#3}{table}{lot}%
+\begingroup%
 \KFLT at boxouter{#1}{#2}%
 \KFLT at boxinner%
 \centering%
@@ -666,6 +706,7 @@
 #4%
 \endKFLT at boxinner%
 \endKFLT at boxouter%
+\endgroup%
 }
 
 
@@ -719,7 +760,7 @@
 {\bigbreak%
 \noindent\begin{minipage}{\linewidth}}%
 \ifthenelse{\boolean{KFLT at inkeysubfloats}}%
-{}{\captionsetup{type=figure}}%
+{}{\captionsetup*{type=figure}}%
 }% [H] or nested
 {% figure
 \IfBooleanTF{#1}% starred figure, two-col figure in a two-col format
@@ -796,7 +837,7 @@
 \IfBooleanTF{#1}%
 {\begin{\KFLT at type*}[#2]}{\begin{\KFLT at type}[#2]}%
 }%
-\captionsetup{type=\KFLT at subgrptype}%
+\captionsetup*{type=\KFLT at subgrptype}%
 \ifthenelse{\boolean{KFLT at subgrpcont}}{\ContinuedFloat}{}%
 \centering%
 \KFLT at captioniftype{table}{subgrp}%
@@ -839,7 +880,27 @@
 {%
 \KFLT at endsubfloats{#1}{#2}%
 }
+\newsavebox{\KFLT at marginfloatbox}
 
+\NewDocumentEnvironment{KFLT at marginfloat}{O{-1.2ex} m}
+{% start
+\FloatBarrier% keep floats in order
+\begin{lrbox}{\KFLT at marginfloatbox}%
+\begin{minipage}{\marginparwidth}%
+\captionsetup{type=#2}%
+\hbox{}\vspace*{#1}%
+\noindent%
+}% start
+{\end{minipage}%
+\end{lrbox}%
+\marginpar{\usebox{\KFLT at marginfloatbox}}%
+}
+\ProvideDocumentEnvironment{marginfigure}{O{-1.2ex}}
+  {\begin{KFLT at marginfloat}[#1]{figure}}
+  {\end{KFLT at marginfloat}}
+\ProvideDocumentEnvironment{margintable}{O{-1.2ex}}
+  {\begin{KFLT at marginfloat}[#1]{table}}
+  {\end{KFLT at marginfloat}}
 
 
 \endinput



More information about the tex-live-commits mailing list