summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-03-22 20:49:29 +0000
committerKarl Berry <karl@freefriends.org>2019-03-22 20:49:29 +0000
commitc683b2e6b6248248b03f94e79edbebec1de2416b (patch)
tree3cb1aa9ea067a4be5304208f37ff35b48615ea33 /Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty
parentb22baef408c481cea9a3570cdc3912c89a1356cd (diff)
keyfloat (22mar19)
git-svn-id: svn://tug.org/texlive/trunk@50534 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty')
-rw-r--r--Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty605
1 files changed, 393 insertions, 212 deletions
diff --git a/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty b/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty
index 4bc84196c9c..0a8b5d6ceef 100644
--- a/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty
+++ b/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty
@@ -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@prohibitpackage}[2]{
+ \KFLT@@prohibitpackage{#1}{#2}
+ \AtBeginDocument{\KFLT@@prohibitpackage{#1}{#2}}
+}
+\KFLT@prohibitpackage{floatrow}{caption and subcaption}
+\KFLT@prohibitpackage{subfig}{subcaption}
+\KFLT@prohibitpackage{subfigure}{subcaption}
+\KFLT@prohibitpackage{subfloat}{subcaption}
+\KFLT@prohibitpackage{float}{newfloat}
+\KFLT@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@sc}{}
\newboolean{KFLT@scgiven}
\newcommand*{\KFLT@type}{}
-\newcommand*{\KFLT@listtype}{}
\define@key{KFLT@keys}{l}{\renewcommand{\KFLT@l}{#1}}
\newcommand*{\KFLT@l}{}
\define@key{KFLT@keys}{ap}{\renewcommand{\KFLT@ap}{#1}}
@@ -97,37 +121,48 @@
\newcommand*{\KFLT@al}{}
\define@key{KFLT@keys}{as}{\renewcommand{\KFLT@as}{#1}}
\newcommand*{\KFLT@as}{}
+\define@key{KFLT@keys}{aup}{\renewcommand{\KFLT@aup}{#1}}
+\newcommand*{\KFLT@aup}{}
+\define@key{KFLT@keys}{auf}{\renewcommand{\KFLT@auf}{#1}}
+\newcommand*{\KFLT@auf}{}
+\define@key{KFLT@keys}{aul}{\renewcommand{\KFLT@aul}{#1}}
+\newcommand*{\KFLT@aul}{}
+\define@key{KFLT@keys}{aus}{\renewcommand{\KFLT@aus}{#1}}
+\newcommand*{\KFLT@aus}{}
\newcommand*{\KFLT@textalign}{}
\newcommand{\KFLT@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@key{KFLT@keys}{t}{%
\renewcommand{\KFLT@t}{#1}%
\renewcommand{\KFLT@textalign}{}%
- \tdtextjustify%
}
\define@key{KFLT@keys}{tc}{%
\renewcommand{\KFLT@t}{#1}%
\renewcommand{\KFLT@textalign}{\centering}%
- \tdtextcenter%
}
\define@key{KFLT@keys}{tr}{%
\renewcommand{\KFLT@t}{#1}%
\renewcommand{\KFLT@textalign}{\raggedleft}%
- \tdtextright%
}
\define@key{KFLT@keys}{tl}{%
\renewcommand{\KFLT@t}{#1}%
\renewcommand{\KFLT@textalign}{\raggedright}%
- \tdtextleft%
}
-\newcommand*{\KFLT@i}{}
\define@key{KFLT@keys}{lw}{%
\renewcommand{\KFLT@lw}{#1}%
\setlength{\KFLT@w}{0pt}%
@@ -195,17 +230,6 @@
\newcommand*{\KFLT@subgrptype}{}
-\newcommand*{\KFLT@subgrplisttype}{}
-
-\newcommand*{\KFLT@setsubgrpfigure}{%
- \renewcommand{\KFLT@subgrptype}{figure}%
- \renewcommand{\KFLT@subgrplisttype}{lof}%
-}
-
-\newcommand*{\KFLT@setsubgrptable}{%
- \renewcommand{\KFLT@subgrptype}{table}%
- \renewcommand{\KFLT@subgrplisttype}{lot}%
-}
\define@key{KFLT@subgrpkeys}{l}{\renewcommand{\KFLT@subgrpl}{#1}}
\newcommand*{\KFLT@subgrpl}{}
\newcommand*{\KFLT@subgrptextalign}{}
@@ -213,22 +237,18 @@
\define@key{KFLT@subgrpkeys}{t}{%
\renewcommand{\KFLT@subgrpt}{#1}%
\renewcommand{\KFLT@subgrptextalign}{}%
- \tdtextjustify%
}
\define@key{KFLT@subgrpkeys}{tc}{%
\renewcommand{\KFLT@subgrpt}{#1}%
\renewcommand{\KFLT@subgrptextalign}{\centering}%
- \tdtextcenter%
}
\define@key{KFLT@subgrpkeys}{tl}{%
\renewcommand{\KFLT@subgrpt}{#1}%
\renewcommand{\KFLT@subgrptextalign}{\raggedright}%
- \tdtextleft%
}
\define@key{KFLT@subgrpkeys}{tr}{%
\renewcommand{\KFLT@subgrpt}{#1}%
\renewcommand{\KFLT@subgrptextalign}{\raggedleft}%
- \tdtextright%
}
\define@key{KFLT@subgrpkeys}{ap}{\renewcommand{\KFLT@subgrpap}{#1}}
\newcommand*{\KFLT@subgrpap}{}
@@ -239,6 +259,15 @@
\define@key{KFLT@subgrpkeys}{as}{\renewcommand{\KFLT@subgrpas}{#1}}
\newcommand*{\KFLT@subgrpas}{}
+\define@key{KFLT@subgrpkeys}{aup}{\renewcommand{\KFLT@subgrpaup}{#1}}
+\newcommand*{\KFLT@subgrpaup}{}
+\define@key{KFLT@subgrpkeys}{auf}{\renewcommand{\KFLT@subgrpauf}{#1}}
+\newcommand*{\KFLT@subgrpauf}{}
+\define@key{KFLT@subgrpkeys}{aul}{\renewcommand{\KFLT@subgrpaul}{#1}}
+\newcommand*{\KFLT@subgrpaul}{}
+\define@key{KFLT@subgrpkeys}{aus}{\renewcommand{\KFLT@subgrpaus}{#1}}
+\newcommand*{\KFLT@subgrpaus}{}
+
\newlength{\KFLT@imagewidth}
@@ -255,8 +284,8 @@
{\setlength{\KFLT@imagewidth}{\KFLT@w}}%
{% width not given
\ifcsempty{\KFLT@lw}%
- {\setlength{\KFLT@imagewidth}{\KFLT@boxwidth}}%
- {\setlength{\KFLT@imagewidth}{\KFLT@lw\KFLT@boxwidth}}%
+ {\setlength{\KFLT@imagewidth}{\KFLT@boxwidth}}%
+ {\setlength{\KFLT@imagewidth}{\KFLT@lw\KFLT@boxwidth}}%
}% width not given
}
\newcommand{\KFLTtightframe}[1]{%
@@ -294,7 +323,7 @@
{}% no frame
}% not looseframe
}
-\NewDocumentCommand{\KFLT@onefigureimage}{}
+\NewDocumentCommand{\KFLT@onefigureimage}{m}%
{%
\begin{lrbox}{\KFLT@envbox}%
\ifdefempty{\KFLT@lw}%
@@ -305,21 +334,21 @@
{% w and h
\includegraphics%
[scale=\KFLT@s,%
- width=\KFLT@imagewidth,height=\KFLT@h]{\KFLT@i}%
+ width=\KFLT@imagewidth,height=\KFLT@h]{#1}%
}% w and h
{% only w
\includegraphics%
- [scale=\KFLT@s,width=\KFLT@imagewidth]{\KFLT@i}%
+ [scale=\KFLT@s,width=\KFLT@imagewidth]{#1}%
}% only w
}% width is given
{% width is not given
\ifdimgreater{\KFLT@h}{0pt}%
- {\includegraphics[scale=\KFLT@s,height=\KFLT@h]{\KFLT@i}}%
- {\includegraphics[scale=\KFLT@s]{\KFLT@i}}%
+ {\includegraphics[scale=\KFLT@s,height=\KFLT@h]{#1}}%
+ {\includegraphics[scale=\KFLT@s]{#1}}%
}% width is not given
}% not linewidth
{% linewidth given
- \includegraphics[scale=\KFLT@s,width=\KFLT@imagewidth]{\KFLT@i}%
+ \includegraphics[scale=\KFLT@s,width=\KFLT@imagewidth]{#1}%
}%
\end{lrbox}%
\unskip%
@@ -330,12 +359,6 @@
\end{turn}%
}
-\newcommand*{\KFLT@captioniftype}[2]{%
- \ifcsstring{KFLT@#2type}{#1}%
- {\KFLT@caption{#2}}%
- {}%
-}
-
\NewDocumentCommand{\KFLT@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@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@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@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@tocdata
}% tocdata loaded
{% no tocdata
@@ -382,11 +432,19 @@
{%
\KFLT@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@docaption
}% no tocdata
@@ -400,24 +458,25 @@
\ifcsempty{KFLT@#1sc}%
{}%
{% non-empty cstar and sc:
- \addcontentsline{\KFLT@listtype}%
- {\csname KFLT@#1type\endcsname}{\KFLT@sc}%
+ \edef\KFLT@listtype{\csuse{KFLT@#1type}}%
+ \addcontentsline{\csuse{ext@\KFLT@listtype}}%
+ {\csuse{KFLT@#1type}}{\KFLT@sc}%
}% non-empty cstar and sc
- \KFLT@docaption*{\csname KFLT@#1c\endcsname}{#1}%
+ \KFLT@docaption*{\csuse{KFLT@#1c}}{#1}%
}%
}% starred caption
{% unstarred caption
\ifcsempty{KFLT@#1sc}%
{% no short cap
- \KFLT@docaption{\csname KFLT@#1c\endcsname}{#1}%
+ \KFLT@docaption{\csuse{KFLT@#1c}}{#1}%
}% no short cap
{% short cap
- \KFLT@docaption[\csname KFLT@#1sc\endcsname]%
- {\csname KFLT@#1c\endcsname}{#1}%
+ \KFLT@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@sc}{}%
\setboolean{KFLT@scgiven}{false}%
\renewcommand{\KFLT@type}{figure}%
- \renewcommand{\KFLT@listtype}{lof}%
\renewcommand{\KFLT@l}{}%
\renewcommand{\KFLT@ap}{}%
\renewcommand{\KFLT@af}{}%
\renewcommand{\KFLT@al}{}%
\renewcommand{\KFLT@as}{}%
+ \renewcommand{\KFLT@aup}{}%
+ \renewcommand{\KFLT@auf}{}%
+ \renewcommand{\KFLT@aul}{}%
+ \renewcommand{\KFLT@aus}{}%
\renewcommand{\KFLT@t}{}%
\renewcommand{\KFLT@textalign}{}%
- \tdtextjustify%
- \renewcommand{\KFLT@i}{}%
\renewcommand{\KFLT@lw}{}%
\setlength{\KFLT@w}{0pt}%
\setlength{\KFLT@h}{0pt}%
@@ -462,18 +522,17 @@
\ifnumless{\value{KFLT@thiscol}}{\value{KFLT@numcols}}%
{}% thiscol < numcols
{% >=
-
- \addvspace{.75\floatsep}
-
+ \par%
+ \addvspace{.75\floatsep}%
\defcounter{KFLT@thiscol}{0}%
}%
}%
-\newcommand{\KFLT@trackrows}
+\newcommand{\KFLT@trackrows}%
{%
\ifboolexpr{%
- test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or
+ test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or%
bool{KFLT@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@addartisttext}[1]
{%
- \ifcsstring{KFLT@#1type}{figure}%
- {% figure
- \ifcsempty{KFLT@#1al}%
- {\KFLT@addtext{#1}}%
- {}% fig w/ artist: text will be added by \captionartist in \KFLT@caption
- }% figure
- {\KFLT@addtext{#1}}%
+ \ifcsempty{KFLT@#1al}% artist last name
+ {%
+ \ifcsempty{KFLT@#1aul}% author last name
+ {\KFLT@addtext{#1}}
+ {}%
+ }%
+ {}% fig w/ artist: text will be added by \captionartist in \KFLT@caption
}% KFLT@addartisttext
}% tocdata loaded
{% tocdata not loaded
+
+\newcommand*{\KFLT@@addartisttext}[3]{%
+ \addvspace{\medskipamount}%
+ \begin{minipage}{\linewidth}%
+ #3%
+ \footnotesize\textsc{%
+ \KFLT@optionalname{\csuse{KFLT@#1a#2p}}%
+ \KFLT@optionalname{\csuse{KFLT@#1a#2f}}%
+ \csuse{KFLT@#1a#2l}%
+ \csuse{KFLT@#1a#2s}%
+ }%
+ \end{minipage}%
+ \par\addvspace{2ex}%
+}
+
\newcommand{\KFLT@addartisttext}[1]
{%
\ifcsempty{KFLT@#1al}%
- {}% last name not given
- {% last name given
- \addvspace{2ex}%
- \begin{minipage}{\linewidth}%
- \centering\footnotesize\textsc{%
- \KFLT@optionalname{\csname KFLT@#1ap\endcsname}%
- \KFLT@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@addtext{#1}%
}% KFLT@addartisttext
}% tocdata not loaded
@@ -560,49 +631,56 @@
\endturn%
\end{lrbox}%
\KFLT@frame{\usebox{\KFLT@envbox}}%
- \par\addvspace{2ex}%
+ \par%
}% endkeyboxinner
-\NewDocumentCommand{\KFLT@boxkeys}{+m m m}
+\NewDocumentCommand{\KFLT@boxkeys}{+m m}
{%
\KFLT@defaults%
\renewcommand{\KFLT@type}{#2}%
- \renewcommand{\KFLT@listtype}{#3}%
\setkeys{KFLT@keys}{#1}%
}
+\newcommand*{\KFLT@LWR@hook@boxouter}{}%
+
+\newenvironment*{KFLT@LWR@hook@boxouter@minipage}[2][]
+ {\minipage[#1]{#2}}
+ {\endminipage}
+
\NewDocumentEnvironment{KFLT@boxouter}{m m}
{% boxouter
\ifbool{KFLT@inkeysubfloats}%
- {\csname sub\KFLT@type\endcsname{\KFLT@rowboxwidth}}% subfloat
+ {\csuse{sub\KFLT@type}{\KFLT@rowboxwidth}}% subfloat
{% not subfloat:
\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}%
{% keyfloats
\ifbool{KFLT@keywrap}%
- {\minipage[t]{\KFLT@rowboxwidth}}%
+ {\KFLT@LWR@hook@boxouter@minipage[t]{\KFLT@rowboxwidth}}%
{\minipage[\KFLT@va]{\KFLT@rowboxwidth}}%
\captionsetup*{type=\KFLT@type}%
}% keyfloats
{% not keyfloats
+ \KFLT@LWR@hook@boxouter%
\ifbool{KFLT@keywrap}%
{%
\par\addvspace{\baselineskip}%
- \noindent\minipage[t]{\linewidth}%
+ \noindent%
+ \KFLT@LWR@hook@boxouter@minipage[t]{\linewidth}%
\captionsetup{type=\KFLT@type}%
}%
{% not a keywrap
\ifstrequal{#2}{W}%
{% [W]
- \KFLT@findwidths%
- \csname wrap\KFLT@type\endcsname{\KFLT@wp}%
- {\KFLT@imagewidth+2\KFLTlooseframewidth}%
- \renewcommand{\KFLT@lw}{}%
- \renewcommand{\KFLT@w}{\KFLT@imagewidth}%
+ \KFLT@findwidths%
+ \wrapfloat{\KFLT@type}{\KFLT@wp}%
+ {\KFLT@imagewidth+2\KFLTlooseframewidth}%
+ \renewcommand{\KFLT@lw}{}%
+ \renewcommand{\KFLT@w}{\KFLT@imagewidth}%
}% [W]
{% not [W]
\ifstrequal{#2}{M}%
{% [M]
- \csname margin\KFLT@type\endcsname[\KFLT@mo]%
+ \KFLT@marginfloat[\KFLT@mo]{\KFLT@type}%
\captionsetup{type=\KFLT@type}%
}% [M]
{% not [M}
@@ -614,8 +692,8 @@
}% [H]
{% not [H]
\IfBooleanTF{#1}%
- {\csname \KFLT@type*\endcsname[#2]}%
- {\csname \KFLT@type\endcsname[#2]}%
+ {\csuse{\KFLT@type*}[#2]}%
+ {\csuse{\KFLT@type}[#2]}%
}% not [H]
}% not [M]
}% not [W]
@@ -624,34 +702,37 @@
}% not subfloat
\ifbool{KFLT@cont}{\ContinuedFloat}{}%
\KFLT@findwidths%
- \KFLT@captioniftype{table}{}%
+ \caption@iftop{\KFLT@caption{}}{}%
\center\unskip%
}% boxouter
{% endboxouter
\endcenter\unskip%
+ \addvspace{\smallskipamount}%
\KFLT@addartisttext{}%
- \KFLT@captioniftype{figure}{}%
+ \caption@iftop{}{\KFLT@caption{}}%
\ifbool{KFLT@inkeysubfloats}%
{%
- \csname endsub\KFLT@type\endcsname%
+ \csuse{endsub\KFLT@type}%
}% subfloat
{% not subfloat
\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}% keyfloats?
- {\endminipage}% keyfloats
+ {%
+ \endminipage%
+ }% keyfloats
{% not keyfloats
\ifbool{KFLT@keywrap}{%
- \endminipage%
+ \endKFLT@LWR@hook@boxouter@minipage%
\par\addvspace{\baselineskip}%
}%
{% not keywrap
\ifstrequal{#2}{W}%
{% [W]
- \csname endwrap\KFLT@type\endcsname%
+ \endwrapfloat%
}% [W]
{% not[W]
\ifstrequal{#2}{M}%
{% [M]
- \csname endmargin\KFLT@type\endcsname%
+ \endKFLT@marginfloat%
}% [M]
{% not [M]
\ifstrequal{#2}{H}%
@@ -661,8 +742,8 @@
}%
{% not [H]
\IfBooleanTF{#1}% starred float?
- {\csname end\KFLT@type*\endcsname}%
- {\csname end\KFLT@type\endcsname}%
+ {\csuse{end\KFLT@type*}}%
+ {\csuse{end\KFLT@type}}%
}% not [H]
}% not [M]
}% not [W]
@@ -671,16 +752,101 @@
}% not subfloat
}% endkeyboxouter
+\newcommand*{\KFLT@@ignorespaces}[1]{%
+ \ifboolexpr{%
+ test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or%
+ bool{KFLT@inkeysubfloats}%
+ }{}{\csuse{#1}}%
+}
-\NewDocumentEnvironment{keyfigure}{s O{tbp} +m}
+\newcommand*{\KFLT@ignorespaces}{%
+ \KFLT@@ignorespaces{ignorespaces}%
+}
+
+\newcommand*{\KFLT@envignorespaces}{%
+ \KFLT@@ignorespaces{ignorespacesafterend}%
+}
+
+\NewDocumentCommand{\KFLT@keyflt}{m m m +m +m}
{%
- \KFLT@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@ignorespaces%
+ \KFLT@trackrows%
+ \KFLT@boxkeys{#4}{#3}%
+ \begingroup%
\KFLT@boxouter{#1}{#2}%
- \KFLT@boxinner%
-}%
+ #5%
+ \endKFLT@boxouter%
+ \endgroup%
+ \KFLT@ignorespaces%
+}
+
+
+\NewDocumentCommand{\keyflt}{s O{tbp} m +m +m}
{%
+ \KFLT@keyflt{#1}{#2}{#3}{#4}{%
+ \KFLT@boxinner%
+ \centering%
+ #5%
+ \endKFLT@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@keyfloatstart}[4]{%
+ \KFLT@envignorespaces%
+ \KFLT@boxkeys{#4}{#3}%
+ \KFLT@boxouter{#1}{#2}%
+ \KFLT@boxinner%
+}
+
+\newcommand{\KFLT@keyfloatend}{%
\endKFLT@boxinner%
\endKFLT@boxouter%
+ \KFLT@envignorespaces%
+}
+
+\NewDocumentEnvironment{keyfloat}{s O{tbp} m +m}
+{%
+ \KFLT@keyfloatstart{#1}{#2}{#3}{#4}%
+}%
+{%
+ \KFLT@keyfloatend%
+}
+
+\BeforeBeginEnvironment{keyfloat}{%
+ \KFLT@trackrows%
+}
+
+
+\NewDocumentEnvironment{keyfigure}{s O{tbp} +m}
+{%
+ \KFLT@keyfloatstart{#1}{#2}{figure}{#3}%
+}%
+{%
+ \KFLT@keyfloatend%
}
\BeforeBeginEnvironment{keyfigure}{%
@@ -690,21 +856,17 @@
\NewDocumentCommand{\keyfig}{s O{tbp} +m m}
{%
- \KFLT@trackrows%
- \KFLT@boxkeys{#3}{figure}{lof}%
- \renewcommand{\KFLT@i}{#4}%
- \begingroup%
- \KFLT@boxouter{#1}{#2}%
- \KFLT@onefigureimage%
- \endKFLT@boxouter%
- \endgroup%
+ \KFLT@keyflt{#1}{#2}{figure}{#3}{%
+ \KFLT@onefigureimage{#4}%
+ }%
}
\NewDocumentCommand{\keyfigbox}{s O{tbp} +m +m}
{%
+ \KFLT@ignorespaces%
\KFLT@trackrows%
- \KFLT@boxkeys{#3}{figure}{lof}%
+ \KFLT@boxkeys{#3}{figure}%
\begingroup%
\KFLT@boxouter{#1}{#2}%
\KFLT@boxinner%
@@ -712,13 +874,15 @@
\endKFLT@boxinner%
\endKFLT@boxouter%
\endgroup%
+ \KFLT@ignorespaces%
}
\NewDocumentCommand{\keyparbox}{s O{tbp} +m +m}
{%
+ \KFLT@ignorespaces%
\KFLT@trackrows%
- \KFLT@boxkeys{#3}{figure}{lof}%
+ \KFLT@boxkeys{#3}{figure}%
\renewcommand{\KFLT@c}{}%
\setboolean{KFLT@cstar}{true}%
\begingroup%
@@ -728,34 +892,26 @@
\endKFLT@boxinner%
\endKFLT@boxouter%
\endgroup%
+ \KFLT@ignorespaces%
}
\NewDocumentCommand{\keytab}{s O{tbp} +m +m}
{%
- \KFLT@trackrows%
- \KFLT@boxkeys{#3}{table}{lot}%
- \begingroup%
- \KFLT@boxouter{#1}{#2}%
- \KFLT@boxinner%
- \centering%
- #4%
- \endKFLT@boxinner%
- \endKFLT@boxouter%
- \endgroup%
+ \IfBooleanTF{#1}{%
+ \keyflt*[#2]{table}{#3}{#4}%
+ }{%
+ \keyflt[#2]{table}{#3}{#4}%
+ }%
}
\NewDocumentEnvironment{keytable}{s O{tbp} +m}
{%
- \KFLT@boxkeys{#3}{table}{lot}%
- \KFLT@boxouter{#1}{#2}%
- \KFLT@boxinner%
- \centering%
+ \KFLT@keyfloatstart{#1}{#2}{table}{#3}%
}%
{%
- \endKFLT@boxinner%
- \endKFLT@boxouter%
+ \KFLT@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@LWR@hook@keyfloats}{}%
+
+\newenvironment*{KFLT@LWR@hook@keyfloatsminipage}[1]
+ {\noindent\minipage{#1}}
+ {\endminipage}%
+
\NewDocumentEnvironment{keyfloats}{s O{tbp} m}
{%
+ \KFLT@envignorespaces%
+ \KFLT@LWR@hook@keyfloats%
\addtocounter{KFLT@keyfloatdepth}{1}%
\ifboolexpr{%
test {\ifstrequal{#2}{H}} or
test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
bool {KFLT@inkeysubfloats} or
- bool {KFLT@keywrap}
+ bool {KFLT@keywrap}%
}%
{% [H] or nested
\ifboolexpr{%
@@ -798,12 +963,11 @@
bool {KFLT@inkeysubfloats}
}%
{%
- \noindent%
- \begin{minipage}{\KFLT@rowboxwidth}%
+ \KFLT@LWR@hook@keyfloatsminipage{\KFLT@rowboxwidth}%
}%
{%
\bigbreak%
- \noindent\begin{minipage}{\linewidth}%
+ \KFLT@LWR@hook@keyfloatsminipage{\linewidth}%
}%
\ifbool{KFLT@inkeysubfloats}%
{}%
@@ -832,30 +996,25 @@
bool {KFLT@keywrap}
}%
{% was [H], etc.
- \end{minipage}%
- \ifboolexpr{%
+ \endKFLT@LWR@hook@keyfloatsminipage%
+ \ifboolexpr{
test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or
bool {KFLT@keywrap}
}%
- {}{\bigbreak}%
+ {}{%
+ \bigbreak%
+ }%
}% was [H], etc.
{% not [H], etc.
\IfBooleanTF{#1}% starred figure?
{\end{figure*}}{\end{figure}}%
}% not [H], etc.
\addtocounter{KFLT@keyfloatdepth}{-1}%
+ \KFLT@envignorespaces%
}
\BeforeBeginEnvironment{keyfloats}{%
- \ifboolexpr{%
- test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or
- bool {KFLT@inkeysubfloats}
- }%
- {\KFLT@maybestartfloatrow}%
- {}%
- \ifnumgreater{\value{KFLT@thiscol}}{1}%
- {\hfill}%
- {}%
+ \KFLT@trackrows%
}
@@ -865,19 +1024,23 @@
\setboolean{KFLT@subgrpcstar}{false}%
\renewcommand{\KFLT@subgrpsc}{}%
\setboolean{KFLT@subgrpscgiven}{false}%
- \KFLT@setsubgrpfigure%
+ \renewcommand{\KFLT@subgrptype}{figure}%
\renewcommand{\KFLT@subgrpl}{}%
\renewcommand{\KFLT@subgrpap}{}%
\renewcommand{\KFLT@subgrpaf}{}%
\renewcommand{\KFLT@subgrpal}{}%
\renewcommand{\KFLT@subgrpas}{}%
+ \renewcommand{\KFLT@subgrpaup}{}%
+ \renewcommand{\KFLT@subgrpauf}{}%
+ \renewcommand{\KFLT@subgrpaul}{}%
+ \renewcommand{\KFLT@subgrpaus}{}%
\renewcommand{\KFLT@subgrpt}{}%
\renewcommand{\KFLT@subgrptextalign}{}%
- \tdtextjustify%
}
\NewDocumentCommand{\KFLT@subfloats}{m m m +m}
{%
+ \KFLT@envignorespaces%
\setkeys{KFLT@subgrpkeys}{#4}%
\setboolean{KFLT@inkeysubfloats}{true}%
\IfBooleanTF{#1}%
@@ -900,7 +1063,7 @@
{\ContinuedFloat}%
{}%
\center\unskip%
- \KFLT@captioniftype{table}{subgrp}%
+ \caption@iftop{\KFLT@caption{subgrp}}{}%
\defcounter{KFLT@numcols}{#3}%
\defcounter{KFLT@thiscol}{0}%
\begingroup%
@@ -908,10 +1071,11 @@
\newcommand*{\KFLT@endsubfloats}[2]{%
\endgroup%
- \unskip\endcenter%
+ \unskip%
+ \endcenter%
\par\addvspace{\bigskipamount}%
\KFLT@addartisttext{subgrp}%
- \KFLT@captioniftype{figure}{subgrp}%
+ \caption@iftop{}{\KFLT@caption{subgrp}}%
\ifboolexpr{%
test {\ifstrequal{#2}{H}} or
bool{KFLT@keywrap}
@@ -923,33 +1087,49 @@
{\end{\KFLT@subgrptype}}%
}% not [H]
\setboolean{KFLT@inkeysubfloats}{false}%
+ \KFLT@envignorespaces%
}
-\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m}
+\newcommand*{\KFLT@LWR@hook@keysubfloats}{}
+
+\NewDocumentEnvironment{KFLT@keysubfloats}{m m m m +m}
{%
\KFLT@nonest%
+ \KFLT@LWR@hook@keysubfloats%
\KFLT@subgrpdefaults%
- \KFLT@subfloats{#1}{#2}{#3}{#4}%
+ \renewcommand{\KFLT@subgrptype}{#3}%
+ \KFLT@subfloats{#1}{#2}{#4}{#5}%
}% the start of the environment
{%
\KFLT@endsubfloats{#1}{#2}%
}
-\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m}
+\NewDocumentEnvironment{keysubfloats}{s O{tbp} m m +m}
{%
- \KFLT@nonest%
- \KFLT@subgrpdefaults%
- \KFLT@setsubgrptable%
- \KFLT@subfloats{#1}{#2}{#3}{#4}%
-}% the start of the environment
+ \KFLT@keysubfloats{#1}{#2}{#3}{#4}{#5}%
+}{%
+ \endKFLT@keysubfloats%
+}
+
+\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m}
{%
- \KFLT@endsubfloats{#1}{#2}%
+ \KFLT@keysubfloats{#1}{#2}{figure}{#3}{#4}%
+}{%
+ \endKFLT@keysubfloats%
+}
+
+\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m}
+{%
+ \KFLT@keysubfloats{#1}{#2}{table}{#3}{#4}%
+}{%
+ \endKFLT@keysubfloats%
}
\newsavebox{\KFLT@marginfloatbox}
\NewDocumentEnvironment{KFLT@marginfloat}{O{-1.2ex} m}
{% start
\FloatBarrier% keep floats in order
+ \KFLT@envignorespaces%
\begin{lrbox}{\KFLT@marginfloatbox}%
\begin{minipage}{\marginparwidth}%
\captionsetup{type=#2}%
@@ -960,6 +1140,7 @@
\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\KFLT@marginfloatbox}}%
+ \KFLT@envignorespaces%
}% end
\ProvideDocumentEnvironment{marginfigure}{O{-1.2ex}}
{\begin{KFLT@marginfloat}[#1]{figure}}