Debian Codegraph @

texmf-dist/source/latex/keyfloat/keyfloat.dtx

raw
1 %
2 % \iffalse meta-comment
3 %
4 % Copyright 2016--2024 Brian Dunn
5 %
6 % This work may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in
10 % http://www.latex-project.org/lppl.txt
11 % and version 1.3 or later is part of all distributions of LaTeX
12 % version 2005/12/01 or later.
13 %
14 % \fi
15
16 %
17 % \iffalse
18 %<package>\NeedsTeXFormat{LaTeX2e}
19 %<package>\ProvidesPackage{keyfloat}
20 %<package> [2024/01/12 v2.09 Key/value interface for floats and subfloats.]
21 %
22 %<*driver>
23 \documentclass{ltxdoc}
24
25 \newcommand*{\mypackagename}{keyfloat}
26 \newcommand{\quicksummary}{Provides a key/value interface for generating floats.}
27
28
29 % \usepackage{lmodern}
30 \usepackage{erewhon}
31 \usepackage{roboto}
32 % \usepackage{sourcesanspro}
33 \usepackage{inconsolata}
34 % \usepackage{libertine}
35 \usepackage[T1]{fontenc}
36 \usepackage[utf8]{inputenc}
37 \usepackage{textcomp} % provides \degree, \textquotesingle, \textmu
38
39
40 \newcommand*{\TakeFourierOrnament}[1]{{%
41 \fontencoding{U}\fontfamily{futs}\selectfont\char#1}}
42
43 \newcommand*{\textwarning}{\TakeFourierOrnament{66}}
44
45 % copy/paste special unicode symbols:
46 \input{glyphtounicode}
47 \pdfglyphtounicode{prime}{2032}% hex
48 \pdfglyphtounicode{diameter}{2300}% diameter
49 \pdfglyphtounicode{warningsign}{26A0}% warning sign
50 \pdfgentounicode=1
51
52 \usepackage{newunicodechar}
53 \newunicodechar{ff}{ff}
54 \newunicodechar{fi}{fi}
55 \newunicodechar{fl}{fl}
56 \newunicodechar{ffi}{ffi}
57 \newunicodechar{ffl}{ffl}
58 % \newunicodechar{°}{\degree}
59 \newunicodechar{ρ}{\ensuremath{\rho}}
60 \newunicodechar{⨯}{\texttimes}
61 \newunicodechar{⁄}{\textfractionsolidus}
62 % \newunicodechar{®}{\textregistered}
63 % \newunicodechar{©}{\textcopyright}
64 \newunicodechar{—}{---}
65 \newunicodechar{–}{--}
66 % \newunicodechar{”}{''}
67 % \newunicodechar{“}{``}
68 % \newunicodechar{§}{\S}
69 % \newunicodechar{¶}{\P}
70 % \newunicodechar{†}{\dag}
71 \newunicodechar{‡}{\ddag}
72 \newunicodechar{⚠}{\textwarning}
73
74 \usepackage{etoolbox}
75
76 \usepackage{xparse}
77
78 \usepackage{metalogox}
79
80 \usepackage{microtype}
81
82
83
84
85
86 \usepackage[svgnames]{xcolor}
87 \definecolor{myurlcolor}{rgb}{0,0,.7}
88 \definecolor{mylinkcolor}{rgb}{.7,0,0}
89 \definecolor{codecolor}{rgb}{0,.4,.2}
90 \definecolor{overviewcolor}{rgb}{0,.2,.4}
91
92
93 \usepackage{graphicx}
94 \graphicspath{{images/}}
95
96 \usepackage{enumitem}
97
98 \usepackage{needspace}
99
100 \usepackage{array}
101 \usepackage{booktabs}
102 \usepackage{threeparttable}
103
104 \usepackage{fancybox}% must be loaded before fancyvrb
105 \usepackage{fancyvrb}
106
107
108 \usepackage{caption}
109 \usepackage{newfloat}
110
111 \captionsetup{labelfont={small,bf},textfont={small,bf}}
112
113 \captionsetup*[figure]{
114 style=default, justification=centering,
115 margin=0pt, parskip=0pt, skip=2ex,
116 labelfont={small,bf},textfont={small,bf}
117 }
118
119 \captionsetup*[table]{
120 style=default, justification=centering,
121 margin=0pt, parskip=0pt, skip=1ex,
122 labelfont={small,bf},textfont={small,bf},
123 position=top
124 }
125
126 \captionsetup*[subfigure]{
127 style=default, justification=centering,
128 margin=0pt, parskip=0pt, skip=2ex,
129 labelfont={small},textfont={small}
130 }
131
132 \captionsetup*[subtable]{
133 style=default, justification=centering,
134 margin=0pt, parskip=0pt, skip=1ex,
135 labelfont={small},textfont={small},
136 position=top
137 }
138
139 \captionsetup*[wrapfigure]{
140 style=default, justification=centering,
141 margin=0pt, parskip=0pt, skip=2ex,
142 labelfont={small,bf},textfont={small,bf}
143 }
144
145 \captionsetup*[wraptable]{
146 style=default, justification=centering,
147 margin=0pt, parskip=0pt, skip=1ex,
148 labelfont={small,bf},textfont={small,bf}
149 }
150
151
152
153 \usepackage{blindtext}
154
155
156
157 \usepackage{tikz}
158 \usetikzlibrary{positioning,fit,backgrounds,calc,shapes.geometric,shadows}
159
160 \usepackage[framemethod=tikz]{mdframed}
161
162 \mdfdefinestyle{boxroundshadow}{linewidth=1pt,innerleftmargin=0in,innerrightmargin=0in,%
163 innertopmargin=0in,innerbottommargin=0in,%
164 align=center,roundcorner=3pt,shadow=true,shadowcolor=black!50,shadowsize=4pt,%
165 leftmargin=0pt,rightmargin=0pt,%
166 frametitlebackgroundcolor=black!15,%
167 skipabove=0ex,skipbelow=0ex,%
168 frametitlerulewidth=1pt,frametitleaboveskip=5pt,%
169 }
170
171 \newmdenv[style=boxroundshadow,align=center]{mdtightframe}
172
173 \newmdenv[style=boxroundshadow,align=center,%
174 innertopmargin=3pt,innerbottommargin=3pt,%
175 innerleftmargin=3pt,innerrightmargin=3pt]{mdlooseframe}
176
177
178 \usepackage[normalem]{ulem}
179
180
181 \usepackage{tocdata}[2019/03/21]% v2.02 or later
182
183 \usepackage{tocloft}
184 \setlength{\cftsubsecnumwidth}{3em}
185 \setlength{\cftsubsubsecindent}{2.8em}
186 \setlength{\cftsubsubsecnumwidth}{4em}
187 \setlength{\cftbeforesubsecskip}{1ex}
188
189 % \usepackage{titletoc}
190
191
192
193 \usepackage{titleps}
194
195 \newpagestyle{pageheadfoot}{
196 \headrule
197 \sethead{\pkg{\mypackagename}}{}{\thepage}
198 % \renewcommand{\makefootrule}{\rule[2.5ex]{\linewidth}{.4pt}}
199 \setfoot{}{}{}
200 }
201
202 \pagestyle{pageheadfoot}
203
204
205 % Indexing, logos, \Describexxxx, etc:
206 \usepackage{dtxdescribe}[2023/01/03]
207
208
209
210 \usepackage{splitidx}
211
212 \newindex[Index of Objects]{idx}
213 \newindex[General Index]{gen}
214 % \newindex[Troubleshooting Index]{trb}
215 \newindex[Index of Indexes]{meta}
216
217 \makeindex
218
219 \newcommand*{\gindex}[1]{\sindex[gen]{#1}\ignorespaces}
220
221 % \trouble[watchout phrase]{index entry}
222 \newcommand*{\trouble}[2][]{%
223 \ifblank{#1}{}{%
224 \watchout[#1]%
225 }%
226 % \sindex[trb]{#2}%
227 \gindex{#2}%
228 \ignorespaces%
229 }
230
231
232
233
234 \newcommand{\testtable}{%
235 \begin{tabular}{cc}%
236 \hline\rule{0pt}{2.7ex}%
237 A & B \\
238 C & D \\
239 \hline
240 \end{tabular}%
241 }
242
243 \newcommand{\testwidetable}{%
244 \begin{tabular}{cccc}%
245 \hline\rule{0pt}{2.7ex}%
246 A & B & C \\
247 D & E & F \\
248 \hline
249 \end{tabular}%
250 }
251
252
253 \newcommand{\mainsubarg}{empty or ``\texttt{subgrp}''}
254 \newcommand{\keyvalsarg}{keys \Slash values}
255
256 \setlength{\floatsep}{5ex plus 1ex minus 1ex}
257 \setlength{\dblfloatsep}{5ex plus 1ex minus 1ex}
258
259
260 \usepackage{\mypackagename}
261
262
263
264 \AtBeginDocument{
265 \hypersetup{%
266 pdfinfo={%
267 Title={The LaTeX \mypackagename\ package},%
268 Author={Brian Dunn},%
269 Subject={A key/value interface for LaTeX floats.},%
270 Keywords={LaTeX, floats, key/val, subcaption, rows}%
271 colorlinks,%
272 linkcolor=mylinkcolor,%
273 urlcolor=myurlcolor,%
274 pageanchor=true,
275 }}
276
277 \pdfstringdefDisableCommands{
278 \def\quad{ }
279 \def\\{ }
280 \def\pkg#1{#1}
281 \def\cs#1{\textbackslash#1}
282 \def\env#1{#1}
283 \def\,{ }
284 \def\prog#1{#1}
285 \def\LuaLaTeX{LuaLaTeX}
286 \def\XeLaTeX{XeLaTeX}
287 \def\TeX{TeX}
288 \def\LaTeX{LaTeX}
289 \def\Dash{ --- }
290 \def\dash{ -- }
291 \def\element#1{#1}
292 \def\attribute#1{#1}
293 }
294 }% AtBeginDocument
295
296 \AddToHook{begindocument/before}{% Before .aux file is loaded.
297 \usepackage{cleveref}% If needed.
298 }
299
300
301
302
303 \setlength{\marginparsep}{1em}
304 \setlength{\marginparpush}{.7ex}
305 \setlength{\IndexMin}{40ex}
306
307 \setcounter{IndexColumns}{2}
308
309 \DisableCrossrefs
310 \CodelineIndex
311 \RecordChanges
312 \begin{document}
313 \DocInput{\mypackagename.dtx}
314 \end{document}
315 %
316 %</driver>
317 %
318 % \fi
319 %
320 % \iffalse
321 %<*package>
322 % \fi
323 %
324
325 % \changes{v0.10}{2016/12/01}{\ 2016/12/01 Initial ver.}
326 % \changes{v0.11}{2016/12/02}{\ 2016/12/02}
327 % \changes{v0.12}{2016/12/09}{\ 2016/12/09}
328 % \changes{v0.12}{2016/12/02}{Docs: Loading keyfloat.}
329 % \changes{v0.12}{2016/12/05}{Docs: Improved index.}
330 % \changes{v0.13}{2017/01/18}{\ 2017/01/18}
331 % \changes{v0.13}{2017/01/12}{Docs: Other Settings.}
332 % \changes{v0.14}{2017/02/09}{\ 2017/02/09}
333 % \changes{v0.15}{2017/05/12}{\ 2017/05/12}
334 % \changes{v1.00}{2019/01/11}{\ 2019/01/11}
335 % \changes{v1.00}{2019/01/08}{Source formatting improvements.}
336 % \changes{v1.00}{2019/01/08}{Docs \PDF\ bookmark improvements.}
337 % \changes{v1.00}{2019/01/08}{Removed spurious spaces.}
338 % \changes{v2.00}{2019/03/21}{\ 2019/03/21}
339 % \changes{v2.00}{2019/03/17}{Added custom float types.}
340 % \changes{v2.00}{2019/03/17}{Added float authors.}
341 % \changes{v2.01}{2019/09/23}{2019/09/23}
342 % \changes{v2.02}{2021/05/28}{2021/05/27}
343 % \changes{v2.03}{2021/05/28}{Fixed \cs{hbadness} w/ \cs{relax}.}
344 % \changes{v2.03}{2021/05/28}{2021/05/28}
345 % \changes{v2.04}{2021/06/08}{2021/06/08}
346 % \changes{v2.05}{2021/06/11}{2021/06/11}
347 % \changes{v2.06}{2021/06/29}{2021/06/29}
348 % \changes{v2.07}{2021/08/30}{Docs: Show macro and environment nesting.}
349 % \changes{v2.07}{2022/01/10}{2022/01/10}
350 % \changes{v2.08}{2023/01/03}{Docs updated for \pkg{dtxdescribe}.}
351 % \changes{v2.08}{2023/01/03}{2023/01/03}
352 % \changes{v2.09}{2024/01/12}{2024/01/12}
353 % \changes{v2.09}{2024/01/12}{Updated contact info.}
354
355
356
357 % \GetFileInfo{\mypackagename.sty}
358 %
359 % \DoNotIndex{\newcommand,\renewcommand,\addtocounter,\begin,\end,\begingroup,\endgroup}
360 % \DoNotIndex{\global,\ifbool,\ifthenelse,\isequivalentto,\let}
361 % \DoNotIndex{\booltrue,\boolfalse}
362 % \expandafter\DoNotIndex\expandafter{\detokenize{\(,\),\,,\\,\#,\$,\%,\^,\_,\~,\ ,\&,\{,\}}}
363 %
364 %
365 % \thispagestyle{empty}
366 % \begin{center}
367 % \vfill
368 % ^^A \includegraphics[width=.3\linewidth]{\mypackagename_logo.pdf}
369 % \vfill
370 % {\Huge The \LaTeX\ \pkg{\mypackagename} Package}
371 % \bigskip
372 %
373 % \fileversion{} --- \filedate
374 %
375 % \bigskip
376 %
377 % {\small\textcopyright{} 2016--2024} Brian Dunn\\ \small \url{https://github.com/bdtc/keyfloat}
378 %
379 % \vspace{.5in}
380 %
381 % {\Large \textup{\quicksummary}}
382 %
383 %
384 % \vfill
385 %
386 %
387 % ^^A % \title{The \pkg{keyfloat} package\thanks{This document
388 % ^^A % corresponds to \pkg{keyfloat}~\fileversion,
389 % ^^A % dated \filedate.}}
390 % ^^A % \author{{\small\textcopyright{} 2016} Brian Dunn\\ \small \url{https://github.com/bdtc/keyfloat}
391 % ^^A % \published{}
392 % ^^A % \subtitle{\textup{Subtitle}}
393 % ^^A %
394 % ^^A % \maketitle
395 %
396 % \vfill
397 %
398 %
399 % \begin{abstract}
400 % \noindent
401 % The \pkg{keyfloat} package provides a key/value user interface for quickly
402 % creating figures with a single image each, figures with arbitrary contents,
403 % tables, subfloats, rows of floats, floats located |[H|]ere,
404 % floats in the |[M]|argin, and floats with text |[W]|rapped around them.
405 %
406 % Key/value combinations may specify a caption and label, a width proportional
407 % to \cs{linewidth}, a fixed width and/or height, rotation, scaling, a
408 % tight or loose frame, an \cs{arraystretch}, a continued float,
409 % additional supplemental text,
410 % and an artist/author's name with automatic index entry.
411 % When used with the \pkg{tocdata} package, the name also appears in the
412 % List of Figures.
413 %
414 % Floats may be moved into or rearranged inside a multi-row environment or subfloats,
415 % and are typeset to fit within the given number of columns,
416 % continuing to additional rows as necessary.
417 % Nested sub-rows may be used to generate layouts such as
418 % two small figures placed vertically next to
419 % one larger figure.
420 %
421 % As an example, a typical command to include a figure with a framed image of half \cs{linewidth}
422 % could be: \\
423 % \hspace*{1em}\verb|\keyfig*[hbp]{f,lw=.5,c={A caption},l={fig:label}}{image}|
424 %
425 % \pkg{keyfloat} uses the \pkg{caption}, \pkg{subcaption},
426 % \pkg{newfloat} or \pkg{float}, and \pkg{wrapfig} packages,
427 % \watchout[incompatible packages]
428 % and cannot be used with the
429 % \pkg{subfig}, \pkg{subfigure}, \pkg{subfloat}, \pkg{floatrow},
430 % or \pkg{floatflt} packages.
431 %
432 % See the \nameref{sec:indexgen} for an index of topics and troubleshooting.
433 % \watchout[Need help?]
434 %
435 % For the latest updates, see \nameref{sec:updates}.
436 % \margintag{What's new?}
437 %
438 % \vfill
439 %
440 % \footnotesize
441 % \begin{description}
442 % \item[License:] \
443 %
444 % This work may be distributed and/or modified under the
445 % conditions of the LaTeX Project Public License, either version 1.3
446 % of this license or (at your option) any later version.
447 % The latest version of this license is in
448 % http://www.latex-project.org/lppl.txt
449 % and version 1.3 or later is part of all distributions of LaTeX
450 % version 2005/12/01 or later.
451 % \end{description}
452 %
453 % \end{abstract}
454 %
455 % \vspace*{\fill}
456 % \vspace*{\fill}
457 % \vspace*{\fill}
458 % \end{center}
459 % \clearpage
460 %
461 % \tableofcontents
462 % \listofdtxexamplefloats
463 % \listoffigures
464 % \listoftables
465 %
466 %
467 % \thispagestyle{pageheadfoot}
468 %
469 % \clearpage
470 %
471 %^^A \part{keyfloat.sty}
472 %
473 % \section{Introduction}
474 %
475 % The \pkg{keyfloat} package simplifies the creation
476 % of \LaTeX\ floats, while still allowing a large number of useful features.
477 %
478 %
479 % \subsection{A problem with floats}
480 %
481 % When including a figure with a graphics image into a document,
482 % the user typically enters something such as:
483 % \begin{sourceverb}
484 % \begin{figure}
485 % \centering
486 % \includegraphics[width=3in]{filename}
487 % \caption{A Figure}
488 % \label{fig:somelabel}
489 % \end{figure}
490 % \end{sourceverb}
491 % \unskip
492 %
493 % When doing that often enough, it makes sense to factor the common code:
494 % \begin{sourceverb}
495 % \onefigure[3in]{filename}{A Figure}{fig:somelabel}
496 % \end{sourceverb}
497 % \unskip
498 %
499 % Expanding the capability of \cs{onefigure} via \pkg{xparse} can lead to the general case of:
500 % \begin{sourceverb}
501 % \onefigure*[loc](width){filename}(add'l text)[shortcap]{caption}*[label]
502 % \end{sourceverb}
503 % \unskip
504 % Attempting to add additional features such as frames and continued floats
505 % hits the limit of nine parameters for a \TeX\ macro,
506 % requiring that new features use some kind of change-state macros instead.
507 % Attempting to support rows of floats or subfloats only makes things more complicated still.
508 %
509 % A key/value system solves the problem of adding more features,
510 % does not require much additional typing, is a more self-documenting
511 % syntax, and allows a shared syntax with subfloats and groups of floats as well.
512 % Thus, the \pkg{keyfloat} package.
513 %
514 % \subsection{The \pkg{keyfloat} package}
515 %
516 % Using \pkg{keyfloat}, the previous example becomes:
517 % \begin{sourceverb}
518 % \keyfig{w=3in,c=A figure,l=fig:somelabel}{filename}
519 % \end{sourceverb}
520 % \unskip
521 %
522 % The \cs{onefigure} general case becomes:
523 % \begin{sourceverb}
524 % \keyfig*[loc]{w=width,t={add'l text},sc=shortcap,cstar=caption,
525 % l=label}{filename}
526 % \end{sourceverb}
527 %
528 %
529 % \subsection{Features}
530 %
531 % The macros and environments provided by \pkg{keyfloat} include:
532 % \begin{description}
533 % \item[\cs{keyfig}:] A figure with an image.
534 % \item[\cs{keytab}:] A table.
535 % \item[\cs{keyflt}:] An arbitrary float type macro.
536 % \item[\cs{keyfigbox}:] A figure with arbitrary contents.
537 % \item[\cs{keyparbox}:] A ``figure'' without a caption, useful
538 % to place uncaptioned text inside a group,
539 % \item[\env{keyfigure}:] A figure environment.
540 % \item[\env{keytable}:] A table environment.
541 % \item[\env{keyfloat}:] An arbitrary float type environment.
542 % \item[\env{keyfloats}:] A group of rows and columns of floats.
543 % \item[\env{keysubfigs}:] A figure containing a group of rows and columns of subfigures.
544 % \item[\env{keysubtabs}:] A table containing a group of rows and columns of subtables.
545 % \item[\env{keysubfloats}:] A float of arbitrary type containing a group of rows and columns of subfloats.
546 % \item[\env{keywrap}:] Wraps a keyfloat around an environment of text. Usable inside a list.
547 % \item[\env{marginfigure}:] A figure environment placed into
548 % the margin.\footnote{\env{marginfigure} and \env{margintable}: The environments
549 % provided by the |tufte-book| class are used if loaded,
550 % otherwise \pkg{keyfloat} provides its own versions.}
551 % \item[\env{margintable}:] A table environment placed in the margin.
552 % \end{description}
553 %
554 % Additional features include:
555 % \begin{itemize}
556 % \item Rows and columns of floats may be generated by placing them inside a \env{keyfloats}
557 % environment.
558 % \item Subfloats may be generated by placing them inside a \env{keysubfigs}
559 % or \env{keysubtabs} environment.
560 % \item Dynamic layout: The number of columns is specified. Extra
561 % floats are placed onto additional rows as needed, with the final row
562 % adjusted to compensate for leftovers.
563 % \item Floats may be placed \optn{[H]}ere.
564 % \item Floats may be placed in the \optn{[M]}argin.
565 % \item Floats may be placed with text \optn{[W]}rapped around them.
566 % \item Floats may be starred to span two columns.
567 % \item Continued floats may be used to repeat the previous float number.
568 % \item A figure may contain an image, with additional sizing, rotation, and a frame.
569 % \item Tables may be stretched. (\cs{arraystretch})
570 % \item Boxes of arbitrary contents may be assigned a width and framed.
571 % \item Floats may be moved into and out of the grouping environments as needed.
572 % \item An artist/author's name may be added to a figure and the index.
573 % \item If the \pkg{tocdata} package is loaded (use v0.12+),
574 % the name is also added to the \acro{LOF}.
575 % \item Additional descriptive text may be added as well.
576 % \item Frames may be customized.
577 % \end{itemize}
578 %
579 % A large number of examples are provided, each showing \LaTeX\ source and
580 % \margintag{examples}
581 % the resulting float.
582 %
583 % A customized index is included at the back of the documentation,
584 % \margintag{index}
585 % including troubleshooting issues.
586 %
587 % Blue margin tags are used to help quickly find information, and often
588 % \margintag{margin tags}
589 % indicate the destination of index entries.
590 %
591 % Several warnings are noted in the text. Watch out for these special cases.
592 % \watchout[warnings]
593 %
594 % ^^A % See the ``troubleshooting'' section of the index for help
595 % ^^A % \margintag{problems}
596 % ^^A % with specific problems which may occur.
597 %
598 % \subsection{Updates}
599 %
600 % \label{sec:updates}
601 %
602 % Recent changes include the following:
603 % \begin{description}
604 % \item[v2.06:] Added shared keys for groups of floats or subfloats.
605 % Added the \optn{kar} key to keep the aspect ratio of an image.
606 % Removed \texttt{:} for an empty caption.
607 % Warns if an image is too wide to fit.
608 % \item[v2.02, v2.04:] Added keys for wrapped floats.
609 % \end{description}
610 %
611 % \subsection{Other float-related packages}
612 %
613 % Several other \LaTeX\ packages related to floats include:
614 % \begin{description}
615 % \item[\pkg{caption} and \pkg{subcaption}:] Improved control over captions.
616 % \item[\pkg{floatrow}:] A macro-based package for creating floats; including captions,
617 % footnotes, and rows of floats.
618 % \item[\pkg{hvfloat}:] A key \Slash value system allowing the easy rotation of
619 % captions and floats.
620 % \item[\pkg{nccfloats}:] Macros for minipage floats and side-by-side floats.
621 % \item[\pkg{newfloat}:] Macros for the creationg of float environments.
622 % \item[\pkg{rotfloat}:] Environments for rotated floats.
623 % \item[\pkg{subfig}:] Macros to add subfloats inside a float.
624 % \end{description}
625 %
626 %
627 % \clearpage
628 %
629 % \section{Using the \pkg{keyfloat} package}
630 %
631 % \subsection{Loading \pkg{keyfloat} and related packages}
632 %
633 % \pkg{keyfloat} is loaded with the usual command:
634 % \begin{sourcedisplay}
635 % \cs{usepackage}\{keyfloat\}
636 % \end{sourcedisplay}
637 %
638 %
639 % If you wish to have artists' names appear in the list of figures,
640 % \DescribePackage{tocdata}%
641 % \DescribePackage{tocloft}%
642 % \DescribePackage{titletoc}%
643 % as provided by the \pkg{tocdata} package,
644 % load \pkg{tocdata},
645 % optionally followed by either \pkg{tocloft} or \pkg{titletoc},
646 % then \pkg{keyfloat}:
647 % \begin{sourcedisplay}
648 % \cs{usepackage}\{tocdata\} \\
649 % \cs{usepackage}\{titletoc\}\% or titletoc, or neither \\
650 % \cs{usepackage}\{keyfloat\}
651 % \end{sourcedisplay}
652 %
653 % To use custom float types with the \pkg{float} package:
654 % \DescribePackage{float}
655 % \begin{sourceverb}
656 % \usepackage{float}
657 % \newfloat{diagram}{htb}{lod}
658 % \end{sourceverb}
659 %
660 % To use custom float types with the \pkg{newfloat} package:
661 % \DescribePackage{newfloat}
662 % \begin{sourceverb}
663 % \usepackage{newfloat}
664 % \DeclareFloatingEnvironment[
665 % fileext={lod},
666 % listname={List of Diagrams},
667 % name={Diagram},
668 % ]{diagram}
669 % \end{sourceverb}
670 %
671 % For the \pkg{caption} package, to have table captions appear above the tables, and
672 % \DescribePackage{caption}
673 % to use custom float types:
674 % \begin{sourceverb}
675 % \usepackage[tableposition=top]{caption}
676 % \captionsetup[diagram]{
677 % style=default, justification=centering,
678 % margin=0pt, parskip=0pt, skip=1ex,
679 % labelfont={small,bf},textfont={small,bf}
680 % }
681 % \end{sourceverb}
682 %
683 % To use custom float and subfloat types with \pkg{cleveref}:
684 % \DescribePackage{cleveref}
685 % \begin{sourceverb}
686 % \usepackage{cleveref}
687 % \crefname{diagram}{diagram}{diagrams}
688 % \crefname{subdiagram}{subdiagram}{subdiagrams}
689 % \end{sourceverb}
690 %
691 %
692 % \needspace{7\baselineskip}
693 % \subsection{Macros and environments}
694 %
695 % \DescribeMacro{\keyfig} * \oarg{loc} \marg{\keyvalsarg} \marg{image filename} \\
696 % A macro to generate a figure with an image from a file.
697 %
698 % \DescribeMacro{\keytab} * \oarg{loc} \marg{\keyvalsarg} \marg{tabular contents} \\
699 % A macro to generate a table with tabular contents.
700 % Usually use the \env{keytable} environment instead.
701 %
702 % \DescribeMacro{\keyflt} * \oarg{loc} \marg{float type} \marg{keys/values} \marg{contents} \\
703 % A macro to generate an arbitrary float type with its contents.
704 %
705 % \DescribeMacro{\keyfigbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents} \\
706 % A macro to generate a figure with arbitrary paragraph contents.
707 % See \cref{ex:keyfigbox}.
708 %
709 % \DescribeMacro{\keyparbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents} \\
710 % A macro to generate a figure with arbitrary paragraph contents,
711 % but no number or caption. This is equal to a \cs{keyfigbox} with |cstar={}|.
712 % Mostly useful to add supplemental information inside a row of floats or subfloats.
713 % See \cref{ex:keyparbox}.
714 %
715 % \DescribeEnv{keyfigure} * \oarg{loc} \marg{\keyvalsarg} \\
716 % An environment to generate a figure with arbitrary contents.
717 % Useful for multi-paragraph contents.
718 % See \cref{ex:keyfigure}.
719 %
720 % \DescribeEnv{keytable} * \oarg{loc} \marg{\keyvalsarg} \\
721 % An environment to generate a table with arbitrary contents.
722 % Useful for larger tables.
723 % See \cref{ex:keytable}.
724 %
725 % \DescribeEnv{keyfloat} * \oarg{loc} \marg{float type} \marg{\keyvalsarg} \\
726 % An environment to generate an arbitrary float type with its contents.
727 % Useful for multi-paragraph contents.
728 %
729 % \begin{docsidebar}
730 % \textbf{The above macros and environments may be used by themselves,
731 % or inside the following \env{keyfloats}, \env{keysubfigs}, or
732 % \env{keysubtabs} environments.}
733 % \end{docsidebar}
734 %
735 %
736 % \DescribeEnv{keyfloats} * \oarg{loc} \marg{num columns} \oarg{shared \keyvalsarg} \\
737 % A group of figures or tables typeset in rows. May be nested, [H], [W], or [M].
738 % The optional shared \keyvalsarg\ are passed to each object within.
739 % See \cref{ex:keyfloats}.
740 %
741 % \DescribeEnv{keysubfigs} * \oarg{loc} \marg{numcols} \marg{keys} \oarg{shared \keyvalsarg} \\
742 % A group of subfigures typeset in rows.
743 % May \emph{not} be nested. May be [H], [W], or [M].
744 % The optional shared \keyvalsarg\ are passed to each object within.
745 % See \cref{ex:keysubfigs}.
746 %
747 % \needspace{2\baselineskip}
748 % \DescribeEnv{keysubtabs} * \oarg{loc} \marg{numcols} \marg{keys} \oarg{shared \keyvalsarg} \\
749 % A group of subtables typeset in rows.
750 % May \emph{not} be nested. May be [H], [W], or [M].
751 % The optional shared \keyvalsarg\ are passed to each object within.
752 % See \cref{ex:keysubtabs}.
753 %
754 % \needspace{2\baselineskip}
755 % \DescribeEnv{keysubfloats} * \oarg{loc} \marg{float type} \marg{numcols} \marg{keys} \oarg{shared \keyvalsarg} \\
756 % A group of subfloats typeset in rows.
757 % May \emph{not} be nested. May be [H], [W], or [M].
758 % The optional shared \keyvalsarg\ are passed to each object within.
759 %
760 % \DescribeEnv{keywrap} \marg{width of keyfloat} \marg{keyfloat} \\
761 % Displays a keyfloat next to an environment of text.
762 % Two minipages are used side-by-side, which allows its use inside a list item
763 % where [W] will not work, but extra empty vertical space
764 % \watchout[empty space]
765 % will appear if the keyfloat and the text are of unequal vertical size.
766 % \meta{keyfloat} may be any of \cs{keyfig}, \env{keyfigure},
767 % \env{keyfloats}, \env{keysubfigs}, etc., each with its proper arguments.
768 % See \cref{ex:keywrapkeyfig}.
769 %
770 % \DescribeEnv{marginfigure} \oarg{offset} \\
771 % A figure placed into the margin, with an optional vertical offset.
772 % \cs{keyfloat} uses the version provided by the |tufte-book| class if available,
773 % or provides its own version otherwise.
774 % See \cref{ex:marginfigure}.
775 %
776 % \DescribeEnv{margintable} \oarg{offset} \\
777 % A table placed into the margin, with an optional vertical offset.
778 % \cs{keyfloat} uses the version provided by the |tufte-book| class if available,
779 % or provides its own version otherwise.
780 % See \cref{ex:margintable}.
781 %
782 % \medskip\hrule\medskip
783 %
784 % \DescribeArgument{*}
785 % The star option create floats which span both columns in a two-column
786 % document.
787 %
788 % \DescribeArgument{{[H]}}
789 % The |[H]| location forces a figure to be ``Here'', in the
790 % form of a minipage instead of a float. A caption, label, etc.\ may
791 % still be assigned.
792 %
793 % \DescribeArgument{{[M]}}
794 % The |[M]| location places the float into the margin. When the |tufte-book| class
795 % is used, its \env{marginfigure} and \env{margintable} environments are used,
796 % otherwise \pkg{keyfloat} provides and uses its own versions of the same environments.
797 % See \cref{ex:keyfigm,ex:keytablem}.
798 %
799 % \DescribeArgument{{[W]}}\DescribePackage{wrapfig}
800 % The |[W]| location wraps text around the float. Use this just before the start of
801 % a paragraph with contents large enough to wrap around the float. Do not use this
802 % inside a list environment. Select placement with the |wp| key; see
803 % the \pkg{wrapfig} package documentation for more information.
804 % Use \optn{w} or \optn{lw} to set the width of the item \Slash image contained
805 % inside the wrap area. By default the caption will also be contained in this width.
806 % To use a larger width for the overall container and caption,
807 % set \optn{w} or \optn{lw} for the size of the image, and also use
808 % \optn{ww} or \optn{wlw} for a larger size for the caption.
809 % Watch the log for warnings from \pkg{wrapfig}.\watchout[\pkg{wrapfig} warnings]
810 %
811 % \DescribeArgument{{[loc]}}
812 % The star and [loc] options are ignored for floats inside a \env{keyfloats},
813 % \env{keysubfigs}, or \env{keysubtabs} environment. Note that these
814 % container environments may have their own star and [loc] options.
815 %
816 %
817 % \clearpage
818 %
819 %
820 %
821 %
822 % \subsection{Keys and values}
823 %
824 % \changes{v2.05}{2021/06/11}{Docs: Fixed braces for multi-word values.}
825 %
826 % \newcommand{\largebullet}{{\Large\textbullet}}
827 %
828 % \begin{keytable}[bp]{c={Keys and values — part I},l={tab:keyvals},stretch=1.5}
829 % \centering
830 % \gindex{keys>and values}
831 % \begin{threeparttable}
832 % \small
833 % \begin{tabular}{>{\ttfamily}cc>{\raggedright}p{2.5in}>{\centering\arraybackslash}>{\ttfamily\arraybackslash}p{1in}}
834 % \toprule
835 % \textrm{Key} & Sub\tnote{a} & Description & \textrm{Example} \\
836 % \midrule
837 % c & \largebullet & An unstarred caption.
838 % If empty, creates a figure with a number but no caption. & c=\{A caption\} \\
839 % cstar & \largebullet & A starred caption. Creates a float without a number.
840 % If empty, creates a figure with no number or caption. & cstar=\{No Num\} \\
841 % sc & \largebullet & The short caption for the \acro{LOF}/\acro{LOT}, even if cstar. & sc=\{Short cap\} \\
842 % cont & \largebullet & Continued float? & cont \\
843 % l & \largebullet & The label. Enclose in braces if a comma is included.
844 % Ignored in unnumbered floats. & l=fig:alabel \\
845 % ap, aup & \largebullet & Artist/author's prefix, such as ``Mr.''\,\tnote{b} & ap=Mr. \\
846 % af, auf & \largebullet & Artist/author's first name.\tnote{b} & af=First \\
847 % al, aul & \largebullet & Artist/author's last name.\tnote{b} & al=Last \\
848 % as, aus & \largebullet & Artist/author's suffix, such as |~III|.\tnote{b} & |al=~III| \\
849 % t & \largebullet & Additional text. May include paragraphs. \\
850 % Enclose in braces if a comma is included.
851 % May need \cs{protect} before macro calls.
852 % Fully-justified alignment.
853 % & t=\{Paragraphs\} \\
854 % tc & \largebullet & Additional text, aligned to the center. & tc=\{Paragraphs\} \\
855 % tl & \largebullet & Additional text, aligned to the left. & tl=\{Paragraphs\} \\
856 % tr & \largebullet & Additional text, aligned to the right. & tr=\{Paragraphs\} \\
857 % \bottomrule
858 % \end{tabular}
859 % \begin{tablenotes}
860 % \item[a:] All the keys in Part I may be used with the main keys of the
861 % \env{keysubfigs}, \env{keysubtabs}, and \env{keysubfloats} environments.
862 % \item[b:] Artist \Slash author keys:
863 % |al| is an artist's last name, |aul| is an author's last name, etc.
864 % Artists names are printed centered, authors are flush right.
865 % A fixed-width non-breakable space is placed between parts of names, except that
866 % the optional suffix is connected directly to the last name, allowing
867 % ``|as={, Title}|'', for example.
868 % \end{tablenotes}
869 % \smallskip
870 % \hrule\medskip\centering
871 % {\footnotesize \dots\ continued}
872 % \end{threeparttable}
873 % \end{keytable}
874
875
876 % \changes{v2.05}{2021/06/11}{Docs: Fixed \optn{r} key.}
877
878 % \begin{keytable}{
879 % c={Keys and values — part II},cont,stretch=1.5}
880 % \centering
881 % \gindex{keys>and values}
882 % \begin{threeparttable}
883 % \small
884 % \begin{tabular}{>{\ttfamily}cc>{\raggedright}p{2.5in}>{\centering\arraybackslash}>{\ttfamily\arraybackslash}p{1in}}
885 % \toprule
886 % \textrm{Key} & Sub\tnote{c} & Description & \textrm{Example} \\
887 % \midrule
888 % lw & --- & Set the width to a fraction of \cs{linewidth}. Cancels |w|.
889 % If a non-image float, sets the width of the text box.
890 % For wrapped objects, may be used with \optn{wlw} for a smaller item
891 % with a larger caption.
892 % & lw=.5 \\
893 % w & --- & Set the actual width. Cancels |lw|.
894 % If a non-image float, sets the width of the text box.
895 % For wrapped objects, may be used with \optn{ww} for a smaller item
896 % with a larger caption.
897 % & w=2in \\
898 % h & --- & Set the actual height. Images only. & w=2in \\
899 % kar & --- & Keep aspect ratio: Use with \optn{w} or \optn{lw}, along with \optn{h},
900 % to fit an image into a given area. Images only. & kar \\
901 % s & --- & Set the image scale. Images only. & s=3 \\
902 % r & --- & Set the rotation angle; counter-clockwise degrees. & r=90 \\
903 % f & --- & Selects a loose frame with the current \cs{fboxsep}.
904 % Only rotated with \cs{keyfig}. & f \\
905 % ft & --- & Selects a tight frame with no \cs{fboxsep}. Useful for photographs,
906 % or diagrams which already have some margin built in. & ft \\
907 % stretch & --- & Sets \cs{arraystretch} inside the float. & stretch=1.5 \\
908 % mo & --- & Sets the vertical offset for a margin float. & mo=-1.2ex \\
909 % wn & --- & Sets the number of lines for a wrapped float. & wn=2 \\
910 % wp & --- & Sets the wrap placement for a wrapped float. The default
911 % is |O|, which places the wrapped float at the outside edge of the text.
912 % See \cref{tab:wrapplacement}.
913 % & wp=I \\
914 % wo & --- & Sets the wrap overhang for a wrapped float. & wo=8em \\
915 % wlw & --- & Sets the total width of the wrapped item to a fraction of \cs{linewidth}.
916 % May be more than the \optn{w} or \optn{lw} width. & wlw=.6 \\
917 % ww & --- & Sets the total width of the wrapped item.
918 % May be more than the \optn{w} or \optn{lw} width. & ww=2in \\
919 % va & --- & Sets the vertical alignment of the outermost minipage container for the keyfloat.
920 % Defaults to 'c'. Ignored by \env{subfigure}, \env{subtable}.
921 % & va=t \\
922 % \bottomrule
923 % \end{tabular}
924 % \begin{tablenotes}
925 % \item[c:] None of the keys in Part II are used in the main keys of the
926 % \env{keysubfigs}, \env{keysubtabs}, or \env{keysubfloats} environments,
927 % but may be used in the optional shared keys to be passed to each object within.
928 % \end{tablenotes}
929 % \end{threeparttable}
930 % \end{keytable}
931 %
932 % \Cref{tab:keyvals} shows the key/value combinations which are allowed.
933 % In most cases these may be used in any order and any combination,
934 % except for the following:
935 %
936 % The keys labeled "Sub"\margintag{subfloat keys}
937 % \gindex{subfloat>keys}\gindex{keys>subfloats}
938 % may be used for the \env{keysubfigs} and
939 % \env{keysubtabs} environments, which group a number of subfloats together under
940 % one master float. The master float has its own caption, label, and text, and
941 % each subfloat inside the group likewise has its own set of keys.
942 %
943 % \env{keyfloats} does not accept any keys at all.\margintag{keyfloats keys}
944 % \gindex{keyfloats>keys}\gindex{keys>keyfloats}
945 %
946 % The ``artist'' keys |ap|, |af|, |al|, and |as| are only used by figures.
947 %
948 % The |stretch| key increases space between tabular elements.
949 %
950 % The rest of the macros
951 % and environments accept all of the keys, as they each create an individual
952 % float or subfloat, and each may have its own assigned dimensions and frame.
953 %
954 % \Cref{tab:captions} shows the combinations of the caption-related keys
955 % \margintag{short/long\\caption combinations}
956 % |c|, |cstar|, and |sc|, and how they control the caption numbering and
957 % entries in the \acro{LOF}/\acro{LOT}.
958 %
959 %
960 % \begin{keytable}{c={Caption-related key combinations},l=tab:captions,stretch=1.5}
961 % \gindex{caption>options}
962 % \centering
963 % \begin{threeparttable}
964 % \small
965 % \begin{tabular}{ccccc}
966 % \toprule
967 % \multicolumn{3}{c}{\bfseries Keys in Use} & \multicolumn{2}{c}{\bfseries Type of} \\
968 % \cmidrule(r){1-3}\cmidrule(l){4-5}
969 % |c| & |cstar| & |sc| & \textbf{Caption}\tnote{a} & \textbf{\LOF\Slash\LOT}\tnote{b} \\
970 % \cmidrule(r){1-3} \cmidrule(l){4-5}
971 % \largebullet & — & — & Numbered & Caption \\
972 % \largebullet & — & \largebullet & Numbered & Short Caption \\
973 % \midrule
974 % — & \largebullet & — & Unnumbered & None \\
975 % — & \largebullet & \largebullet & Unnumbered & Short Caption \\
976 % \midrule
977 % — & |cstar={}| & Ignored & None & None \\
978 % \bottomrule
979 % \end{tabular}
980 % \begin{tablenotes}
981 % \item[a:] Caption: Shows whether the float will
982 % be numbered, unnumbered, or have no caption.
983 % \item[b:] \LOF\Slash\LOT: Shows whether the regular or short caption
984 % will appear in the List of Figures or List of Tables, or if there will be no listing.
985 % \end{tablenotes}
986 % \end{threeparttable}
987 % \end{keytable}
988 %
989 %
990 % \Cref{tab:wrapplacement} shows the wrapped-float placement
991 % \margintag{wrapped float placement}
992 % options for the |wp| key
993 % for floats placed |[W]|.
994 %
995 % \begin{keytable}{c={Key \optn{wp}: Wrapped float placement options},l=tab:wrapplacement}
996 % \gindex{float>wrapped placement}\gindex{wrapped float placement}
997 % \centering
998 % \begin{tabular}{ccl}
999 % \toprule
1000 % \multicolumn{2}{c}{Key} & Location \\
1001 % \cmidrule(r){1-2}\cmidrule{3-3}
1002 % r & R & to the right of the text body \\
1003 % l & L & to the left of the text body \\
1004 % i & I & to the inside margin \\
1005 % o & O & to the outside margin \\
1006 % \bottomrule
1007 % \end{tabular}
1008 %
1009 % \raggedright\small
1010 % The un-capitalized key attempts to place the float ``here'', and
1011 % the capitalized key allows \LaTeX\ to try to find the best location.
1012 % The default is |O|.
1013 % \end{keytable}
1014 %
1015 %
1016 % \clearpage
1017 %
1018 % \subsection{Other settings}
1019 %
1020 % \DescribeMacro{\KFLTtightframe} \marg{contents} Frames the contents without separation.
1021 %
1022 % \DescribeMacro{\KFLTlooseframe} \marg{contents} Frames the contents with separation.
1023 %
1024 % These may be used to re-define how contents are framed. The default
1025 % is a simple \cs{fbox}.
1026 %
1027 % \DescribeLength{\KFLTtightframewidth} Combined width of the frame and separation
1028 % for each of tight and loose frames. These settings should be adjusted when
1029 % changing the frame width and/or separation. The value should be equivalent
1030 % to \cs{fboxwidth} plus \cs{fboxsep}.
1031 % \DescribeLength{\KFLTlooseframewidth}
1032 %
1033 % \DescribeLength{\KFLTimageboxwidth} The computed width of the image.
1034 % Useful to enclose an mdframed environment to restrict its width.
1035 % See \cref{ex:customframe}.
1036 %
1037 %
1038 %
1039 %
1040 % \clearpage
1041 %
1042 % \subsection{Examples}
1043 %
1044 %
1045 % \subsubsection{Single floats}
1046 %
1047 %
1048 % \begin{dtxexample}[\Cref{fig:simple}]{Figure with an image from a file}
1049 % \keyfig{c=A \cs{keyfig} with an image,l=fig:simple}{image}
1050 % \end{dtxexample}
1051 %
1052 % This float (\cref{fig:simple}) is shown at its natural size
1053 % \margintag{natural size}
1054 % because no width or height modifiers were specified. When used alone like this,
1055 % a regular float is created.
1056 % \gindex{image>natural size}
1057 %
1058 %
1059 % \begin{dtxexample}[\Cref{fig:figbox}]{Figure with arbitrary contents\label{ex:keyfigbox}}
1060 % \keyfigbox{f,c={A \cs{keyfigbox}},l=fig:figbox}
1061 % {Some text. More text. \par Another paragraph.}
1062 % \end{dtxexample}
1063 %
1064 % The \cs{keyfigbox} creates a figure with a box of arbitrary contents, instead of
1065 % an image from a file. Its default width is the full \cs{linewidth},\margintag{default width}
1066 % \gindex{float>default width}
1067 % unless |w| or |lw| keys are used.
1068 %
1069 %
1070 % \begin{dtxexample}[\Cref{fig:environment}]
1071 % {Figure environment with arbitrary contents\label{ex:keyfigure}}
1072 % \begin{keyfigure}{f,c={A \env{keyfigure} environment},
1073 % l=fig:environment}
1074 % Arbitrary contents may go here.
1075 %
1076 % Including multiple paragraphs.
1077 % \end{keyfigure}
1078 % \end{dtxexample}
1079 %
1080 % The \env{keyfigure} environment is preferred over the \cs{keyfigbox} macro when
1081 % multiple lines of contents are to be included.
1082 %
1083 % \begin{dtxexample}[\Cref{tab:simpletable}]{Table macro}
1084 % \keytab{c=A \cs{keytab} table,l=tab:simpletable}{\testtable}
1085 % \end{dtxexample}
1086 %
1087 % Do not try to use tables which overflow the page.
1088 %
1089 % For anything other than a simple table, use the \env{keytable} environment.
1090 % See \cref{ex:keytable}.
1091 %
1092 % For large tables, use the \pkg{longtable} or \pkg{supertabular} packages.
1093 % \margintag{large tables}
1094 % \trouble{table>large}
1095 %
1096 %
1097 % \begin{dtxexample}[\Cref{tab:environment}]
1098 % {Table environment with arbitrary contents\label{ex:keytable}}
1099 % \begin{keytable}{f,c={A \env{keytable} environment},
1100 % l=tab:environment}
1101 % Arbitrary contents may go here.\footnote{A footnote.}
1102 %
1103 % \testtable
1104 % \end{keytable}
1105 % \end{dtxexample}
1106 %
1107 % The \env{keytable} environment is preferred over the \cs{keytab} macro
1108 % since most tables are multi-line creations.
1109 %
1110 % \cs{keytab} centers the table, but \env{keytable} does not.
1111 % Add \cs{centering} if desired.
1112 %
1113 % \clearpage
1114 %
1115 % \begin{dtxexample}[\Cref{fig:options}]{Figure with many options selected}
1116 % \keyfig{
1117 % w=2in,ft,r=15,
1118 % c=A figure with many options,
1119 % sc=A figure with options,
1120 % t={Additional text. Multiple paragraphs may be used.
1121 % The entire text is enclosed in braces because a comma
1122 % is included. Alignment may be set by using
1123 % tags \optn{tc}, \optn{tl}, or \optn{tr}
1124 % instead of \optn{t}},
1125 % l=fig:options
1126 % }{image}
1127 % \end{dtxexample}
1128 %
1129 % \gindex{text>added}
1130 % \gindex{float>text added}
1131 %
1132 % Width is fixed at 2\,in, a tight frame is specified (\cs{fboxsep} of 0\,pt),
1133 % a short caption appears in the List of Figures, and the additional text
1134 % is using the default fully-justified alignment.
1135 %
1136 % Since \cref{fig:options} is a float, it may appear on the following page.
1137 %
1138 %
1139 % \clearpage
1140 %
1141 % \begin{dtxexample}[\Cref{fig:linewidth}]{Using \cs{linewidth}}
1142 % \keyfig{lw=.5,c=Half of \cs{linewidth},l=fig:linewidth}{image}
1143 % \end{dtxexample}
1144 %
1145 % \Cref{fig:linewidth} is half of \cs{linewidth} in size.
1146 % \margintag{\cs{linewidth}}
1147 % \gindex{image>linewidth=\cs{linewidth}}\gindex{linewidth=\cs{linewidth}}
1148 % \gindex{subfloat>\cs{linewidth}}\gindex{keyfloats>\cs{linewidth}}
1149 % When the |lw| key is used inside a \env{keyfloats} or \env{keysubfigs} environment,
1150 % the \cs{linewidth} will be proportional to the sub-box for each element.
1151 % When used alone, such as here, the \cs{linewidth} is the full width of the text on
1152 % this page.
1153 %
1154 % |lw| and |w| are not used at the same time.
1155 % If both |lw| and |w| are specified, the last one cancels any previous ones.
1156 %
1157 %
1158 % \clearpage
1159 %
1160 % \begin{dtxexample}[\Cref%
1161 % {fig:looseframe,fig:tightframe,tab:looseframe,tab:tightframe}%
1162 % ]{Using frames}
1163 % \begin{keyfloats}[hbp]{4}
1164 % \keyfig{f,c=Loosely-framed figure,l=fig:looseframe}{image}
1165 % \keyfig{ft,c=Tightly-framed figure,l=fig:tightframe}{image}
1166 % \keytab{f,c=Loosely-framed table,l=tab:looseframe}{\testtable}
1167 % \keytab{ft,c=Tightly-framed table,l=tab:tightframe}{\testtable}
1168 % \end{keyfloats}
1169 % \end{dtxexample}
1170 %
1171 % The |f| key adds a loose frame with the current \cs{fboxsep}.
1172 % This is desirable in most cases.
1173 %
1174 % The |tf| key adds a tight frame with no separation.
1175 % This is useful for framing a photograph, or a diagram which already has a margin.
1176 %
1177 % Framing tables is seldom recommended. In the case of the tight frame, \cref{tab:tightframe},
1178 % note that the external frame almost overwrites the table's natural horizontal rules.
1179 %
1180 % Also see \cref{sec:customframes} for customizing frames.
1181 % \margintag{custom frames}
1182 %
1183 %
1184 % \clearpage
1185 %
1186 % \begin{dtxexample}[\Cref{tab:rotated}]{Using rotation with boxes}
1187 % \keytab{f,w=.8in,c={Table, rotated},
1188 % r=70,l=tab:rotated,
1189 % tc=(Framed to show box width.)}
1190 % {\testwidetable}
1191 % \end{dtxexample}
1192 %
1193 % Unless a width is given, a box is the full \cs{linewidth}.
1194 % \margintag{rotated whitespace}
1195 % When rotated, this extra horizontal space is rotated into extra vertical space.
1196 % \gindex{rotate>box width and vertical space}\gindex{linewidth=\cs{linewidth}>with rotation}
1197 % \trouble{rotate>extra space}
1198 % To avoid this extra space, set a |w| or |lw| to be wide enough
1199 % \watchout[box width]
1200 % for the table or other contents,
1201 % but not much wider. When this box is rotated, it will not take much more
1202 % vertical space than necessary.
1203 %
1204 % Unlike an image, the frame of a box does not rotate with its contents.
1205 % \margintag{frame rotation}\gindex{frame>rotation}
1206 % \trouble{rotate>frame}
1207 %
1208 % \clearpage
1209 %
1210 % \begin{dtxexample}[\Cref{tab:here}, \Cref{fig:here}]{Located [H]ere}
1211 % \keytab[H]{c={A table [H]},l=tab:here}{\testtable}
1212 % \keyfig[H]{f,w=1in,c={A keyfig [H]},l=fig:here}{image}
1213 % \end{dtxexample}
1214 %
1215 % \gindex{h=[H]ere placement}
1216 % \gindex{float>h=[H]ere placement}
1217 % \gindex{float>inline}
1218 % \Cref{tab:here} and \Cref{fig:here} are to be placed ``[H]ere'', and therefore may appear
1219 % \watchout[Out of sequence]
1220 % out-of-sequence with surrounding figures.
1221 % \trouble{float>out of sequence}
1222 % Place a \cs{clearpage} before or after to re-sync, if necessary.
1223 %
1224 %
1225 % \clearpage
1226 %
1227 % \begin{dtxexample}[See fig: ``A starred caption''.]{Unnumbered float}
1228 % \keyfig[H]{f,cstar={A starred caption}}{image}
1229 % \end{dtxexample}
1230 %
1231 % \gindex{float>unnumbered}
1232 %
1233 % A starred caption creates a float without a number, and without
1234 % an entry in the List of Figures unless there is a non-empty short caption.
1235 % (See the next example.)
1236 %
1237 % Labels cannot be used when there is no number for a float.
1238 % \trouble[No label]{label>missing}
1239 % \trouble{label>unnumbered float}
1240 % \trouble{float>unnumbered>no label}
1241 %
1242 % \begin{dtxexample}
1243 % [See fig: ``Starred caption with a short caption''.]
1244 % {Unnumbered float with a \acro{LOF} entry}
1245 % \keyfig{
1246 % f,cstar={Starred caption with a short caption.},
1247 % sc={Starred short caption}
1248 % }{image}
1249 % \end{dtxexample}
1250 %
1251 % A starred caption with a non-empty short caption creates an
1252 % unnumbered entry in the List of Figures.
1253 %
1254 %
1255 % \clearpage
1256 %
1257 % \begin{dtxexample}
1258 % [See fig: ``Optional text which is not a caption.'']
1259 % {An unnumbered in-text image}
1260 % \keyfig[H]{f,cstar={},
1261 % tc={Optional text which is not a caption.}
1262 % }{image2}
1263 % \end{dtxexample}
1264 %
1265 % \gindex{float>inline without caption}
1266 %
1267 % By using [H] and |cstar={}|, the image is placed inline
1268 % without a number or \acro{LOF} entry.
1269 %
1270 % Also see \cref{ex:keyparbox}.
1271 %
1272 %
1273 % \clearpage
1274 %
1275 % \begin{dtxexample}[\Cref{fig:nexttoparbox}, and the box to its left.]
1276 % {A box without a caption.\label{ex:keyparbox}}
1277 % \begin{keyfloats}{2}
1278 % \keyparbox{
1279 % f,lw=.5,
1280 % tc={A \cs{keyparbox} with no number or label.}
1281 % }{Some contents.}
1282 % \keyfig{c=Next to a \cs{keyparbox},l=fig:nexttoparbox}{image}
1283 % \end{keyfloats}
1284 % \keyparbox[H]{f,lw=.5}{A \cs{keyparbox} [H], outside the keyfloats.}
1285 % \end{dtxexample}
1286 %
1287 % \gindex{float>without caption}
1288 %
1289 % A \cs{keyparbox} is a \cs{keyfigbox} with |cstar={}|,
1290 % and is mostly useful as an information box inside a row or a set of subfloats.
1291 %
1292 %
1293 %
1294 %
1295 % \clearpage
1296 %
1297 % \subsubsection{Groups of floats, shared keys, keep aspect ratio}
1298 %
1299 % \begin{dtxexample}[\Cref{fig:firstinrow} to \Cref{tab:seventhinrow}]{Groups of figures — \env{keyfloats} environment\label{ex:keyfloats}}
1300 % \begin{keyfloats}{2}
1301 % \keyfig{lw=1,c={First in a group},
1302 % l=fig:firstinrow,tl={\cs{raggedright} text}
1303 % }{image}
1304 % \keyparbox{}{\centering A \cs{keyparbox} describing something.
1305 % \par With several paragraphs.}
1306 % \begin{keyfloats}{2}[f,lw=1,h=3em,kar,va=t]
1307 % \keyfig{lw=1,c={Third in a group},
1308 % l=fig:thirdinarow}{image}
1309 % \keyfig{lw=1,c={Fourth in a group, with a longer caption}}{image2}
1310 % \keyfig{lw=1,c={Fifth in a group}}{image}
1311 % \keyfig{lw=1,c={Sixth in a group},
1312 % l=fig:sixthinarow}{image2}
1313 % \end{keyfloats}
1314 % \keytab{c={Seventh in a group},l=tab:seventhinrow}{\testwidetable}
1315 % \end{keyfloats}
1316 % \end{dtxexample}
1317 %
1318 %
1319 % The \env{keyfloats} environment takes an argument for the number of columns.
1320 % Additional floats
1321 % \margintag{automatic layout}
1322 % are automatically placed on following rows.
1323 % Changing the number of columns will cause the floats to automatically readjust as
1324 % necessary. Leftovers will be centered on the last row.
1325 % An optional argument
1326 % \margintag{shared keys}
1327 % \gindex{group>shared keys}
1328 % \gindex{float>shared keys}
1329 % \gindex{keys>shared in a group}
1330 % may contain keys and values which are passed to each object
1331 % inside the group.
1332 %
1333 % \Cref{fig:firstinrow} to \cref{tab:seventhinrow} are in a \env{keyfloats} environment.
1334 % Furthermore,
1335 % \margintag{nested groups}
1336 % \Crefrange{fig:thirdinarow}{fig:sixthinarow} are in an
1337 % additional nested \env{keyfloats} environment, forming a small box of floats inside
1338 % the larger group.
1339 % In this subgroup, shared keys are set so that each image is framed
1340 % and keeps its aspect ratio while being resized to fit a fixed width and height.
1341 %
1342 % Note that \cs{linewidth} is adjusted for each row and nested row,
1343 % \watchout[\cs{linewidth}]
1344 % so the |lw| key may need to be changed if a float is moved to a different nesting level.
1345 % \trouble{linewidth=\cs{linewidth}}\gindex{linewidth=\cs{linewidth}>subfloats}
1346 % \gindex{subfloat>\cs{linewidth}}
1347 %
1348 % Fixed-width or fixed-height floats may be too large to fit
1349 % \watchout[image too large]
1350 % if they are moved into a group. A warning is issued if so.
1351 % It is the user's responsibility to adjust |w|, |h|, or |lw| as necessary.
1352 % \trouble{image>too large}
1353 % To allow images to automatically adjust, use |lw=1| or less, which adjusts
1354 % to the \cs{linewidth}.
1355 %
1356 % Keyfloats may be located
1357 % \margintag{location}
1358 % [H], [M], or located [W] set with half the line width:\\
1359 % \hspace*{2em}|\begin{keyfloats}[H]{2}| \dots
1360 %
1361 % Keyfloats may be starred
1362 % \margintag{two columns}
1363 % to span both columns in a two-column format: \\
1364 % \hspace*{2em}|\begin{keyfloats}*{2}| \dots
1365 %
1366 % As shown in the sub group above,
1367 % \margintag{grid of images}
1368 % \gindex{group>nested}
1369 % \gindex{float>nested group}
1370 % \gindex{image>grid of}
1371 % \gindex{image>keep aspect ratio}
1372 % \gindex{aspect ratio}
1373 % \gindex{keep aspect ratio}
1374 % to display a group of images of varying shape inside a grid, use the shared option to
1375 % select a maximum size, keep aspect ratio, and align at the top so that captions
1376 % of varying length may wrap below each image:
1377 % \begin{sourceverb}
1378 % \begin{keyfloats}{2}[lw=1,h=3em,kar,va=t]
1379 % ...
1380 % \end{keyfloats}
1381 % \end{sourceverb}
1382 %
1383 %
1384 % \clearpage
1385 %
1386 % \subsubsection{Subfloats}
1387 %
1388 % \begin{dtxexample}[\Cref{fig:subfigs}]{Subfigures — \env{keysubfigs} environment\label{ex:keysubfigs}}
1389 % \begin{keysubfigs}{3}{c=Subfigures,l=fig:subfigs}
1390 % \keyfig{lw=1,f,c={First subfigure},
1391 % l=fig:firstsubfig,t=Some text}{image}
1392 % \keyfig{lw=1,f,r=90,c={Second subfigure},
1393 % l=fig:secondsubfig,
1394 % t=Lots of lots of lots of lots of text.}
1395 % {image2}
1396 % \begin{keyfloats}{1}
1397 % \keyfig{lw=1,f,c={Third subfigure},l=fig:thirdsubfig}{image}
1398 % \keytab{c={Fourth subfigure},l=fig:fourthsubfig}{\testtable}
1399 % \keyfig{lw=.5,f,c={Fifth subfigure},l=fig:fifthsubfig}{image}
1400 % \end{keyfloats}
1401 % \end{keysubfigs}
1402 % \end{dtxexample}
1403 %
1404 % \Crefrange{fig:firstsubfig}{fig:fifthsubfig} are in
1405 % the \cref{fig:subfigs} \env{keysubfigs} environment.
1406 % The \env{keysubtabs} environment is similar.
1407 % Mixed types have the type of their container, as shown with \cref{fig:fourthsubfig}.
1408 %
1409 % Subfloats are associated floats (a, b, \dots) collected together into one common float
1410 % (the enclosing \env{keysubfigs} or \env{keysubtabs} environment).
1411 % The enclosing float can have its own caption (call ``Sub-Figures'' in the example),
1412 % which appears in the \acro{LOF}/\acro{LOT}, and also a label.
1413 % Each subfloat can have its own caption and label as well, but the
1414 % subcaption does not appear in the \acro{LOF}/\acro{LOT}.
1415 %
1416 % All subfloats are forced to have the same type as
1417 % its containing float.\trouble{mixed subfloats}
1418 % \watchout[mixed subfloats]
1419 % A table inside a figure will be labeled as a figure, for example.
1420 % This avoids miss-labeling as each subfloat must clearly be identified
1421 % as a child of its containing float.
1422 %
1423 % \env{keysubfigs} and \env{keysubtabs} may not be used inside\watchout[nested subfloats]
1424 % \trouble{nested subfloats}\gindex{subfloat>nested}
1425 % the \env{keyfloats} environment,
1426 % and cannot be nested inside each other. (No subfloat |12aa|, |12ab|, |12ba|, etc.)
1427 %
1428 % The \env{keyfloats} environment may be used inside \env{keysubfigs} or
1429 % \margintag{nested keyfloats}\gindex{keyfloats>nested}
1430 % \env{keysubtabs} to gather subfloats together, such as the
1431 % three right-most figures in \cref{fig:subfigs}.
1432 %
1433 % Subfloats may be located
1434 % \margintag{location}
1435 % [H], [M], or located [W] set with half the line width: \\
1436 % \hspace*{2em}|\begin{keysubfigs}[H]{3}{|key/vals \dots|}|
1437 %
1438 % Subfloats may be starred
1439 % \margintag{two columns}
1440 % to span both columns in a two-column format: \\
1441 % \hspace*{2em}|\begin{keysubfigs}*{2}{|key/vals \dots|}|
1442 %
1443 % A group of subfloats
1444 % \margintag{shared keys}
1445 % \gindex{group>shared keys}
1446 % \gindex{subfloat>shared keys}
1447 % \gindex{keys>shared in a group}
1448 % may have an optional argument for shared keys and values,
1449 % which are then passed to each subfloat within.
1450 %
1451 % The vertical alignment
1452 % \watchout[va]
1453 % option |va| does not work with subfloats.
1454 %
1455 % \begin{dtxexample}[\Cref{tab:subtabs}]{Subtables [H] — \env{keysubtabs} environment\label{ex:keysubtabs}}
1456 % \begin{keysubtabs}[H]{2}{c=Subtables [H],l=tab:subtabs}
1457 % \keytab{c={First subtable},l=fig:firstsubtab}{\testtable}
1458 % \keytab{c={Second subtable},l=fig:secondsubtab}{\testwidetable}
1459 % \end{keysubtabs}
1460 % \end{dtxexample}
1461 %
1462 %
1463 %
1464 % \clearpage
1465 %
1466 % \subsubsection{Continued floats}
1467 %
1468 % \gindex{float>continued}
1469 % \gindex{continued float}
1470 %
1471 % The |cont| key may be used to generate a ``continued'' float.
1472 % The continued float receives the same number as the previous float,
1473 % and it is assumed that they are the same float, except that
1474 % they are separated for some reason such as size on the page.
1475 %
1476 % The label may be placed in a continued float, and will still
1477 % receive the same float number as the prior non-continued float.
1478 %
1479 % \begin{dtxexample}[\Cref{fig:firstcontinued}]{Continued figure}
1480 % \begin{keyfloats}{2}
1481 % \keyfig{,c=Figure to be continued}{image}
1482 % \keyfig{c={\dots continued},cont,l=fig:firstcontinued}{image2}
1483 % \end{keyfloats}
1484 % \end{dtxexample}
1485 %
1486 %
1487 % \clearpage
1488 % \subsubsection{Continued subfloats}
1489 %
1490 % \gindex{float>subfloat continued}
1491 % \gindex{subfloat>continued}
1492 % \gindex{continued subfloat}
1493 %
1494 % The \env{keysubfigs} and \env{keysubtabs} environments may also
1495 % be given the |cont| key.
1496 % The containing environment's float receives the same number as the previous float
1497 % (presumably another subfloat container).
1498 %
1499 % \begin{dtxexample}[\Cref{fig:continuedfigures}]{Continued subfloats}
1500 % \begin{keysubfigs}{2}{c={A set of figures},l=fig:continuedfigures}
1501 % \keyfig{c={First of a set},l=fig:contfirst}{image}
1502 % \keyfig{c={Second of a set},l=fig:contsecond}{image}
1503 % \end{keysubfigs}
1504 % \begin{keysubfigs}{2}{c={\dots continued},cont}
1505 % \keyfig{c={Third of a set},l=fig:contthird}{image2}
1506 % \keyfig{c={Fourth of a set},l=fig:contfourth}{image2}
1507 % \end{keysubfigs}
1508 % \end{dtxexample}
1509 %
1510 %
1511 % \clearpage
1512 % \subsubsection{Margin floats}
1513 % \changes{v0.12}{2016/12/02}{Docs: Margin float examples.}
1514 %
1515 % \gindex{float>margin placement}
1516 % \gindex{margin placement}
1517 %
1518 % When a keyfloat is located [M], it will be placed in the margin.
1519 %
1520 % \DescribeClass{tufte-book}
1521 % When the |tufte-book| class is used, its \env{marginfigure} or \env{margintable}
1522 % environments will be used, otherwise \pkg{keyfloat} provides environments
1523 % of the same name and uses those instead.
1524 %
1525 % \begin{dtxexample}[\Cref{fig:marginfigure}]{The \env{marginfigure} environment\label{ex:marginfigure}}
1526 % \begin{marginfigure}
1527 % \centering
1528 % \includegraphics[width=.75\linewidth]{image}
1529 %
1530 % Some text added by hand.
1531 % \caption{A \env{marginfigure}}
1532 % \label{fig:marginfigure}
1533 % \end{marginfigure}
1534 % \end{dtxexample}
1535 %
1536 %
1537 % \begin{dtxexample}[\Cref{fig:margintable}]{The \env{margintable} environment\label{ex:margintable}}
1538 % \begin{margintable}
1539 % \centering
1540 % \testwidetable
1541 % \caption{A \env{margintable}}
1542 % \label{fig:margintable}
1543 % \end{margintable}
1544 % \end{dtxexample}
1545 %
1546 %
1547 % \begin{dtxexample}[\Cref{fig:keyfigm}]{Using \cs{keyfig}\optn{[M]}\label{ex:keyfigm}}
1548 % \keyfig[M]{c={A \cs{keyfig}\optn{[M]}},l=fig:keyfigm,ft,
1549 % t=Additional text.
1550 % Text text text text text text.
1551 %
1552 % More paragraphs.
1553 % }{image2}
1554 % \end{dtxexample}
1555 %
1556 %
1557 % \begin{dtxexample}[\Cref{tab:keytablem}]
1558 % {Using \env{keytable}\optn{[M]} and an offset\label{ex:keytablem}}
1559 % \begin{keytable}[M]{c={A \env{keytable}\optn{[M]}},
1560 % l=tab:keytablem,mo=-.9in}
1561 % \centering
1562 % \testwidetable
1563 % \end{keytable}
1564 % \end{dtxexample}
1565 %
1566 % A negative offset was used to shift the table upwards
1567 % \margintag{margin float offset}
1568 % to the top of the example.
1569 %
1570 % To set the minimum-allowed distance between \cs{marginpar}s and margin floats:
1571 % \margintag{distance between floats}
1572 % \gindex{distance between floats}\gindex{float>distance between}
1573 % \begin{sourceverb}
1574 % \setlength{\marginparpush}{3ex}
1575 % \end{sourceverb}
1576 %
1577 %
1578 %
1579 % \clearpage
1580 %
1581 % \subsubsection{Wrapped floats}
1582 % \changes{v0.12}{2016/12/03}{Docs: Wrapped float examples.}
1583 %
1584 % Note: If you see the warning:
1585 % \watchout[\pkg{wrapfig} warning]\gindex{wrapfig=\pkg{wrapfig} collision warning}
1586 % \begin{center}
1587 % |Package wrapfig Warning: Collision between wrapping environments|
1588 % \end{center}
1589 % then \pkg{wrapfig} was not able to wrap the paragraph correctly.
1590 % Try adding \cs{clearpage} or \cs{newpage} before the wrapped object,
1591 % or see the \pkg{needspace} package to automatically insert
1592 % a \cs{newpage} if necessary.
1593 %
1594 % \begin{dtxexample}[\Cref{fig:keyfigw,tab:keytabw}]
1595 % {Using \cs{keyfig}\optn{[W]} and \cs{keytab}\optn{[W]}\label{ex:keyfigw}}
1596 % \keyfig[W]{c={A \cs{keyfig}\optn{[W]}},
1597 % l=fig:keyfigw,ft,lw=.4,wp=I, wo=8em, wn=12,
1598 % t={.4\cs{linewidth} wide, placed \optn{I}.}
1599 % }{image2}
1600 % \blindtext
1601
1602 % \keytab[W]{c={A \cs{keytab}\optn{[W]}},l=tab:keytabw,w=.75in,
1603 % }{\testtable}
1604 % \blindtext
1605 % \end{dtxexample}
1606 %
1607 % \begin{dtxexample}[\Cref{fig:keyfigboxw} and the \cs{keyparbox}.]
1608 % {Using \cs{keyfigbox}\optn{[W]} and \cs{keyparbox}\optn{[W]}\label{ex:keyfigboxw}}
1609 % \keyfigbox[W]{
1610 % c={A \cs{keyfigbox}\optn{[W]}},
1611 % l=fig:keyfigboxw,f,lw=.25,wp=I, wn=7,
1612 % t=Text text text text text text text text text
1613 % }{The contents.}
1614 % \blindtext
1615
1616 % \keyparbox[W]{w=1in}{
1617 % A \cs{keyparbox}[W] and some text.
1618 % No caption or numbering.
1619 % }
1620 % \blindtext
1621 % \end{dtxexample}
1622 %
1623 % \clearpage
1624 %
1625 % \begin{dtxexample}[\Cref{fig:keyfigurew,tab:keytablew}]
1626 % {Using \cs{keyfigure}\optn{[W]} and \cs{keytable}\optn{[W]}\label{ex:keyfiguretablew}}
1627 % \begin{keyfigure}[W]{c={A \cs{keyfigure}\optn{[W]}},
1628 % l=fig:keyfigurew,f,w=1.5in, wo=4em,wn=5}
1629 % This is a keyfigure.
1630 % \end{keyfigure}
1631 % \blindtext
1632 %
1633 % \begin{keytable}[W]{c={A \env{keytable}\optn{[W]}},
1634 % l=tab:keytablew,w=2in,wp=L,
1635 % tc=Placed \optn{L} and 2in wide.}
1636 % \centering
1637 % \testwidetable
1638 % \end{keytable}
1639 % \blindtext
1640 % \end{dtxexample}
1641 %
1642 %
1643 % \clearpage
1644 %
1645 % \begin{dtxexample}[\Cref{fig:keywrapfig}]
1646 % {Using \env{keywrap} with a \cs{keyfig}\label{ex:keywrapkeyfig}}
1647 % \begin{itemize}
1648 % \item First item.
1649 % Several lines of text text text text text
1650 % text text text text text text text text.
1651 % \item \begin{keywrap}{.3\linewidth}{\keyfig{%
1652 % lw=1,c={Keywrap with \cs{keyfig}},l=fig:keywrapfig%
1653 % }{image}}
1654 % Second item.
1655 %
1656 % These paragraphs are inside the \texttt{keywrap}.
1657 % A vertical gap appears below if the text is not enough to
1658 % fill the space next to the \cs{keyfig}.
1659 % \end{keywrap}
1660 % Now outside the \env{keywrap},\margintag{notes}\
1661 % but still in the second item.
1662 % There is no elegant way to place only part of a paragraph
1663 % inside a \env{keywrap}.
1664 % \item Third item.
1665 % \end{itemize}
1666 % \end{dtxexample}
1667 %
1668 % \clearpage
1669 %
1670 % \begin{dtxexample}[\Cref{fig:keyfigwlw,fig:keyfigww}]
1671 % {Using wrap width \optn{ww} and \optn{wlw}\label{ex:keyfigwlw}}
1672 % \keyfig[W]{c={A \cs{keyfig}\optn{[W] with \optn{wlw}}},
1673 % l=fig:keyfigwlw,ft,lw=.15,wlw=.4,wp=I,
1674 % t={.15\cs{linewidth} wide, in a .4\cs{linewidth} box.}
1675 % }{image2}
1676 % \blindtext[1]
1677 %
1678 % \keyfig[W]{c={A \cs{keyfig}\optn{[W] with \optn{ww}}},
1679 % l=fig:keyfigww,ft,w=1cm,ww=3cm,wp=I,
1680 % t={1cm wide, in a 3cm box.}
1681 % }{image2}
1682 % \blindtext[1]
1683 % \end{dtxexample}
1684 %
1685 %
1686 % \clearpage
1687 % \subsubsection{Custom frames}
1688 %
1689 % \begin{dtxexample}[\Cref{fig:customframe,fig:customlooseframe}]
1690 % {Custom frames with \pkg{mdframed}\label{ex:customframe}}
1691 % \renewcommand{\KFLTtightframe}[1]{%
1692 % \begin{minipage}{\KFLTimageboxwidth}
1693 % \begin{mdtightframe}%
1694 % #1
1695 % \end{mdtightframe}%
1696 % \end{minipage}
1697 % }
1698 % \setlength{\KFLTtightframewidth}{1pt}
1699 %
1700 % \renewcommand{\KFLTlooseframe}[1]{%
1701 % \begin{mdlooseframe}[leftmargin=.5in,rightmargin=.5in]%
1702 % #1
1703 % \end{mdlooseframe}%
1704 % }
1705 % \setlength{\KFLTlooseframewidth}{4pt}
1706 %
1707 % \keyfig{ft,c=Custom-framed image,l=fig:customframe,r=90}{image}
1708 % \keyfigbox{f,c=Custom loosely-framed box,
1709 % l=fig:customlooseframe}{A loosely-framed box.}
1710 % \end{dtxexample}
1711 %
1712 % \gindex{frame>mdframed}
1713 % \gindex{mdframed}
1714 %
1715 % \DescribePackage{mdframed}
1716 % \Cref{ex:customframe} shows custom frames
1717 % created with the \pkg{mdframed} package along with \pkg{tikz}.
1718 % Note that \pkg{mdframed} uses the full \cs{linewidth}
1719 % \watchout[\pkg{mdframed} width]
1720 % even if the left/right margins are explicitly set, which
1721 % causes extra vertical space when rotated.
1722 % Because of this, the framed object is enclosed inside a minipage
1723 % whose width is precomputed based on the object itself, then
1724 % set in \cs{KFLTimageboxwidth}. Any shadow may fall outside this
1725 % box.
1726 % \trouble{rotate>extra space}
1727 % \trouble{mdframed}
1728 %
1729 % See \cref{sec:customframes} for more details.
1730 %
1731 % \begin{dtxexample}[\Cref{fig:customshadow,fig:customlooseshadow}]
1732 % {Custom shadows with \pkg{fancybox}\label{ex:customshadow}}
1733 % \renewcommand{\KFLTtightframe}[1]{%
1734 % \setlength{\fboxrule}{.4pt}
1735 % \setlength{\fboxsep}{0pt}
1736 % \setlength{\shadowsize}{2pt}
1737 % \shadowbox{#1}%
1738 % }
1739 % \setlength{\KFLTtightframewidth}{0.4pt}
1740 %
1741 % \renewcommand{\KFLTlooseframe}[1]{%
1742 % \setlength{\fboxrule}{.4pt}
1743 % \setlength{\fboxsep}{3pt}
1744 % \setlength{\shadowsize}{2pt}
1745 % \shadowbox{#1}%
1746 % }
1747 % \setlength{\KFLTlooseframewidth}{3.4pt}
1748 %
1749 % \keyfig{ft,c=Custom shadow,l=fig:customshadow}{image}
1750 % \keyfigbox{f,c=Custom loosely-framed shadow,lw=.5,
1751 % l=fig:customlooseshadow}{A loosely-framed shadow box.}
1752 % \end{dtxexample}
1753 %
1754 % \gindex{fancybox}
1755 % \gindex{frame>fancybox}
1756 %
1757 % \DescribePackage{fancybox}
1758 % \Cref{ex:customshadow} shows custom shadow frames
1759 % created with the \pkg{fancybox} package.
1760 % This combination respects |lw| and |w|.
1761 %
1762 % See \cref{sec:customframes} for more details.
1763 %
1764 %
1765 %
1766 %
1767 %
1768 % \renewcommand{\KFLTtightframe}[1]{%
1769 % \setlength{\fboxsep}{0pt}%
1770 % \setlength{\fboxrule}{.4pt}%
1771 % \fbox{#1}%
1772 % }
1773 % \setlength{\KFLTtightframewidth}{.4pt}
1774 %
1775 % \renewcommand{\KFLTlooseframe}[1]{%
1776 % \setlength{\fboxsep}{3pt}%
1777 % \setlength{\fboxrule}{.4pt}%
1778 % \fbox{#1}%
1779 % }
1780 % \setlength{\KFLTlooseframewidth}{3.4pt}
1781 %
1782 %
1783 %
1784 %
1785 %
1786 % \clearpage
1787 % \subsubsection{Artist's name}
1788 %
1789 % \gindex{author's or artist's name}
1790 % \gindex{name>author or artist}
1791 %
1792 % \begin{dtxexample}[\Cref{fig:artist}]{Artist's name — image}
1793 % \keyfig{ft,ap=Mr.,af=First,al=Last,as={~III},
1794 % tc={\textit{About the illustration.}},
1795 % c=Artist's name — image,l=fig:artist}{image}
1796 % \end{dtxexample}
1797 %
1798 %
1799 % \begin{dtxexample}[\Cref{fig:artistpar}]{Artist's name — arbitrary contents}
1800 % \tdartistright
1801 % \begin{keyfigure}{f,ap=Mr.,al=Last,
1802 % c=Artist's name — arbitrary contents,l=fig:artistpar}
1803 % \centering Some text, a quotation, a TikZ\ diagram —
1804 % anything not an image file.
1805 % \end{keyfigure}
1806 % \tdartistcenter
1807 % \end{dtxexample}
1808 %
1809 % The artist's name and optional prefix/suffix are printed below the figure,
1810 % and an index entry is made for the name in (Last, First) format,
1811 % or (Last) if there is no first name.
1812 % If the \pkg{tocdata} package is loaded, the artist's name is also added to
1813 % the List of Figures, and the \pkg{tocdata} \cs{tdname}\dots\ macros
1814 % may be used to align the name.
1815 %
1816 %
1817 %
1818 % \begin{dtxexample}[\Cref{fig:artistcollection}]{Subfloats with an artist}
1819 % \begin{keysubfigs}{2}{
1820 % c=Artist's collection, l=fig:artistcollection,
1821 % t={Some fully-justified text just for illustrative purposes,
1822 % in case you have use for long explanations.
1823 % This text may be the full \cs{linewidth} in size. \par
1824 % Multiple paragraphs of text are allowed.},
1825 % ap=Prefix,af=First,al=Last,as={, Suffix}
1826 % }
1827 % \keyfig{c=Artist's First Work}{image}
1828 % \keyfig{c=Artist's Second Work,
1829 % tc={Commentary about the work.}}{image2}
1830 % \end{keysubfigs}
1831 % \end{dtxexample}
1832 %
1833 % A group of figures may be placed into a subfloat container,
1834 % which may have its own artist keys and additional text.
1835 % Furthermore, each subfloat inside the collection may also have its
1836 % own artist tags and additional text.
1837 %
1838 %
1839 % \clearpage
1840 %
1841 % \subsection{Customization}
1842 %
1843 % \subsubsection{Custom frames}
1844 % \label{sec:customframes}
1845 %
1846 % \gindex{frame>custom}
1847 %
1848 % There are two user-redefinable framing macros: \\
1849 % \hspace*{2em}\cs{KFLTtightframe} and \cs{KFLTlooseframe}
1850 %
1851 % A float's contents are placed into a box,
1852 % which is passed to either of these two macros
1853 % depending on the key |f| or |tf|.
1854 %
1855 % Each macro takes one argument and frames it.
1856 %
1857 % Each macro has a associated \LaTeX\ lengths: \\
1858 % \hspace*{2em}\cs{KFLTtightframewidth} and \cs{KFLTlooseframewidth}
1859 %
1860 % These lengths must be redefined to the expected
1861 % total frame width, equal to the frame thickness plus
1862 % separation.
1863 %
1864 % The default definitions are:
1865 % \begin{sourceverb}
1866 % \newcommand{\KFLTtightframe}[1]{%
1867 % \setlength{\fboxsep}{0pt}%
1868 % \setlength{\fboxrule}{.4pt}%
1869 % \fbox{#1}%
1870 % }
1871 % \setlength{\KFLTtightframewidth}{.4pt}
1872 %
1873 % \newcommand{\KFLTlooseframe}[1]{%
1874 % \setlength{\fboxsep}{3pt}%
1875 % \setlength{\fboxrule}{.4pt}%
1876 % \fbox{#1}%
1877 % }
1878 % \setlength{\KFLTlooseframewidth}{3.4pt}
1879 % \end{sourceverb}
1880 %
1881 % See \cref{ex:customframe} for an example
1882 % created with the \pkg{mdframed} package,
1883 % and \cref{ex:customshadow} for an example
1884 % created with the \pkg{fancybox} package.
1885 %
1886 %
1887 %
1888 % \subsubsection{Distance between floats and rows}
1889 % \gindex{distance between floats}
1890 % \gindex{subfloat>distance between}
1891 % \gindex{float>distance between}
1892 % \trouble{table>rows too close or far}
1893 % To spread out the distance between floats and/or rows of floats
1894 % \margintag{rows too close/far}
1895 % on a busy page, the following settings may be changed.
1896 % The settings used in this documentation are:
1897 % \begin{sourceverb}
1898 % \setlength{\floatsep}{5ex plus 1ex minus 1ex}
1899 % \setlength{\dblfloatsep}{5ex plus 1ex minus 1ex}
1900 % \end{sourceverb}
1901 %
1902 %
1903 % \subsubsection{Formatting the captions}
1904 %
1905 % ^^A \trouble{caption format}
1906 % To modify the typesetting of the captions, see the \pkg{caption} package.
1907 % \gindex{caption>formatting}
1908 % The settings used in this documentation are:
1909 % \begin{sourceverb}
1910 % % default applied to margin floats:
1911 % \captionsetup{labelfont={small,bf},textfont={small,bf}}
1912 %
1913 % \captionsetup[figure]{
1914 % style=default, justification=centering,
1915 % margin=0pt, parskip=0pt, skip=2ex,
1916 % labelfont={small,bf},textfont={small,bf}
1917 % }
1918 %
1919 % \captionsetup[table]{
1920 % style=default, justification=centering,
1921 % margin=0pt, parskip=0pt, skip=1ex,
1922 % labelfont={small,bf},textfont={small,bf}
1923 % }
1924 %
1925 % \captionsetup[subfigure]{
1926 % style=default, justification=centering,
1927 % margin=0pt, parskip=0pt, skip=2ex,
1928 % labelfont={small},textfont={small}
1929 % }
1930 %
1931 % \captionsetup[subtable]{
1932 % style=default, justification=centering,
1933 % margin=0pt, parskip=0pt, skip=1ex,
1934 % labelfont={small},textfont={small}
1935 % }
1936 % \end{sourceverb}
1937
1938
1939
1940 % \clearpage
1941 %
1942 % ^^A \StopEventually{\PrintChanges\PrintIndex}
1943 %
1944 % \makeatletter
1945 %
1946 % \StopEventually{
1947 % ^^A \part{Change History and Index}
1948 % ^^A \part{Change History}
1949 %
1950 %
1951 % \pagestyle{plain}
1952 %
1953 % ^^A Each index has a prologue which creates its own \part, label,
1954 % ^^A and meta index entry.
1955 % \GlossaryPrologue{
1956 % \part{Change History}
1957 % ^^A \section{Chg Hist}
1958 % \label{sec:changehistory}
1959 % \sindex[meta]{Change History}
1960 % \markboth{{Change History}}{{Change History}}
1961 %
1962 % For the most recent changes, see page \pageref{sec:changesend}.
1963 %
1964 % }
1965 % \PrintChanges
1966 % \phantomsection
1967 % \label{sec:changesend}
1968 %
1969 %
1970 % ^^A The instructions for the Index of Objects:
1971 % \IndexPrologue{
1972 % \clearpage
1973 % \expandafter\part\expandafter{\indexname}
1974 % \label{sec:index\indexshortcut}
1975 % \sindex[meta]{\indexname}
1976 % \markboth{Index of Objects}{Index of Objects}%
1977 %
1978 % This is an index of macros, environments, booleans, counters, lengths,
1979 % packages, classes, options, keys, files, and various other programming objects.
1980 % Each is listed by itself, and also by category.
1981 % In some cases, they are further subdivided by [class].
1982 %
1983 % Numbers written in italic refer to the page
1984 % where the corresponding entry is described;
1985 % numbers underlined refer to the
1986 % \ifcodeline@index
1987 % code line of the
1988 % \fi
1989 % definition.
1990 % ^^A ; numbers in roman refer to the
1991 % ^^A \ifcodeline@index
1992 % ^^A code lines
1993 % ^^A \else
1994 % ^^A pages
1995 % ^^A \fi
1996 % ^^A where the entry is used.
1997 % }
1998 %
1999 % \printindex[idx][Index of Objects]
2000 %
2001 %
2002 % ^^A The instructions for the General Index:
2003 % \IndexPrologue{
2004 % \clearpage
2005 % \expandafter\part\expandafter{\indexname}
2006 % \label{sec:index\indexshortcut}
2007 % \sindex[meta]{\indexname}
2008 %
2009 % ^^A This is an index of instructions and concepts.
2010 % ^^A Look here when wondering how to do something, and
2011 % ^^A check the Troubleshooting Index when something goes wrong.
2012 % This is a general index, including how-to and troubleshooting.
2013 % }
2014 %
2015 % \printindex[gen][General Index]
2016 %
2017 %
2018 % ^^A% The instructions for the Troubleshooting Index:
2019 % ^^A% \IndexPrologue{
2020 % ^^A% \clearpage
2021 % ^^A% \expandafter\part\expandafter{\indexname}
2022 % ^^A% \label{sec:index\indexshortcut}
2023 % ^^A% \sindex[meta]{\indexname}
2024 % ^^A%
2025 % ^^A% This index is a sorted reference of problems and solutions.
2026 % ^^A% In order to make it easier to locate a solution,
2027 % ^^A% the same issue may be addressed by more than one entry.
2028 % ^^A%
2029 % ^^A% Entries with higher page numbers are often duplicates of entries with
2030 % ^^A% lower page numbers, as the same warning may occur within the user manual
2031 % ^^A% and again within the source code for a given package.
2032 % ^^A% }
2033 % ^^A%
2034 % ^^A% \printindex[trb][Troubleshooting Index]
2035 %
2036 %
2037 % ^^A The meta index does not get a meta index entry pointing to itself:
2038 % \IndexPrologue{
2039
2040 % \clearpage
2041 % \expandafter\part\expandafter{\indexname}
2042 % \label{sec:index\indexshortcut}
2043 % }
2044 %
2045 % \printindex[meta][Index of Indexes]
2046 % }
2047 %
2048 % \makeatother
2049 %
2050 %
2051 %
2052 %
2053 % \section{Code}
2054 % ^^A *source
2055 %
2056 %
2057 %
2058 %
2059 % \subsection{Older packages}
2060 %
2061 % Ensure that \pkg{tocdata}, if loaded, is new enough:
2062 % \begin{macrocode}
2063 \@ifpackageloaded{tocdata}{
2064 \@ifpackagelater{tocdata}{2019/03/21}{}{
2065 \PackageError{keyfloat}
2066 {%
2067 The tocdata package is out of date.\MessageBreak
2068 Update to tocdata v2.02 2019/03/21 or later\MessageBreak
2069 to use use this version of keyfloat%
2070 }
2071 {%
2072 Please update the tocdata package. It's worth it!%
2073 }
2074 }
2075 }{}
2076 % \end{macrocode}
2077 %
2078 % \subsection{Prohibited packages}
2079 %
2080 % Prohibits the use of a certain other packages.
2081 %
2082 % \begin{macro}{\KFLT@@prohibitpackage} \marg{packagename}
2083 % \begin{macrocode}
2084 \newcommand*{\KFLT@@prohibitpackage}[2]{%
2085 \@ifpackageloaded{#1}
2086 {
2087 \PackageError{keyfloat}
2088 {%
2089 The keyfloat package conflicts with the #1\MessageBreak
2090 package. Remove #1 to use keyfloat.\MessageBreak
2091 Alternative(s):\MessageBreak
2092 \space\space#2%
2093 }
2094 {%
2095 Keyfloat uses the caption, subcaption, newfloat, and wrapfig packages.%
2096 }
2097 }{}
2098 }
2099 % \end{macrocode}
2100 % \end{macro}
2101 %
2102 %
2103 % \begin{macro}{\KFLT@prohibitpackage} \marg{packagename}
2104 %
2105 % Prohibits the use of another package, both now and also \cs{AtBeginDocument}.
2106 %
2107 % \changes{v2.00}{2019/03/11}{Improved package conflict detection.}
2108 % \begin{macrocode}
2109 \newcommand*{\KFLT@prohibitpackage}[2]{
2110 \KFLT@@prohibitpackage{#1}{#2}
2111 \AtBeginDocument{\KFLT@@prohibitpackage{#1}{#2}}
2112 }
2113 % \end{macrocode}
2114 % \end{macro}
2115 %
2116 %
2117 % The list of prohibited packages:
2118 % \changes{v2.02}{2021/05/18}{Work with \pkg{float}.}
2119 % \begin{macrocode}
2120 \KFLT@prohibitpackage{floatrow}{caption and subcaption}
2121 \KFLT@prohibitpackage{subfig}{subcaption}
2122 \KFLT@prohibitpackage{subfigure}{subcaption}
2123 \KFLT@prohibitpackage{subfloat}{subcaption}
2124 \KFLT@prohibitpackage{floatflt}{wrapfig}
2125 % \end{macrocode}
2126 %
2127 %
2128 %
2129 % \subsection{Required packages}
2130 % \changes{v1.00}{2019/01/08}{Removed \pkg{xifthen} dependency.}
2131 %
2132 % \DescribePackage{etoolbox} v2.6 or later
2133 % for \cs{BeforeBeginEnvironment}, \cs{AfterEndEnvironment}
2134 % \begin{macrocode}
2135 \RequirePackage{etoolbox}[2011/01/03]%
2136 % \end{macrocode}
2137 % \DescribePackage{xparse} Argument processing:
2138 % \begin{macrocode}
2139 \RequirePackage{xparse}
2140 % \end{macrocode}
2141 % \DescribePackage{keyval} Key processing:
2142 % \begin{macrocode}
2143 \RequirePackage{xkeyval}
2144 % \end{macrocode}
2145 % \DescribePackage{graphicx} For \cs{includegraphics} and \pkg{rotating}:
2146 % \begin{macrocode}
2147 \RequirePackage{graphicx}
2148 % \end{macrocode}
2149 % \DescribePackage{caption} Handles all caption-related functions:
2150 % \begin{macrocode}
2151 \RequirePackage{caption}[2010/10/31]% v3.2 to support \phantomcaption
2152 % \end{macrocode}
2153 % \DescribePackage{subcaption} Derived from \pkg{caption}, used to handle subfloats:
2154 % \begin{macrocode}
2155 \RequirePackage{subcaption}
2156 % \end{macrocode}
2157 % \DescribePackage{calc} Used to compute box width minus frame sep and width.
2158 % \begin{macrocode}
2159 \RequirePackage{calc}
2160 % \end{macrocode}
2161 % \DescribePackage{rotating} Provides rotation via the \env{turn} environment:
2162 % \begin{macrocode}
2163 \RequirePackage{rotating}
2164 % \end{macrocode}
2165 % \DescribePackage{placeins} Provides \FloatBarrier to process existing floats before adding new ones.
2166 % \begin{macrocode}
2167 \RequirePackage{placeins}
2168 % \end{macrocode}
2169 % \DescribePackage{wrapfig} Provides figure wrapping code.
2170 % \begin{macrocode}
2171 \RequirePackage{wrapfig}
2172 % \end{macrocode}
2173 %
2174
2175
2176 % \DescribePackage{gettitlestring} Used by \pkg{hyperref} and \pkg{nameref}.
2177 %
2178 % \changes{v0.13}{2017/01/14}{Fix: Expands names in references.}
2179 %
2180 % Expand names used in titles:
2181 % \begin{macrocode}
2182 \PassOptionsToPackage{expand}{gettitlestring}
2183 % \end{macrocode}
2184
2185
2186 % Rows of floats are created by a simple \env{minipage} environment,
2187 % instead of relying on a preexisting package. This proved to be
2188 % advantageous when support was added for multiple rows in one
2189 % environment.
2190 %
2191
2192 % \subsection{In-line figures and tables}
2193
2194 % These macros are commonly used by others.
2195
2196 % \begin{environment}{tablehere} Place a table exactly [H].
2197 %
2198 % \shownesting{\env{tablehere}}
2199 % {\shownesting{\env{minipage}}{Contents}}
2200 %
2201 % \changes{v2.01}{2019/09/11}{Fix: Font and color.}
2202 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
2203 % \begin{macrocode}
2204 \ProvideDocumentEnvironment{tablehere}{}
2205 {%
2206 \vskip\intextsep\noindent%
2207 \minipage{\linewidth}%
2208 \def\@captype{table}%
2209 \normalcolor\reset@font\normalsize%
2210 }%
2211 {\endminipage\vskip\intextsep}%
2212 % \end{macrocode}
2213 % \end{environment}
2214
2215 % \begin{environment}{figurehere} Place a figure exactly [H].
2216 %
2217 % \shownesting{\env{figurehere}}
2218 % {\shownesting{\env{minipage}}{Contents}}
2219 %
2220 % \changes{v2.01}{2019/09/11}{Fix: Font and color.}
2221 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
2222 % \begin{macrocode}
2223 \ProvideDocumentEnvironment{figurehere}{}
2224 {%
2225 \vskip\intextsep\noindent%
2226 \minipage{\linewidth}%
2227 \def\@captype{figure}%
2228 \normalcolor\reset@font\normalsize%
2229 }%
2230 {\endminipage\vskip\intextsep}%
2231 % \end{macrocode}
2232 % \end{environment}
2233
2234
2235
2236 % \subsection{Row counting and control}
2237
2238 % Used to count position and wrap at end of each row.
2239
2240
2241 % \DescribeCounter{KFLT@numcols} Columns per row.
2242 % \begin{macrocode}
2243 \newcounter{KFLT@numcols}
2244 % \end{macrocode}
2245
2246 % \DescribeCounter{KFLT@thiscol} Column currently processing.
2247 % |0| if not yet in a keyfloats or subfloat.
2248 %
2249 % \begin{macrocode}
2250 \newcounter{KFLT@thiscol}
2251 % \end{macrocode}
2252
2253 % \DescribeLength{\KFLT@rowboxwidth} How wide is each box in the row.
2254 % \begin{macrocode}
2255 \newlength{\KFLT@rowboxwidth}
2256 % \end{macrocode}
2257
2258
2259
2260
2261
2262 % \subsection{Float key handling}
2263
2264 % \DescribeBoolean{KFLT@cont} Continued float?
2265 % \begin{macrocode}
2266 \newboolean{KFLT@cont}
2267 % \end{macrocode}
2268 %
2269 % \DescribeKey[main]{cont} Continued float?
2270 %
2271 % \begin{macrocode}
2272 \define@key{KFLT@keys}{cont}[true]{\setboolean{KFLT@cont}{#1}}
2273 % \end{macrocode}
2274 %
2275 % \begin{macro}{\KFLT@c} Caption storage
2276 % \begin{macrocode}
2277 \newcommand{\KFLT@c}{}
2278 % \end{macrocode}
2279 % \end{macro}
2280 %
2281 % \DescribeBoolean{KFLT@cstar} Starred caption?
2282 % \begin{macrocode}
2283 \newboolean{KFLT@cstar}
2284 % \end{macrocode}
2285 %
2286 % \DescribeKey[main]{c} Caption
2287 %
2288 % \begin{macrocode}
2289 \define@key{KFLT@keys}{c}{%
2290 \renewcommand{\KFLT@c}{#1}\setboolean{KFLT@cstar}{false}%
2291 }
2292 % \end{macrocode}
2293 %
2294 % \DescribeKey[main]{cstar} Caption starred?
2295 %
2296 % \begin{macrocode}
2297 \define@key{KFLT@keys}{cstar}{%
2298 \renewcommand{\KFLT@c}{#1}\setboolean{KFLT@cstar}{true}%
2299 }
2300 % \end{macrocode}
2301 %
2302 % \DescribeKey[main]{sc} Short caption
2303 %
2304 % \begin{macrocode}
2305 \define@key{KFLT@keys}{sc}{%
2306 \renewcommand{\KFLT@sc}{#1}%
2307 \setboolean{KFLT@scgiven}{true}%
2308 }
2309 % \end{macrocode}
2310 %
2311 % \begin{macro}{\KFLT@sc} Short caption storage
2312 % \begin{macrocode}
2313 \newcommand{\KFLT@sc}{}
2314 % \end{macrocode}
2315 % \end{macro}
2316 %
2317 % \DescribeBoolean{KFLT@scgiven} Was a short caption given?
2318 % \begin{macrocode}
2319 \newboolean{KFLT@scgiven}
2320 % \end{macrocode}
2321 %
2322 % \begin{macro}{\KFLT@type} Float type: ``|figure|'', ``|table|''
2323 % \begin{macrocode}
2324 \newcommand*{\KFLT@type}{}
2325 % \end{macrocode}
2326 % \end{macro}
2327 %
2328 %
2329 % \DescribeKey[main]{l} Label
2330 % \begin{macrocode}
2331 \define@key{KFLT@keys}{l}{\renewcommand{\KFLT@l}{#1}}
2332 % \end{macrocode}
2333 %
2334 % \begin{macro}{\KFLT@l} Label storage
2335 % \begin{macrocode}
2336 \newcommand*{\KFLT@l}{}
2337 % \end{macrocode}
2338 % \end{macro}
2339 %
2340 %
2341 % For the artist/author keys:
2342 %
2343 % \DescribeKey[main]{ap} Artist prefix
2344 % \begin{macrocode}
2345 \define@key{KFLT@keys}{ap}{\renewcommand{\KFLT@ap}{#1}}
2346 % \end{macrocode}
2347 %
2348 % \begin{macro}{\KFLT@ap} Storage for artist prefix
2349 % \begin{macrocode}
2350 \newcommand*{\KFLT@ap}{}
2351 % \end{macrocode}
2352 % \end{macro}
2353 %
2354 % \DescribeKey[main]{af} Artist first name
2355 % \begin{macrocode}
2356 \define@key{KFLT@keys}{af}{\renewcommand{\KFLT@af}{#1}}
2357 % \end{macrocode}
2358 %
2359 % \begin{macro}{\KFLT@af} Storage for artist first name
2360 % \begin{macrocode}
2361 \newcommand*{\KFLT@af}{}
2362 % \end{macrocode}
2363 % \end{macro}
2364 %
2365 % \DescribeKey[main]{al} Artist last name
2366 % \begin{macrocode}
2367 \define@key{KFLT@keys}{al}{\renewcommand{\KFLT@al}{#1}}
2368 % \end{macrocode}
2369 %
2370 % \begin{macro}{\KFLT@al} Storage for artist last name
2371 % \begin{macrocode}
2372 \newcommand*{\KFLT@al}{}
2373 % \end{macrocode}
2374 % \end{macro}
2375 %
2376 % \DescribeKey[main]{as} Artist suffix
2377 % \begin{macrocode}
2378 \define@key{KFLT@keys}{as}{\renewcommand{\KFLT@as}{#1}}
2379 % \end{macrocode}
2380 %
2381 % \begin{macro}{\KFLT@as} Storage for artist suffix
2382 % \begin{macrocode}
2383 \newcommand*{\KFLT@as}{}
2384 % \end{macrocode}
2385 % \end{macro}
2386 %
2387 %
2388 % \DescribeKey[main]{aup} Author prefix
2389 % \begin{macrocode}
2390 \define@key{KFLT@keys}{aup}{\renewcommand{\KFLT@aup}{#1}}
2391 % \end{macrocode}
2392 %
2393 % \begin{macro}{\KFLT@aup} Storage for author prefix
2394 % \begin{macrocode}
2395 \newcommand*{\KFLT@aup}{}
2396 % \end{macrocode}
2397 % \end{macro}
2398 %
2399 % \DescribeKey[main]{auf} Author first name
2400 % \begin{macrocode}
2401 \define@key{KFLT@keys}{auf}{\renewcommand{\KFLT@auf}{#1}}
2402 % \end{macrocode}
2403 %
2404 % \begin{macro}{\KFLT@auf} Storage for author first name
2405 % \begin{macrocode}
2406 \newcommand*{\KFLT@auf}{}
2407 % \end{macrocode}
2408 % \end{macro}
2409 %
2410 % \DescribeKey[main]{aul} Author last name
2411 % \begin{macrocode}
2412 \define@key{KFLT@keys}{aul}{\renewcommand{\KFLT@aul}{#1}}
2413 % \end{macrocode}
2414 %
2415 % \begin{macro}{\KFLT@al} Storage for author last name
2416 % \begin{macrocode}
2417 \newcommand*{\KFLT@aul}{}
2418 % \end{macrocode}
2419 % \end{macro}
2420 %
2421 % \DescribeKey[main]{aus} Author suffix
2422 % \begin{macrocode}
2423 \define@key{KFLT@keys}{aus}{\renewcommand{\KFLT@aus}{#1}}
2424 % \end{macrocode}
2425 %
2426 % \begin{macro}{\KFLT@aus} Storage for author suffix
2427 % \begin{macrocode}
2428 \newcommand*{\KFLT@aus}{}
2429 % \end{macrocode}
2430 % \end{macro}
2431 %
2432 %
2433 %
2434 %
2435 %
2436 % \begin{macro}{\KFLT@textalign} Storage for text alignment.
2437 %
2438 % Used for the additional text in the float.
2439 % \begin{macrocode}
2440 \newcommand*{\KFLT@textalign}{}
2441 % \end{macrocode}
2442 % \end{macro}
2443 %
2444 % \begin{macro}{\KFLT@t} Additional text storage
2445 %
2446 % Used for the additional text in the float.
2447 % \begin{macrocode}
2448 \newcommand{\KFLT@t}{}
2449 % \end{macrocode}
2450 % \end{macro}
2451 %
2452 %
2453 % Create replacement macros in case \pkg{tocdata} is not loaded:
2454 % \changes{v0.12}{2016/12/02}{Adapts to older version of tocdata.}
2455 % \changes{v2.00}{2019/03/20}{Adjustments for \pkg{tocdata} v2.00.}
2456 % \begin{macrocode}
2457 \providecommand{\tdartisttextjustify}{}
2458 \providecommand{\tdartisttextcenter}{}
2459 \providecommand{\tdartisttextleft}{}
2460 \providecommand{\tdartisttextright}{}
2461 \providecommand{\tdauthortextjustify}{}
2462 \providecommand{\tdauthortextcenter}{}
2463 \providecommand{\tdauthortextleft}{}
2464 \providecommand{\tdauthortextright}{}
2465 \providecommand{\tdartistjustify}{}
2466 \providecommand{\tdartistcenter}{}
2467 \providecommand{\tdartistleft}{}
2468 \providecommand{\tdartistright}{}
2469 \providecommand{\tdauthorjustify}{}
2470 \providecommand{\tdauthorcenter}{}
2471 \providecommand{\tdauthorleft}{}
2472 \providecommand{\tdauthorright}{}
2473 % \end{macrocode}
2474 %
2475 %
2476 % \DescribeKey[main]{t} Additional text, justified alignment.
2477 % \begin{macrocode}
2478 \define@key{KFLT@keys}{t}{%
2479 \renewcommand{\KFLT@t}{#1}%
2480 \renewcommand{\KFLT@textalign}{}%
2481 }
2482 % \end{macrocode}
2483 %
2484 %
2485 % \DescribeKey[main]{tc} Additional text, centered alignment.
2486 % \begin{macrocode}
2487 \define@key{KFLT@keys}{tc}{%
2488 \renewcommand{\KFLT@t}{#1}%
2489 \renewcommand{\KFLT@textalign}{\centering}%
2490 }
2491 % \end{macrocode}
2492 %
2493 %
2494 % \DescribeKey[main]{tr} Additional text, aligned to the right.
2495 % \begin{macrocode}
2496 \define@key{KFLT@keys}{tr}{%
2497 \renewcommand{\KFLT@t}{#1}%
2498 \renewcommand{\KFLT@textalign}{\raggedleft}%
2499 }
2500 % \end{macrocode}
2501 %
2502 %
2503 % \DescribeKey[main]{tl} Additional text, aligned to the left.
2504 % \begin{macrocode}
2505 \define@key{KFLT@keys}{tl}{%
2506 \renewcommand{\KFLT@t}{#1}%
2507 \renewcommand{\KFLT@textalign}{\raggedright}%
2508 }
2509 % \end{macrocode}
2510 %
2511 %
2512 % \DescribeKey[main]{lw} Fraction of \cs{linewidth}
2513 % \begin{macrocode}
2514 \define@key{KFLT@keys}{lw}{%
2515 \renewcommand{\KFLT@lw}{#1}%
2516 \setlength{\KFLT@w}{0pt}%
2517 }
2518 % \end{macrocode}
2519 %
2520 % \begin{macro}{\KFLT@lw} Fraction of linewidth storage: ``|.5|''
2521 % \begin{macrocode}
2522 \newcommand*{\KFLT@lw}{}
2523 % \end{macrocode}
2524 % \end{macro}
2525 %
2526 %
2527 % \DescribeKey[main]{w} Fixed width
2528 % \begin{macrocode}
2529 \define@key{KFLT@keys}{w}{%
2530 \setlength{\KFLT@w}{#1}%
2531 \renewcommand{\KFLT@lw}{}%
2532 }
2533 % \end{macrocode}
2534 %
2535 % \begin{macro}{\KFLT@w} Width storage: ``3cm''
2536 % \begin{macrocode}
2537 \newlength{\KFLT@w}
2538 % \end{macrocode}
2539 % \end{macro}
2540 %
2541 %
2542 % \DescribeKey[main]{h} Fixed height
2543 % \begin{macrocode}
2544 \define@key{KFLT@keys}{h}{\setlength{\KFLT@h}{#1}}
2545 % \end{macrocode}
2546 %
2547 % \begin{macro}{\KFLT@h} Height storage: ``2in''
2548 % \begin{macrocode}
2549 \newlength{\KFLT@h}
2550 % \end{macrocode}
2551 % \end{macro}
2552 %
2553 %
2554 % \DescribeKey[main]{kar} Keep aspect ratio
2555 % \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
2556 % \begin{macrocode}
2557 \define@key{KFLT@keys}{kar}[false]{%
2558 \renewcommand{\KFLT@keepaspectratio}{keepaspectratio}%
2559 }
2560 % \end{macrocode}
2561 %
2562 % \begin{macro}{\KFLT@keepaspectratio} Stores ``\optn{keepaspectratio}'' if set.
2563 % \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
2564 % \begin{macrocode}
2565 \newcommand{\KFLT@keepaspectratio}{}
2566 % \end{macrocode}
2567 % \end{macro}
2568 %
2569 %
2570 % \DescribeKey[main]{s} Scale
2571 % \begin{macrocode}
2572 \define@key{KFLT@keys}{s}{\renewcommand{\KFLT@s}{#1}}
2573 % \end{macrocode}
2574 %
2575 % \begin{macro}{\KFLT@s} Scale storage: ``3''
2576 % \begin{macrocode}
2577 \newcommand*{\KFLT@s}{1}
2578 % \end{macrocode}
2579 % \end{macro}
2580 %
2581 %
2582 % \DescribeKey[main]{r} Angle. 90 is counter-clockwise 90 degrees.
2583 % \begin{macrocode}
2584 \define@key{KFLT@keys}{r}{\renewcommand{\KFLT@r}{#1}}
2585 % \end{macrocode}
2586 %
2587 % \begin{macro}{\KFLT@r} Angle storage: ``90''
2588 % \begin{macrocode}
2589 \newcommand*{\KFLT@r}{0}
2590 % \end{macrocode}
2591 % \end{macro}
2592 %
2593 %
2594 % \DescribeKey[main]{f} Frame the image with \cs{KFLTlooseframe}.
2595 % \begin{macrocode}
2596 \define@key{KFLT@keys}{f}[true]{\setboolean{KFLT@f}{#1}}
2597 % \end{macrocode}
2598 %
2599 % \DescribeBoolean{KFLT@f} Frame the image?
2600 % \begin{macrocode}
2601 \newboolean{KFLT@f}
2602 % \end{macrocode}
2603 %
2604 %
2605 % \DescribeKey[main]{ft} Tightly frame the image using \cs{KFLTtightframe}.
2606 % This is useful for photographs, or diagrams which
2607 % already have built-in margins.
2608 % \begin{macrocode}
2609 \define@key{KFLT@keys}{ft}[true]{\setboolean{KFLT@ft}{#1}}
2610 % \end{macrocode}
2611 %
2612 % \DescribeBoolean{KFLT@ft} Tightly frame the image?
2613 % \begin{macrocode}
2614 \newboolean{KFLT@ft}
2615 % \end{macrocode}
2616
2617
2618 % \DescribeKey[main]{stretch} Set \cs{arraystretch} inside the table environment.
2619 % \begin{macrocode}
2620 \define@key{KFLT@keys}{stretch}{\renewcommand{\KFLT@stretch}{#1}}
2621 % \end{macrocode}
2622 %
2623 % \begin{macro}{\KFLT@stretch} Storage for \cs{arraystretch}.
2624 % \begin{macrocode}
2625 \newcommand*{\KFLT@stretch}{1}
2626 % \end{macrocode}
2627 % \end{macro}
2628
2629
2630 % \DescribeKey[main]{mo} Set vertical offset for a margin float.
2631 % \changes{v0.12}{2016/12/03}{Added \optn{mo} key.}
2632 % \begin{macrocode}
2633 \define@key{KFLT@keys}{mo}{\setlength{\KFLT@mo}{#1}}
2634 % \end{macrocode}
2635 %
2636 % \begin{macro}{\KFLT@mo} Storage for the vertical margin offset.
2637 % \begin{macrocode}
2638 \newlength{\KFLT@mo}
2639 % \end{macrocode}
2640 % \end{macro}
2641
2642
2643 % \DescribeKey[main]{wn} Set wrap number of narrow lines for a wrapped float.
2644 %
2645 % \changes{v2.04}{2021/06/08}{Added \optn{wn} key.}
2646 % \begin{macrocode}
2647 \define@key{KFLT@keys}{wn}{\renewcommand{\KFLT@wn}{#1}}
2648 % \end{macrocode}
2649 %
2650 % \begin{macro}{\KFLT@wn} Storage for the wrap placement.
2651 % \begin{macrocode}
2652 \newcommand{\KFLT@wn}{}
2653 % \end{macrocode}
2654 % \end{macro}
2655
2656
2657 % \DescribeKey[main]{wp} Set wrap placement for a wrapped float.
2658 %
2659 % See \cref{tab:wrapplacement} on \cpageref{tab:wrapplacement}.
2660 %
2661 % \changes{v0.12}{2016/12/03}{Added \optn{wp} key.}
2662 % \begin{macrocode}
2663 \define@key{KFLT@keys}{wp}{\renewcommand{\KFLT@wp}{#1}}
2664 % \end{macrocode}
2665 %
2666 % \begin{macro}{\KFLT@wp} Storage for the wrap placement.
2667 % \begin{macrocode}
2668 \newcommand{\KFLT@wp}{O}
2669 % \end{macrocode}
2670 % \end{macro}
2671
2672
2673 % \DescribeKey[main]{wo} Set wrap overhang for a wrapped float.
2674 %
2675 % \changes{v2.04}{2021/06/08}{Added \optn{wo} key.}
2676 % \begin{macrocode}
2677 \define@key{KFLT@keys}{wo}{\renewcommand{\KFLT@wo}{#1}}
2678 % \end{macrocode}
2679 %
2680 % \begin{macro}{\KFLT@wo} Storage for the wrap placement.
2681 % \begin{macrocode}
2682 \newcommand{\KFLT@wo}{\wrapoverhang}
2683 % \end{macrocode}
2684 % \end{macro}
2685
2686
2687 % \DescribeKey[main]{wlw} Wrapped figure, fraction of \cs{linewidth}
2688 % \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
2689 % \begin{macrocode}
2690 \define@key{KFLT@keys}{wlw}{%
2691 \renewcommand{\KFLT@wlw}{#1}%
2692 \setlength{\KFLT@ww}{0pt}%
2693 }
2694 % \end{macrocode}
2695 %
2696 % \begin{macro}{\KFLT@wlw} Wrapped figure, fraction of linewidth storage: ``|.5|''
2697 % \begin{macrocode}
2698 \newcommand*{\KFLT@wlw}{}
2699 % \end{macrocode}
2700 % \end{macro}
2701 %
2702 %
2703 % \DescribeKey[main]{ww} Wrapped figure, fixed width
2704 % \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
2705 % \begin{macrocode}
2706 \define@key{KFLT@keys}{ww}{%
2707 \setlength{\KFLT@ww}{#1}%
2708 \renewcommand{\KFLT@wlw}{}%
2709 }
2710 % \end{macrocode}
2711 %
2712 % \begin{macro}{\KFLT@ww} Wrapped figure, width storage: ``3cm''
2713 % \begin{macrocode}
2714 \newlength{\KFLT@ww}
2715 % \end{macrocode}
2716 % \end{macro}
2717
2718
2719 % \DescribeKey[main]{va} Set vertical alignment of the outermost minipage container.
2720 %
2721 % \changes{v0.15}{2017/05/09}{Added vertical alignment key \optn{va}.}
2722 % \begin{macrocode}
2723 \define@key{KFLT@keys}{va}{\renewcommand{\KFLT@va}{#1}}
2724 % \end{macrocode}
2725 %
2726 % \begin{macro}{\KFLT@va} Storage for the vertical alignment.
2727 % \begin{macrocode}
2728 \newcommand{\KFLT@va}{c}
2729 % \end{macrocode}
2730 % \end{macro}
2731
2732
2733
2734
2735
2736 % \subsection{Nesting control}
2737
2738 % \DescribeCounter{KFLT@keyfloatdepth} Depth inside a keyfigs environment
2739 % \begin{macrocode}
2740 \newcounter{KFLT@keyfloatdepth}
2741 \setcounter{KFLT@keyfloatdepth}{0}
2742 % \end{macrocode}
2743
2744 % \DescribeBoolean{KFLT@inkeysubfloats} Inside a \env{keysubfigs} environment?
2745 % \begin{macrocode}
2746 \newboolean{KFLT@inkeysubfloats}
2747 \setboolean{KFLT@inkeysubfloats}{false}
2748 % \end{macrocode}
2749
2750
2751
2752 % \subsection{Subfloat key handling}
2753 %
2754 % These keys are for the container holding a collection of subfigures.
2755
2756 % \DescribeBoolean{KFLT@subgrpcont} Continued float?
2757 % \begin{macrocode}
2758 \newboolean{KFLT@subgrpcont}{}
2759 % \end{macrocode}
2760 %
2761 % \DescribeKey[subfloat container]{cont} Continued float
2762 % \begin{macrocode}
2763 \define@key{KFLT@subgrpkeys}{cont}[true]{%
2764 \setboolean{KFLT@subgrpcont}{#1}%
2765 }
2766 % \end{macrocode}
2767
2768 % \begin{macro}{\KFLT@subgrpc} Sub-caption storage
2769 % \begin{macrocode}
2770 \newcommand{\KFLT@subgrpc}{}
2771 % \end{macrocode}
2772 % \end{macro}
2773
2774 % \DescribeBoolean{KFLT@subgrpcstart} Sub-caption starred?
2775 % \begin{macrocode}
2776 \newboolean{KFLT@subgrpcstar}
2777 % \end{macrocode}
2778 %
2779 % \DescribeKey[subfloat container]{c} Caption
2780 % \begin{macrocode}
2781 \define@key{KFLT@subgrpkeys}{c}{%
2782 \renewcommand{\KFLT@subgrpc}{#1}\setboolean{KFLT@subgrpcstar}{false}%
2783 }
2784 % \end{macrocode}
2785 %
2786 % \DescribeKey[subfloat container]{cstar} Starred caption?
2787 % \begin{macrocode}
2788 \define@key{KFLT@subgrpkeys}{cstar}{%
2789 \renewcommand{\KFLT@subgrpc}{#1}\setboolean{KFLT@subgrpcstar}{true}%
2790 }
2791 % \end{macrocode}
2792 %
2793 % \DescribeKey[subfloat container]{sc} Short caption
2794 % \begin{macrocode}
2795 \define@key{KFLT@subgrpkeys}{sc}{%
2796 \renewcommand{\KFLT@subgrpsc}{#1}%
2797 \setboolean{KFLT@subgrpscgiven}{true}%
2798 }
2799 % \end{macrocode}
2800
2801 % \begin{macro}{\KFLT@subgrpsc} Sub-shortcaption storage
2802 % \begin{macrocode}
2803 \newcommand{\KFLT@subgrpsc}{}
2804 % \end{macrocode}
2805 % \end{macro}
2806
2807 % \DescribeBoolean{KFLT@subgrpscgiven} Sub-shortcaption was given?
2808 % \begin{macrocode}
2809 \newboolean{KFLT@subgrpscgiven}
2810 % \end{macrocode}
2811
2812 % \begin{macro}{\KFLT@subgrptype} Subfloats collection type storage:
2813 % ``|figure|'', ``|table|''
2814 % \begin{macrocode}
2815 \newcommand*{\KFLT@subgrptype}{}
2816 % \end{macrocode}
2817 % \end{macro}
2818
2819
2820 %
2821 % \DescribeKey[subfloat container]{l} Label
2822 % \begin{macrocode}
2823 \define@key{KFLT@subgrpkeys}{l}{\renewcommand{\KFLT@subgrpl}{#1}}
2824 \newcommand*{\KFLT@subgrpl}{}
2825 % \end{macrocode}
2826 %
2827 %
2828 %
2829 % \begin{macro}{\KFLT@subgrptextalign} Storage for text alignment.
2830 %
2831 % Used for the additional text in the float.
2832 % \begin{macrocode}
2833 \newcommand*{\KFLT@subgrptextalign}{}
2834 % \end{macrocode}
2835 % \end{macro}
2836 %
2837 % \begin{macro}{\KFLT@subgrpt} Additional text storage
2838 %
2839 % Used for the additional text in the float.
2840 % \begin{macrocode}
2841 \newcommand{\KFLT@subgrpt}{}
2842 % \end{macrocode}
2843 % \end{macro}
2844 %
2845 %
2846 % \DescribeKey[subfloat container]{t} Additional text — full justification
2847 % \begin{macrocode}
2848 \define@key{KFLT@subgrpkeys}{t}{%
2849 \renewcommand{\KFLT@subgrpt}{#1}%
2850 \renewcommand{\KFLT@subgrptextalign}{}%
2851 }
2852 % \end{macrocode}
2853 %
2854 % \DescribeKey[subfloat container]{t} Additional text — center justification
2855 % \begin{macrocode}
2856 \define@key{KFLT@subgrpkeys}{tc}{%
2857 \renewcommand{\KFLT@subgrpt}{#1}%
2858 \renewcommand{\KFLT@subgrptextalign}{\centering}%
2859 }
2860 % \end{macrocode}
2861 %
2862 % \DescribeKey[subfloat container]{t} Additional text — aligned left
2863 % \begin{macrocode}
2864 \define@key{KFLT@subgrpkeys}{tl}{%
2865 \renewcommand{\KFLT@subgrpt}{#1}%
2866 \renewcommand{\KFLT@subgrptextalign}{\raggedright}%
2867 }
2868 % \end{macrocode}
2869 %
2870 % \DescribeKey[subfloat container]{t} Additional text — aligned right
2871 % \begin{macrocode}
2872 \define@key{KFLT@subgrpkeys}{tr}{%
2873 \renewcommand{\KFLT@subgrpt}{#1}%
2874 \renewcommand{\KFLT@subgrptextalign}{\raggedleft}%
2875 }
2876 % \end{macrocode}
2877 %
2878 %
2879 %
2880 % For the \pkg{tocdata} package:
2881 %
2882 % \DescribeKey[subfloat container]{ap} Artist prefix
2883 % \begin{macrocode}
2884 \define@key{KFLT@subgrpkeys}{ap}{\renewcommand{\KFLT@subgrpap}{#1}}
2885 % \end{macrocode}
2886 %
2887 % \begin{macro}{\KFLT@subgrpap} Storage for artist prefix
2888 % \begin{macrocode}
2889 \newcommand*{\KFLT@subgrpap}{}
2890 % \end{macrocode}
2891 % \end{macro}
2892 %
2893 % \DescribeKey[subfloat container]{af} Artist first name
2894 % \begin{macrocode}
2895 \define@key{KFLT@subgrpkeys}{af}{\renewcommand{\KFLT@subgrpaf}{#1}}
2896 % \end{macrocode}
2897 %
2898 % \begin{macro}{\KFLT@subgrpaf} Storage for artist first name
2899 % \begin{macrocode}
2900 \newcommand*{\KFLT@subgrpaf}{}
2901 % \end{macrocode}
2902 % \end{macro}
2903 %
2904 % \DescribeKey[subfloat container]{al} Artist last name
2905 % \begin{macrocode}
2906 \define@key{KFLT@subgrpkeys}{al}{\renewcommand{\KFLT@subgrpal}{#1}}
2907 % \end{macrocode}
2908 %
2909 % \begin{macro}{\KFLT@subgrpal} Storage for artist last name
2910 % \begin{macrocode}
2911 \newcommand*{\KFLT@subgrpal}{}
2912 % \end{macrocode}
2913 % \end{macro}
2914 %
2915 % \DescribeKey[subfloat container]{as} Artist suffix
2916 % \begin{macrocode}
2917 \define@key{KFLT@subgrpkeys}{as}{\renewcommand{\KFLT@subgrpas}{#1}}
2918 % \end{macrocode}
2919 %
2920 % \begin{macro}{\KFLT@subgrpas} Storage for artist suffix
2921 % \begin{macrocode}
2922 \newcommand*{\KFLT@subgrpas}{}
2923 % \end{macrocode}
2924 % \end{macro}
2925
2926 % \DescribeKey[subfloat container]{aup} Author prefix
2927 % \begin{macrocode}
2928 \define@key{KFLT@subgrpkeys}{aup}{\renewcommand{\KFLT@subgrpaup}{#1}}
2929 % \end{macrocode}
2930 %
2931 % \begin{macro}{\KFLT@subgrpaup} Storage for author prefix
2932 % \begin{macrocode}
2933 \newcommand*{\KFLT@subgrpaup}{}
2934 % \end{macrocode}
2935 % \end{macro}
2936 %
2937 % \DescribeKey[subfloat container]{auf} Author first name
2938 % \begin{macrocode}
2939 \define@key{KFLT@subgrpkeys}{auf}{\renewcommand{\KFLT@subgrpauf}{#1}}
2940 % \end{macrocode}
2941 %
2942 % \begin{macro}{\KFLT@subgrpauf} Storage for author first name
2943 % \begin{macrocode}
2944 \newcommand*{\KFLT@subgrpauf}{}
2945 % \end{macrocode}
2946 % \end{macro}
2947 %
2948 % \DescribeKey[subfloat container]{aul} Author last name
2949 % \begin{macrocode}
2950 \define@key{KFLT@subgrpkeys}{aul}{\renewcommand{\KFLT@subgrpaul}{#1}}
2951 % \end{macrocode}
2952 %
2953 % \begin{macro}{\KFLT@subgrpaul} Storage for author last name
2954 % \begin{macrocode}
2955 \newcommand*{\KFLT@subgrpaul}{}
2956 % \end{macrocode}
2957 % \end{macro}
2958 %
2959 % \DescribeKey[subfloat container]{aus} Author suffix
2960 % \begin{macrocode}
2961 \define@key{KFLT@subgrpkeys}{aus}{\renewcommand{\KFLT@subgrpaus}{#1}}
2962 % \end{macrocode}
2963 %
2964 % \begin{macro}{\KFLT@subgrpaus} Storage for author suffix
2965 % \begin{macrocode}
2966 \newcommand*{\KFLT@subgrpaus}{}
2967 % \end{macrocode}
2968 % \end{macro}
2969
2970
2971 % \subsection{Computing image width}
2972
2973 % \DescribeLength{\KFLT@imagewidth} Computed width of the image
2974 % \begin{macrocode}
2975 \newlength{\KFLT@imagewidth}
2976 % \end{macrocode}
2977
2978 % \DescribeLength{\KFLT@boxwidth} Computed width of the container box
2979 % \begin{macrocode}
2980 \newlength{\KFLT@boxwidth}
2981 % \end{macrocode}
2982 %
2983 % \DescribeLength{\KFLT@wrapwidth} Computed width of the wrapped figure
2984 % \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
2985 % \begin{macrocode}
2986 \newlength{\KFLT@wrapwidth}
2987 % \end{macrocode}
2988
2989 %
2990 % \begin{macro}{\KFLT@findwidths} Figure out how wide to make an image and its container
2991 % \begin{macrocode}
2992 \newcommand*{\KFLT@findwidths}{%
2993 % \end{macrocode}
2994 %
2995 % Default to a box of full \cs{linewidth} minus the potential frame:
2996 % \begin{macrocode}
2997 \ifbool{KFLT@ft}% tight frame?
2998 {\setlength{\KFLT@boxwidth}{\linewidth - 2\KFLTtightframewidth}}%
2999 {% not tight frame
3000 \ifbool{KFLT@f}% loose frame?
3001 {\setlength{\KFLT@boxwidth}{\linewidth - 2\KFLTlooseframewidth}}%
3002 {\setlength{\KFLT@boxwidth}{\linewidth}}% no frame
3003 }% not tight frame
3004 % \end{macrocode}
3005 %
3006 % Several width options exist. First see if width was given:
3007 % \begin{macrocode}
3008 \ifdimgreater{\KFLT@w}{0pt}%
3009 % \end{macrocode}
3010 %
3011 % Width was given:
3012 % \begin{macrocode}
3013 {\setlength{\KFLT@imagewidth}{\KFLT@w}}%
3014 {% width not given
3015 % \end{macrocode}
3016 %
3017 % Use full \cs{linewidth} or only a fraction:
3018 % \begin{macrocode}
3019 \ifcsempty{KFLT@lw}%
3020 {\setlength{\KFLT@imagewidth}{\KFLT@boxwidth}}%
3021 {\setlength{\KFLT@imagewidth}{\KFLT@lw\KFLT@boxwidth}}%
3022 }% width not given
3023 % \end{macrocode}
3024 %
3025 % The wrap width is the same as the image width, unless specified:
3026 % \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
3027 % \begin{macrocode}
3028 \ifdimgreater{\KFLT@ww}{0pt}%
3029 % \end{macrocode}
3030 %
3031 % Width was given:
3032 % \begin{macrocode}
3033 {%
3034 \setlength{\KFLT@wrapwidth}{\KFLT@ww}}%
3035 {% width not given
3036 % \end{macrocode}
3037 %
3038 % If \optn{wlw}, use a fraction of line width,
3039 % else if none given use the same as the image width.
3040 % \begin{macrocode}
3041 \ifcsempty{KFLT@wlw}%
3042 {%
3043 \setlength{\KFLT@wrapwidth}{\KFLT@imagewidth}}%
3044 {%
3045 \setlength{\KFLT@wrapwidth}{\KFLT@wlw\KFLT@boxwidth}}%
3046 }% width not given
3047 }
3048 % \end{macrocode}
3049 % \end{macro}
3050 %
3051 %
3052 % \subsection{Framing and rotation}
3053 %
3054 %
3055 % A user-redefinable macro and length to tightly frame the contents.
3056 %
3057 % \begin{description}
3058 % \item [\cs{KFLTtightframe}:] Redefine to a macro which frames its contents.
3059 % \item [\cs{KFLTtightframewidth}:] Redefine to the total width of the new.
3060 % frame and its separation.
3061 % \item[\cs{KFLTlooseframe}:] Redefine to a macro which frames its contents.
3062 % \item[\cs{KFLTlooseframewidth}:] Redefine to the total width of the new
3063 % frame and its separation.
3064 % \end{description}
3065 %
3066 % \begin{macro}{\KFLTtightframe} \marg{contents}
3067 % \begin{macrocode}
3068 \newcommand{\KFLTtightframe}[1]{%
3069 \setlength{\fboxsep}{0pt}%
3070 \setlength{\fboxrule}{.4pt}%
3071 \fbox{#1}%
3072 }
3073
3074 % \end{macrocode}
3075 % \end{macro}
3076 %
3077 % \DescribeLength{\KFLTtightframewidth} Must be set to the combined width of
3078 % the tight frame and separation used by \cs{KFLTtightframe}.
3079 % \begin{macrocode}
3080 \newlength{\KFLTtightframewidth}
3081 \setlength{\KFLTtightframewidth}{.4pt}
3082 % \end{macrocode}
3083 %
3084 %
3085 % \begin{macro}{\KFLTlooseframe} \marg{contents}
3086 %
3087 % A user-redefinable macro and length to loosely frame the contents.
3088 %
3089 % \begin{macrocode}
3090 \newcommand{\KFLTlooseframe}[1]{%
3091 \setlength{\fboxsep}{3pt}%
3092 \setlength{\fboxrule}{.4pt}%
3093 \fbox{#1}%
3094 }
3095 % \end{macrocode}
3096 % \end{macro}
3097 %
3098 % \DescribeLength{\KFLTlooseframewidth} Must be set to the combined width of
3099 % the loose frame and separation used by \cs{KFLTlooseframe}.
3100 % \begin{macrocode}
3101 \newlength{\KFLTlooseframewidth}
3102 \setlength{\KFLTlooseframewidth}{3.4pt}
3103 % \end{macrocode}
3104 %
3105 %
3106 % \begin{macro}{\KFLT@frame} \marg{contents}
3107 %
3108 % Frames the contents according to the |f| key. To be nested for further processing.
3109 % \changes{v2.07}{2022/01/08}{Reduced hbox warnings.}
3110 % \begin{macrocode}
3111 \newcommand{\KFLT@frame}[1]
3112 {%
3113 \ifbool{KFLT@ft}%
3114 {%
3115 {%
3116 \hfuzz=\linewidth%
3117 \KFLTtightframe{#1}%
3118 }%
3119 }%
3120 {% not tightframe
3121 \ifbool{KFLT@f}%
3122 {%
3123 {%
3124 \hfuzz=\linewidth%
3125 \KFLTlooseframe{#1}%
3126 }%
3127 }%
3128 {#1}% no frame
3129 }% not looseframe
3130 }
3131 % \end{macrocode}
3132 % \end{macro}
3133 %
3134 %
3135 % \begin{macro}{KFLT@findenvboxwidth}
3136 % Figures the width of the contents of \cs{KFLT@envbox} plus the frame:
3137 % \begin{macrocode}
3138 \newcommand{\KFLT@findenvboxwidth}{%
3139 \settowidth{\KFLTimageboxwidth}{\usebox{\KFLT@envbox}}%
3140 \ifbool{KFLT@ft}%
3141 {\addtolength{\KFLTimageboxwidth}{2\KFLTtightframewidth}}%
3142 {% not tightframe
3143 \ifbool{KFLT@f}%
3144 {\addtolength{\KFLTimageboxwidth}{2\KFLTlooseframewidth}}%
3145 {}% no frame
3146 }% not looseframe
3147 }
3148 % \end{macrocode}
3149 % \end{macro}
3150 %
3151 %
3152 %
3153 %
3154 % \subsection{A graphics image from a file}
3155 %
3156 % \DescribeLength{\KFLT@testwidth} Used to find the width of a graphics image.
3157 % \begin{macrocode}
3158 \newlength{\KFLT@testwidth}
3159 % \end{macrocode}
3160 %
3161 %
3162 % \begin{macro}{\KFLT@includegraphics} \oarg{keys} \marg{file name}
3163 %
3164 % Issue a warning if the image will be too wide, then display the image.
3165 % \begin{macrocode}
3166 \newcommand*{\KFLT@includegraphics}[2][]{%
3167 % \end{macrocode}
3168 %
3169 % Find the width of the image:
3170 % \begin{macrocode}
3171 \settowidth{\KFLT@testwidth}{\includegraphics[#1]{#2}}%
3172 % \end{macrocode}
3173 %
3174 % Avoid rounding errors when using the \optn{lw} option,
3175 % and also avoid the exact line width in case images are side-by-side.
3176 %
3177 % If close to \cs{linewidth}, use slightly less than the \cs{linewidth}:
3178 % \changes{v2.06}{2021/06/25}{Clip if close to \cs{linewidth}.}
3179 % \begin{macrocode}
3180 \ifboolexpr{%
3181 test {\ifdimgreater{\KFLT@testwidth}{\linewidth-.01pt}} and
3182 test {\ifdimless{\KFLT@testwidth}{\linewidth+1pt}}
3183 }%
3184 {\setlength{\KFLT@testwidth}{\linewidth-.01pt}}%
3185 {}%
3186 % \end{macrocode}
3187 %
3188 %
3189 % Issue a warning if wider than the \cs{linewidth}:
3190 % \changes{v2.06}{2021/06/25}{Warn if image too wide.}
3191 % \begin{macrocode}
3192 \ifdimgreater{\KFLT@testwidth}{\linewidth}{%
3193 \PackageWarning{keyfloat}{The image is wider than the line width}%
3194 }{}%
3195 % \end{macrocode}
3196 %
3197 % Display the image:
3198 % \begin{macrocode}
3199 \includegraphics[#1]{#2}%
3200 }
3201 % \end{macrocode}
3202 % \end{macro}
3203 %
3204 %
3205 % \begin{macro}{\KFLT@onefigureimage} \marg{filename}
3206 %
3207 % Create an image with size, frame, and turn.
3208 %
3209 % \shownesting{\cs{KFLT@onefigureimage}}
3210 % {
3211 % \shownesting{\env{turn}}
3212 % {
3213 % \shownesting{\cs{KFLT@frame} $\to$ \cs{fbox}}
3214 % {\cs{KFLT@includegraphics}}
3215 % }
3216 % }
3217 %
3218 % \changes{v2.00}{2019/03/12}{Filename in arg instead of \cs{KFLT@i}.}
3219 % \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
3220 % \begin{macrocode}
3221 \NewDocumentCommand{\KFLT@onefigureimage}{m}%
3222 {%
3223 % \end{macrocode}
3224 % Several possible combinations of linewidth, width, and height are available,
3225 % and each is treated separately.
3226 % Scaling and width/height are done first, then framing, then rotation.
3227 % \begin{macrocode}
3228 \begin{lrbox}{\KFLT@envbox}%
3229 % \end{macrocode}
3230 % Handle the |lw| key. If |lw| is used, width and height are ignored.
3231 % \begin{macrocode}
3232 \ifdefempty{\KFLT@lw}%
3233 {% not linewidth
3234 % \end{macrocode}
3235 % Handle the |w| key, which may be used along with the |h| key:
3236 % \begin{macrocode}
3237 \ifdimgreater{\KFLT@w}{0pt}%
3238 {% width is given
3239 \ifdimgreater{\KFLT@h}{0pt}%
3240 % \end{macrocode}
3241 % Width and height are both given:
3242 % \begin{macrocode}
3243 {% w and h
3244 \KFLT@includegraphics[%
3245 scale=\KFLT@s,%
3246 width=\KFLT@imagewidth,%
3247 height=\KFLT@h,%
3248 \KFLT@keepaspectratio,%
3249 ]{#1}%
3250 }% w and h
3251 % \end{macrocode}
3252 % Only width:
3253 % \begin{macrocode}
3254 {% only w
3255 \KFLT@includegraphics[%
3256 scale=\KFLT@s,%
3257 width=\KFLT@imagewidth,%
3258 \KFLT@keepaspectratio,%
3259 ]{#1}%
3260 }% only w
3261 }% width is given
3262 % \end{macrocode}
3263 % Width was not given, so maybe handle |h| alone:
3264 % \begin{macrocode}
3265 {% width is not given
3266 \ifdimgreater{\KFLT@h}{0pt}%
3267 % \end{macrocode}
3268 % |h| was given:
3269 % \begin{macrocode}
3270 {%
3271 \KFLT@includegraphics[%
3272 scale=\KFLT@s,%
3273 height=\KFLT@h,%
3274 \KFLT@keepaspectratio,%
3275 ]{#1}%
3276 }%
3277 % \end{macrocode}
3278 % If none were given, use the image's natural size:
3279 % \begin{macrocode}
3280 {%
3281 \KFLT@includegraphics[%
3282 scale=\KFLT@s,%
3283 \KFLT@keepaspectratio,%
3284 ]{#1}%
3285 }%
3286 }% width is not given
3287 }% not linewidth
3288 {% linewidth given
3289 % \end{macrocode}
3290 % \changes{v2.06}{2021/06/25}{Fix: \optn{lw} with \optn{h}.}
3291 % \begin{macrocode}
3292 \ifdimgreater{\KFLT@h}{0pt}%
3293 {% lw and h given
3294 \KFLT@includegraphics[%
3295 scale=\KFLT@s,%
3296 width=\KFLT@imagewidth,%
3297 height=\KFLT@h,%
3298 \KFLT@keepaspectratio,%
3299 ]{#1}%
3300 }%
3301 {% lw w/o h
3302 \KFLT@includegraphics[%
3303 scale=\KFLT@s,%
3304 width=\KFLT@imagewidth,%
3305 \KFLT@keepaspectratio,%
3306 ]{#1}%
3307 }%
3308 }%
3309 \end{lrbox}%
3310 \unskip%
3311 \KFLT@findenvboxwidth%
3312 \begin{turn}{\KFLT@r}%
3313 \KFLT@frame{\usebox{\KFLT@envbox}}%
3314 \unskip%
3315 \end{turn}%
3316 }
3317 % \end{macrocode}
3318 % \end{macro}
3319
3320
3321
3322
3323 % \subsection{Printing the caption}
3324 %
3325 %
3326 % \begin{macro}{\KFLT@dosimplecaption} \marg{star?} \marg{short cap or |-NO VALUE-|} \marg{caption}
3327 %
3328 % Calls \cs{caption} depending on several combinations of star and short captions
3329 % being given.
3330 % \begin{macrocode}
3331 \NewDocumentCommand{\KFLT@dosimplecaption}{m m m}
3332 {%
3333 \unskip%
3334 \IfBooleanTF{#1}% star?
3335 {\IfValueTF{#2}{\caption*[#2]{#3}}{\caption*{#3}}}%
3336 {\IfValueTF{#2}{\caption[#2]{#3}}{\caption{#3}}}%
3337 }
3338 % \end{macrocode}
3339 % \end{macro}
3340 %
3341 %
3342 %
3343 % There are two versions of \cs{KFLT@docaption},
3344 % depending on whether \pkg{tocdata} is loaded.
3345 %
3346 % \begin{macrocode}
3347 \@ifpackageloaded{tocdata}
3348 {% tocdata loaded
3349 % \end{macrocode}
3350 %
3351 %
3352 % \begin{macro}{\KFLT@@docaption} {1: artist/author} \marg{2: empty or ''u''}
3353 % \marg{3: star?}
3354 % \marg{4: short caption} \marg{5: caption}
3355 % \marg{6: \mainsubarg}
3356 % \changes{v2.00}{2019/03/19}{Factored.}
3357 % \begin{macrocode}
3358 \newcommand*{\KFLT@@docaption}[6]{%
3359 % \end{macrocode}
3360 % (\pkg{tocdata} does not expand its text argument before checking for empty.)
3361 % \begin{macrocode}
3362 \addvspace{\smallskipamount}%
3363 \ifcsempty{KFLT@#6t}{%
3364 \IfBooleanTF{#3}%
3365 {%
3366 \csuse{caption#1}*[#4]{#5}%
3367 []%
3368 [\csuse{KFLT@#6a#2p}]%
3369 {\csuse{KFLT@#6a#2f}}%
3370 {\csuse{KFLT@#6a#2l}}%
3371 [\csuse{KFLT@#6a#2s}]%
3372 }{%
3373 \csuse{caption#1}[#4]{#5}%
3374 []%
3375 [\csuse{KFLT@#6a#2p}]%
3376 {\csuse{KFLT@#6a#2f}}%
3377 {\csuse{KFLT@#6a#2l}}%
3378 [\csuse{KFLT@#6a#2s}]%
3379 }%
3380 }{%
3381 \ifcsstring{KFLT@#6textalign}{}{\csuse{td#1textjustify}}{}%
3382 \ifcsstring{KFLT@#6textalign}{\centering}{\csuse{td#1textcenter}}{}%
3383 \ifcsstring{KFLT@#6textalign}{\raggedleft}{\csuse{td#1textright}}{}%
3384 \ifcsstring{KFLT@#6textalign}{\raggedright}{\csuse{td#1textleft}}{}%
3385 \IfBooleanTF{#3}%
3386 {%
3387 \csuse{caption#1}*[#4]{#5}%
3388 [\csuse{KFLT@#6t}]%
3389 [\csuse{KFLT@#6a#2p}]%
3390 {\csuse{KFLT@#6a#2f}}%
3391 {\csuse{KFLT@#6a#2l}}%
3392 [\csuse{KFLT@#6a#2s}]%
3393 }{%
3394 \csuse{caption#1}[#4]{#5}%
3395 [\csuse{KFLT@#6t}]%
3396 [\csuse{KFLT@#6a#2p}]%
3397 {\csuse{KFLT@#6a#2f}}%
3398 {\csuse{KFLT@#6a#2l}}%
3399 [\csuse{KFLT@#6a#2s}]%
3400 }%
3401 }%
3402 }
3403 % \end{macrocode}
3404 % \end{macro}
3405 %
3406 % \begin{macro}{\KFLT@docaption} * \oarg{2:short caption} \marg{3:caption} \marg{4: \mainsubarg}
3407 %
3408 % Depending on whether the \pkg{tocdata} package is present,
3409 % and an artist is specified,
3410 % use either \cs{caption} or \cs{captionartist}.
3411 %
3412 % The fourth argument is |{}| if a regular float, or
3413 % |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
3414 %
3415 % See Table \ref{tab:captions} for the possible combinations of
3416 % the caption-related keys: |c|, |cstar|, and |sc|.
3417 %
3418 % \changes{v0.14}{2017/02/09}{Fix: No index entry if no artist given.}
3419 %
3420 % With \pkg{tocdata}:
3421 %
3422 % \begin{macrocode}
3423 \NewDocumentCommand{\KFLT@docaption}{s o m m}
3424 {%
3425 % \end{macrocode}
3426 % Is the last name empty? Assume no artist if so.
3427 % \begin{macrocode}
3428 \ifcsempty{KFLT@#4al}%
3429 {% figure w/o artist
3430 \ifcsempty{KFLT@#4aul}%
3431 {% figure w/o artist or author
3432 % \end{macrocode}
3433 % A figure without an artist or author uses the simple caption.
3434 % \begin{macrocode}
3435 \KFLT@dosimplecaption{#1}{#2}{#3}%
3436 }% figure w/o artist or author
3437 % \end{macrocode}
3438 % A figure with an author uses the \pkg{tocdata} \cs{captionauthor} macro,
3439 % which also creates an index entry.
3440 % \begin{macrocode}
3441 {% figure w/ author
3442 \KFLT@@docaption{author}{u}{#1}{#2}{#3}{#4}%
3443 }% figure w/ author
3444 }% figure w/o artist
3445 {% figure with an artist
3446 % \end{macrocode}
3447 % A figure with an artist uses the \pkg{tocdata} \cs{captionartist} macro,
3448 % which also creates an index entry.
3449 % \begin{macrocode}
3450 \KFLT@@docaption{artist}{}{#1}{#2}{#3}{#4}%
3451 }% figure with an artist
3452 }% KFLT@tocdata
3453 }% tocdata loaded
3454 {% no tocdata
3455 % \end{macrocode}
3456 % \end{macro}
3457 %
3458 % Without \pkg{tocdata}:
3459 %
3460 % \begin{macro}{\KFLT@docaption} * \oarg{2:short caption} \marg{3:caption} \marg{4: \mainsubarg}
3461 % \changes{v2.00}{2019/03/19}{Added support for authors.}
3462 % \begin{macrocode}
3463 \NewDocumentCommand{\KFLT@docaption}{s o m m}
3464 {%
3465 % \end{macrocode}
3466 % If \pkg{tocdata} is not loaded, use a simple caption.
3467 % \begin{macrocode}
3468 \KFLT@dosimplecaption{#1}{#2}{#3}%
3469 % \end{macrocode}
3470 % Create an index entry depending on whether there is a last, first name:
3471 % \begin{macrocode}
3472 \ifcsempty{KFLT@#4al}%
3473 {%
3474 \ifcsempty{KFLT@#4aul}%
3475 {}%
3476 {% yes author
3477 \ifcsempty{KFLT@#4auf}%
3478 {\index{\csuse{KFLT@#4aul}}}%
3479 {\index{\csuse{KFLT@#4aul}, \csuse{KFLT@#4auf}}}%
3480 }% yes author
3481 }% no artist
3482 {% yes artist
3483 \ifcsempty{KFLT@#4af}%
3484 {\index{\csuse{KFLT@#4al}}}%
3485 {\index{\csuse{KFLT@#4al}, \csuse{KFLT@#4af}}}%
3486 }% yes artist
3487 }% KFLT@docaption
3488 }% no tocdata
3489 % \end{macrocode}
3490 % \end{macro}
3491
3492
3493 % \begin{macro}{\KFLT@caption} \marg{\mainsubarg}
3494 %
3495 % Caption-creation logic.
3496 %
3497 % The argument is |{}| if a regular float, or
3498 % |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
3499 %
3500 % See Table \ref{tab:captions} for the possible combinations of
3501 % the caption-related keys: |c|, |cstar|, and |sc|.
3502 % \begin{macrocode}
3503 \newcommand{\KFLT@caption}[1]{%
3504 % \end{macrocode}
3505 % A starred caption is printed but not numbered.
3506 % \begin{macrocode}
3507 \ifbool{KFLT@#1cstar}% starred caption?
3508 % \end{macrocode}
3509 % This is a starred caption:
3510 % \begin{macrocode}
3511 {%starred caption
3512 % \end{macrocode}
3513 % A key given as |cstar={}| yields a float with no caption at all.
3514 % \begin{macrocode}
3515 \ifcsempty{KFLT@#1c}% cstar={}?
3516 {}%
3517 % \end{macrocode}
3518 % Non-empty starred caption might have a \acro{LOF} entry
3519 % if it has a short caption |sc| key:
3520 % \begin{macrocode}
3521 {% non-empty starred caption
3522 \ifcsempty{KFLT@#1sc}%
3523 % \end{macrocode}
3524 % No |sc| short caption, but there is a |cstar|, so no \acro{LOF} entry:
3525 % \begin{macrocode}
3526 {}%
3527 % \end{macrocode}
3528 % Both |cstar| and |sc| were given, so add a \acro{LOF} entry:
3529 % \changes{v2.00}{2019/01/22}{Generalized for float type.}
3530 % \begin{macrocode}
3531 {% non-empty cstar and sc:
3532 \edef\KFLT@listtype{\csuse{KFLT@#1type}}%
3533 \addcontentsline{\csuse{ext@\KFLT@listtype}}%
3534 {\csuse{KFLT@#1type}}{\KFLT@sc}%
3535 }% non-empty cstar and sc
3536 % \end{macrocode}
3537 %
3538 % In the following,
3539 % the test for an empty caption is because the \pkg{caption} package does not
3540 % detect an empty caption if it is given as a macro.
3541 %
3542 % |cstar| was given, so create an unnumbered caption:
3543 % \changes{v2.06}{2019/06/29}{Fix for empty caption.}
3544 % \begin{macrocode}
3545 \ifcsempty{KFLT@#1c}%
3546 {\KFLT@docaption*{}{#1}}%
3547 {\KFLT@docaption*{\csuse{KFLT@#1c}}{#1}}%
3548 }%
3549 }% starred caption
3550 % \end{macrocode}
3551 % Unstarred caption |c| was given, so number this float:
3552 % \changes{v2.06}{2019/06/29}{Fix for empty caption.}
3553 % \begin{macrocode}
3554 {% unstarred caption
3555 \ifcsempty{KFLT@#1sc}%
3556 {% no short cap
3557 \ifcsempty{KFLT@#1c}%
3558 {\KFLT@docaption{}{#1}}%
3559 {\KFLT@docaption{\csuse{KFLT@#1c}}{#1}}%
3560 }% no short cap
3561 {% short cap
3562 \ifcsempty{KFLT@#1c}%
3563 {\KFLT@docaption[\csuse{KFLT@#1sc}]{}{#1}}%
3564 {\KFLT@docaption[\csuse{KFLT@#1sc}]{\csuse{KFLT@#1c}}{#1}}%
3565 }% short cap
3566 % \end{macrocode}
3567 % Optional label:
3568 % \begin{macrocode}
3569 \ifcsempty{KFLT@#1l}%
3570 {}%
3571 {\label{\csuse{KFLT@#1l}}}%
3572 }% unstarred caption
3573 }
3574 % \end{macrocode}
3575 % \end{macro}
3576
3577
3578 % \subsection{Defaults for a new float}
3579
3580 % \begin{macro}{\KFLT@defaults} Defaults all settings before reading the keys.
3581 % \changes{v2.06}{2021/06/25}{Added \optn{kar}.}
3582 % \begin{macrocode}
3583 \newcommand*{\KFLT@defaults}{%
3584 \setboolean{KFLT@cont}{false}%
3585 \renewcommand{\KFLT@c}{}%
3586 \setboolean{KFLT@cstar}{false}%
3587 \renewcommand{\KFLT@sc}{}%
3588 \setboolean{KFLT@scgiven}{false}%
3589 \renewcommand{\KFLT@type}{figure}%
3590 \renewcommand{\KFLT@l}{}%
3591 \renewcommand{\KFLT@ap}{}%
3592 \renewcommand{\KFLT@af}{}%
3593 \renewcommand{\KFLT@al}{}%
3594 \renewcommand{\KFLT@as}{}%
3595 \renewcommand{\KFLT@aup}{}%
3596 \renewcommand{\KFLT@auf}{}%
3597 \renewcommand{\KFLT@aul}{}%
3598 \renewcommand{\KFLT@aus}{}%
3599 \renewcommand{\KFLT@t}{}%
3600 \renewcommand{\KFLT@textalign}{}%
3601 \renewcommand{\KFLT@lw}{}%
3602 \setlength{\KFLT@w}{0pt}%
3603 \setlength{\KFLT@h}{0pt}%
3604 \renewcommand{\KFLT@keepaspectratio}{}%
3605 \renewcommand{\KFLT@s}{1}%
3606 \renewcommand{\KFLT@r}{0}%
3607 \setboolean{KFLT@f}{false}%
3608 \setboolean{KFLT@ft}{false}%
3609 \renewcommand{\KFLT@stretch}{1}%
3610 \setlength{\KFLT@mo}{-1.2ex}%
3611 \renewcommand{\KFLT@wn}{}%
3612 \renewcommand{\KFLT@wp}{O}%
3613 \renewcommand{\KFLT@wo}{\wrapoverhang}%
3614 \renewcommand{\KFLT@wlw}{}%
3615 \setlength{\KFLT@ww}{0pt}%
3616 \renewcommand{\KFLT@va}{c}%
3617 }
3618 % \end{macrocode}
3619 % \end{macro}
3620
3621 % \subsection{Row start/end processing}
3622
3623 % \begin{macro}{\KFLT@maybestartfloatrow} Counts rows
3624 %
3625 % After ending a preexisting row, move to the next row.
3626 % The use of \cs{defcounter} makes this counter change local.
3627 % \begin{macrocode}
3628 \newcommand*{\KFLT@maybestartfloatrow}{%
3629 \KFLT@maybeendfloatrow%
3630 \defcounter{KFLT@thiscol}{\value{KFLT@thiscol}+1}%
3631 }
3632 % \end{macrocode}
3633 % \end{macro}
3634
3635
3636 % \begin{macro}{\KFLT@maybeendfloatrow} Counts rows
3637 %
3638 % Adds vertical space then resets to allow the start of a new row.
3639 % The use of \cs{defcounter} makes this counter change local.
3640 % \begin{macrocode}
3641 \newcommand*{\KFLT@maybeendfloatrow}{%
3642 \ifnumless{\value{KFLT@thiscol}}{\value{KFLT@numcols}}%
3643 {}% thiscol < numcols
3644 {% >=
3645 \par%
3646 \addvspace{.75\floatsep}%
3647 \defcounter{KFLT@thiscol}{0}%
3648 }%
3649 }%
3650 % \end{macrocode}
3651 % \end{macro}
3652
3653
3654
3655
3656
3657
3658 % \subsection{Key environment helper macros}
3659
3660
3661 % \begin{macro}{\KFLT@trackrows} Tracks and spaces rows and columns.
3662 % \begin{macrocode}
3663 \newcommand{\KFLT@trackrows}%
3664 {%
3665 % \end{macrocode}
3666 % If are nested inside a keyfloats or a subfloat:
3667 % \begin{macrocode}
3668 \ifboolexpr{%
3669 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or%
3670 bool{KFLT@inkeysubfloats}%
3671 }%
3672 {% nested
3673 % \end{macrocode}
3674 % Tracks row start and end:
3675 % \begin{macrocode}
3676 \KFLT@maybestartfloatrow%
3677 % \end{macrocode}
3678 % Possibly fill space between columns:
3679 % \begin{macrocode}
3680 \ifnumgreater{\value{KFLT@thiscol}}{1}%
3681 {\hfill}%
3682 {}%
3683 }% nested
3684 {}% not nested
3685 }
3686 % \end{macrocode}
3687 % \end{macro}
3688
3689
3690
3691 % \begin{macro}{\KFLT@addtext} \marg{\mainsubarg}
3692 %
3693 % Adds optional additional text.
3694 %
3695 % The argument is |{}| if a regular float, or
3696 % |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
3697 %
3698 % \changes{v0.11}{2016/12/02}{Improved paragraph handling.}
3699 %
3700 % \begin{macrocode}
3701 \newcommand{\KFLT@addtext}[1]
3702 {%
3703 % \end{macrocode}
3704 % Is there text to add?
3705 % \begin{macrocode}
3706 \ifcsempty{KFLT@#1t}%
3707 {}% no text
3708 {% text to add
3709 {% local
3710 % \end{macrocode}
3711 % Add some space, then create a full-width minipage to contain the text:
3712 % \begin{macrocode}
3713 \addvspace{\smallskipamount}%
3714 \begin{minipage}{\linewidth}%
3715 % \end{macrocode}
3716 %
3717 % Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
3718 % \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
3719 % \begin{macrocode}
3720 \hbadness=10000\relax%
3721 % \end{macrocode}
3722 % Set the alignment and some text parameters:
3723 % \begin{macrocode}
3724 \csuse{KFLT@#1textalign}%
3725 \footnotesize%
3726 \setlength{\parskip}{1.5ex}%
3727 \setlength{\parindent}{0em}%
3728 % \end{macrocode}
3729 % Typeset the actual text:
3730 % \begin{macrocode}
3731 \csuse{KFLT@#1t}%
3732 % \end{macrocode}
3733 % Close it all out with a little more space:
3734 % \begin{macrocode}
3735 \end{minipage}%
3736 \par\addvspace{2ex}%
3737 }% local
3738 }% text to add
3739 }
3740 % \end{macrocode}
3741 % \end{macro}
3742 %
3743 %
3744 %
3745 % \begin{macro}{\KFLT@optionalname} \marg{name}
3746 %
3747 % Adds optional artist's name and the following space.
3748 %
3749 % \begin{macrocode}
3750 \newcommand{\KFLT@optionalname}[1]
3751 {%
3752 \ifblank{#1}%
3753 {}%
3754 {#1~}%
3755 }
3756 % \end{macrocode}
3757 % \end{macro}
3758 %
3759 %
3760 %
3761 % \begin{macro}{\KFLT@addartisttext} \marg{\mainsubarg}
3762 %
3763 % Adds optional additional text.
3764 %
3765 % The argument is |{}| if a regular float, or
3766 % |subgrp| if \env{keysubfigs} or \env{keysubtabs}.
3767 %
3768 % One of two versions is used, depending on whether the \pkg{tocdata}
3769 % package is available.
3770 %
3771 % If \pkg{tocdata} is loaded and this float has an artist or author,
3772 % then the float's artist's information and optional text will be printed
3773 % elsewhere by \cs{KFLT@caption}. Otherwise, the text is printed here.
3774 %
3775 % Two versions, depending on whether \pkg{tocdata} is loaded:
3776 % \begin{macrocode}
3777 \@ifpackageloaded{tocdata}
3778 {% tocdata loaded
3779 % \end{macrocode}
3780 % If \pkg{tocdata} is loaded:
3781 % \begin{macrocode}
3782 \newcommand{\KFLT@addartisttext}[1]
3783 {%
3784 % \end{macrocode}
3785 % Only add text if is a figure without an artist or author name.
3786 % If an artist or author is given, the name and text will be added
3787 % by \pkg{tocdata}.
3788 % \begin{macrocode}
3789 \ifcsempty{KFLT@#1al}% artist last name
3790 {%
3791 \ifcsempty{KFLT@#1aul}% author last name
3792 {\KFLT@addtext{#1}}
3793 {}%
3794 }%
3795 {}% fig w/ artist: text will be added by \captionartist in \KFLT@caption
3796 }% KFLT@addartisttext
3797 }% tocdata loaded
3798 % \end{macrocode}
3799 % If \pkg{tocdata} is not loaded, the name and text are added here:
3800 % \begin{macrocode}
3801 {% tocdata not loaded
3802 % \end{macrocode}
3803
3804 % Factored from \cs{KFLT@addartisttext}
3805 % \begin{macrocode}
3806 \newcommand*{\KFLT@@addartisttext}[3]{%
3807 % \end{macrocode}
3808 % Add space and create the name inside a full-width minipage:
3809 % \begin{macrocode}
3810 \addvspace{\medskipamount}%
3811 \begin{minipage}{\linewidth}%
3812 % \end{macrocode}
3813 %
3814 % Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
3815 % \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
3816 % \begin{macrocode}
3817 \hbadness=10000\relax%
3818 % \end{macrocode}
3819 %
3820 % Text alignment is |#3|, and depends on artist or author:
3821 % \begin{macrocode}
3822 #3%
3823 % \end{macrocode}
3824 %
3825 % |#1| is empty or '|subgrp'| \\
3826 % |#2| is empty for artist, `|u|' for author:
3827 % \begin{macrocode}
3828 \footnotesize\textsc{%
3829 \KFLT@optionalname{\csuse{KFLT@#1a#2p}}%
3830 \KFLT@optionalname{\csuse{KFLT@#1a#2f}}%
3831 \csuse{KFLT@#1a#2l}%
3832 \csuse{KFLT@#1a#2s}%
3833 }%
3834 \end{minipage}%
3835 \par\addvspace{2ex}%
3836 }
3837
3838 \newcommand{\KFLT@addartisttext}[1]
3839 {%
3840 % \end{macrocode}
3841 % Only use the artist information if a last name is given:
3842 % \begin{macrocode}
3843 \ifcsempty{KFLT@#1al}%
3844 {% artist last name not given
3845 \ifcsempty{KFLT@#1aul}%
3846 {}% author last name not given
3847 {% author last name given
3848 \KFLT@@addartisttext{#1}{u}{\raggedleft}%
3849 }% author last name given
3850 }% artist last name not given
3851 {% artist last name given
3852 \KFLT@@addartisttext{#1}{}{\centering}%
3853 }%
3854 % \end{macrocode}
3855 % Any additional text follows the artist's name:
3856 % \begin{macrocode}
3857 \KFLT@addtext{#1}%
3858 }% KFLT@addartisttext
3859 }% tocdata not loaded
3860 % \end{macrocode}
3861 % \end{macro}
3862
3863
3864 % \DescribeLength{\KFLTimageboxwidth} The computed width of the object.
3865 %
3866 % \changes{v0.13}{2017/01/12}{\cs{KFLTimageboxwidth}: Added.}
3867 %
3868 % This may be used as the width parameter of a minipage to encase the object.
3869 %
3870 % \begin{macrocode}
3871 \newlength{\KFLTimageboxwidth}
3872 % \end{macrocode}
3873
3874
3875 % \newcommand*{\showKFLTboxinner}[1]{%
3876 % \shownesting{\env{KFLT@boxinner}}{
3877 % \shownesting{\cs{KFLT@frame} $\to$ \cs{fbox}}
3878 % {
3879 % \shownesting{\env{turn}}
3880 % {\shownesting{\env{minipage}}{#1}}
3881 % }
3882 % }
3883 % }
3884 %
3885 % \begin{environment}{KFLT@boxinner}
3886 %
3887 % Typeset the contents in a width which depends on the keys.
3888 %
3889 % \showKFLTboxinner{Contents}
3890 %
3891 % \begin{macrocode}
3892 \newsavebox{\KFLT@envbox}
3893
3894 \NewDocumentEnvironment{KFLT@boxinner}{}
3895 {% keyboxinner
3896 % \end{macrocode}
3897 % (Possibly) frame the contents of an \env{lrbox}:
3898 % \begin{macrocode}
3899 \begin{lrbox}{\KFLT@envbox}%
3900 % \end{macrocode}
3901 % Rotate the contents:
3902 % \begin{macrocode}
3903 \turn{\KFLT@r}%
3904 % \end{macrocode}
3905 % Box the contents in the width computed by \cs{KFLT@findwidths}:
3906 % \begin{macrocode}
3907 \minipage{\KFLT@imagewidth}%
3908 % \end{macrocode}
3909 % Spacing inside the box.
3910 % Also default to regular justified text alignment.
3911 % \begin{macrocode}
3912 \setlength{\parskip}{2ex}%
3913 \renewcommand{\arraystretch}{\KFLT@stretch}%
3914 }% keyboxinner
3915 % \end{macrocode}
3916 % End of the environment:
3917 % \begin{macrocode}
3918 {% endkeyboxinner
3919 \endminipage%
3920 % \end{macrocode}
3921 % End the rotated box:
3922 % \begin{macrocode}
3923 \endturn%
3924 % \end{macrocode}
3925 % Possibly frame:
3926 % \begin{macrocode}
3927 \end{lrbox}%
3928 \KFLT@frame{\usebox{\KFLT@envbox}}%
3929 \par%
3930 }% endkeyboxinner
3931 % \end{macrocode}
3932 % \end{environment}
3933
3934
3935 % \begin{macro}{\KFLT@sharedkeys}
3936 % Key/values to apply to each object in this group,
3937 % such as a \env{keyfloats} or \env{keysubfigs}.
3938 % \changes{v2.06}{2021/06/25}{Added shared keys.}
3939 % \begin{macrocode}
3940 \newcommand*{\KFLT@sharedkeys}{}
3941 % \end{macrocode}
3942 % \end{macro}
3943
3944 % \begin{macro}{\KFLT@boxkeys} \marg{keys} \marg{float type}
3945 %
3946 % Default the options, adjust for a table, then parse the keys:
3947 % \changes{v2.06}{2021/06/25}{Added shared keys.}
3948 % \begin{macrocode}
3949 \NewDocumentCommand{\KFLT@boxkeys}{+m m}
3950 {%
3951 % \end{macrocode}
3952 % Set the key defaults:
3953 % \begin{macrocode}
3954 \KFLT@defaults%
3955 % \end{macrocode}
3956 % Remember the float type:
3957 % \changes{v2.07}{2022/01/06}{Fixed: Nested types.}
3958 % \begin{macrocode}
3959 \ifbool{KFLT@inkeysubfloats}%
3960 {\renewcommand{\KFLT@type}{\@captype}}%
3961 {\renewcommand{\KFLT@type}{#2}}%
3962 % \end{macrocode}
3963 % Set the shared keys. Expansion seems to be required for \pkg{xkeyval}.
3964 % \begin{macrocode}
3965 \edef\next{\noexpand\setkeys{KFLT@keys}{\KFLT@sharedkeys}}%
3966 \next%
3967 % \end{macrocode}
3968 % Set the float-specific keys, which might overright the group's keys:
3969 % \begin{macrocode}
3970 \setkeys{KFLT@keys}{#1}%
3971 }
3972 % \end{macrocode}
3973 % \end{macro}
3974
3975
3976 % \DescribeBoolean{KFLT@captionistop} Saves the value of \cs{caption@position},
3977 % which may become unreliable if using Komascript and
3978 % \begin{sourceverb}
3979 % \captionsetup[table]{position=above}
3980 % \end{sourceverb}
3981 %
3982 % \begin{macrocode}
3983 \newbool{KFLT@captionistop}
3984 % \end{macrocode}
3985
3986
3987 % \begin{macro}{\KFLT@LWR@hook@boxouter} Used by \pkg{lwarp}.
3988 % \begin{macrocode}
3989 \newcommand*{\KFLT@LWR@hook@boxouter}{}%
3990 % \end{macrocode}
3991 % \end{macro}
3992
3993
3994 % \begin{environment}{KFLT@boxouter} \marg{star?} \marg{loc}
3995 %
3996 % Boxes the contents of figures and floats.
3997 %
3998 % Not used by subfigures.
3999 %
4000 % \changes{v0.12}{2016/12/03}{[M] and [W] floats.}
4001 % \changes{v0.15}{2017/05/09}{Handle vertical alignment key \optn{va}.}
4002 % \changes{v0.15}{2017/05/12}{Adjustments for \protect\env{keywrap}.}
4003 % \begin{macrocode}
4004 \NewDocumentEnvironment{KFLT@boxouter}{m m}
4005 {% boxouter
4006 % \end{macrocode}
4007 % The \env{keyfigure} and \env{keytable} environments handle the contents in one of
4008 % three possible ways, depending on whether it is
4009 % called alone, inside a \env{keyfloats} environment, or
4010 % inside a \env{keysubfigs} or \env{keysubtabs} environment.
4011 %
4012 % Start the new subfigure or subtable, of the given width:
4013 % \begin{macrocode}
4014 \ifbool{KFLT@inkeysubfloats}%
4015 {\csuse{sub\KFLT@type}{\KFLT@rowboxwidth}}% subfloat
4016 % \end{macrocode}
4017 % If \env{keyfloats}, place the contents inside a \env{minipage}:
4018 % \begin{macrocode}
4019 {% not subfloat:
4020 \ifnumgreater{\value{KFLT@keyfloatdepth}}{0}%
4021 {% keyfloats
4022 \ifbool{KFLT@keywrap}%
4023 {\minipage[t]{\KFLT@rowboxwidth}}%
4024 {\minipage[\KFLT@va]{\KFLT@rowboxwidth}}%
4025 \captionsetup*{type=\KFLT@type}%
4026 }% keyfloats
4027 {% not keyfloats
4028 % \end{macrocode}
4029 % A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
4030 % \begin{macrocode}
4031 \KFLT@LWR@hook@boxouter%
4032 % \end{macrocode}
4033 %
4034 % Not a subfloat or \env{keyfloats}, so create a single float.
4035 %
4036 % See if inside a \env{keywrap}.
4037 % If so, force [H] and vertical align top.
4038 % \begin{macrocode}
4039 \ifbool{KFLT@keywrap}%
4040 {%
4041 \par\addvspace{\baselineskip}%
4042 \noindent%
4043 \minipage[t]{\linewidth}%
4044 \captionsetup{type=\KFLT@type}%
4045 }%
4046 {% not a keywrap
4047 % \end{macrocode}
4048 %
4049 % See if the float should [W]rap:
4050 %
4051 % \begin{macrocode}
4052 \ifstrequal{#2}{W}%
4053 % \end{macrocode}
4054 % Place [W], so create a wrapfloat using the \pkg{wrapfig} package:
4055 % \begin{macrocode}
4056 {% [W]
4057 % \end{macrocode}
4058 %
4059 % Temporarily figure out \cs{KFLT@imagewidth},
4060 % and make the wrapped figure environment as wide as the
4061 % desired image size plus frame:
4062 % \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
4063 % \changes{v2.04}{2021/06/08}{Added \optn{wn} and \optn{wo}.}
4064 % \begin{macrocode}
4065 \KFLT@findwidths%
4066 % \end{macrocode}
4067 %
4068 % Expand the arguments for \pkg{wrapfig}:
4069 % \changes{v2.05}{2021/06/11}{No longer patch \pkg{wrapfig} for expansion.}
4070 % \begin{macrocode}
4071 \edef\next{%
4072 \noexpand\wrapfloat%
4073 {\KFLT@type}[\KFLT@wn]{\KFLT@wp}[\KFLT@wo]%
4074 {\KFLT@wrapwidth+2\KFLTlooseframewidth}%
4075 }%
4076 \next%
4077 % \end{macrocode}
4078 % \begin{macrocode}
4079 \minipage{\KFLT@wrapwidth+2\KFLTlooseframewidth}%
4080 % \end{macrocode}
4081 %
4082 % Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
4083 % \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
4084 % \begin{macrocode}
4085 \hbadness=10000\relax%
4086 % \end{macrocode}
4087 % \begin{macrocode}
4088 \normalcolor\reset@font\normalsize%
4089 % \end{macrocode}
4090 %
4091 % Change the interior image to the discovered fixed width.
4092 % \changes{v2.02}{2021/05/27}{Added \optn{ww} and \optn{wlw}.}
4093 % \begin{macrocode}
4094 \renewcommand{\KFLT@lw}{}%
4095 \renewcommand{\KFLT@w}{\KFLT@imagewidth}%
4096 \renewcommand{\KFLT@wlw}{}%
4097 \renewcommand{\KFLT@ww}{0pt}%
4098 }% [W]
4099 {% not [W]
4100 % \end{macrocode}
4101 %
4102 % See if the float should be positioned in the [M]argin:
4103 % \begin{macrocode}
4104 \ifstrequal{#2}{M}%
4105 % \end{macrocode}
4106 % Place [M], so create a marginfloat:
4107 % \changes{v2.00}{2019/03/18}{Added custom float types.}
4108 % \begin{macrocode}
4109 {% [M]
4110 \KFLT@marginfloat[\KFLT@mo]{\KFLT@type}%
4111 }% [M]
4112 {% not [M]
4113 % \end{macrocode}
4114 %
4115 % See if the float should be positioned [H]ere:
4116 % \begin{macrocode}
4117 \ifstrequal{#2}{H}%
4118 % \end{macrocode}
4119 % Place [H], so create an inline minipage:
4120 % \changes{v2.01}{2019/09/11}{Fix: Font and color.}
4121 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
4122 % \begin{macrocode}
4123 {% [H]
4124 \vskip\intextsep%
4125 \noindent\minipage[\KFLT@va]{\linewidth}%
4126 \normalcolor\reset@font\normalsize%
4127 \captionsetup{type=\KFLT@type}%
4128 }% [H]
4129 % \end{macrocode}
4130 % Not [H], so create a float:
4131 % For a starred float, make a two-column table in a two-col format.
4132 % \begin{macrocode}
4133 {% not [H]
4134 \IfBooleanTF{#1}%
4135 {\csuse{\KFLT@type*}[#2]}%
4136 {\csuse{\KFLT@type}[#2]}%
4137 }% not [H]
4138 }% not [M]
4139 }% not [W]
4140 }% not keywrap
4141 }% not keyfloats
4142 }% not subfloat
4143 % \end{macrocode}
4144 % Handle a continued float. Ignored if in a subfloat.
4145 % \begin{macrocode}
4146 \ifbool{KFLT@cont}{\ContinuedFloat}{}%
4147 % \end{macrocode}
4148 % Figure out image and parbox widths for the contents:
4149 % \begin{macrocode}
4150 \KFLT@findwidths%
4151 % \end{macrocode}
4152 % Place the caption above the contents depending on \pkg{caption} \optn{position} option:
4153 % \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
4154 % \begin{macrocode}
4155 \caption@iftop%
4156 {\booltrue{KFLT@captionistop}}%
4157 {\boolfalse{KFLT@captionistop}}%
4158 \ifbool{KFLT@captionistop}{\KFLT@caption{}}{}%
4159 % \end{macrocode}
4160 % Typeset the contents:
4161 % \begin{macrocode}
4162 \center\unskip%
4163 }% boxouter
4164 % \end{macrocode}
4165 %
4166 % End of the KFLT@boxouter environment:
4167 %
4168 % \begin{macrocode}
4169 {% endboxouter
4170 \endcenter\unskip%
4171 \addvspace{\smallskipamount}%
4172 % \end{macrocode}
4173 % Optionally print artist's name and additional text:
4174 % \begin{macrocode}
4175 \KFLT@addartisttext{}%
4176 % \end{macrocode}
4177 % Place the caption below the contents depending on \pkg{caption} \optn{position} option:
4178 % \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
4179 % \begin{macrocode}
4180 \ifbool{KFLT@captionistop}{}{\KFLT@caption{}}%
4181 % \end{macrocode}
4182 % If are inside \env{keysubtabs}, end the subtable:
4183 % \begin{macrocode}
4184 \ifbool{KFLT@inkeysubfloats}%
4185 {%
4186 \csuse{endsub\KFLT@type}%
4187 }% subfloat
4188 {% not subfloat
4189 \ifnumgreater{\value{KFLT@keyfloatdepth}}{0}% keyfloats?
4190 {%
4191 % \end{macrocode}
4192 % \begin{macrocode}
4193 \endminipage%
4194 }% keyfloats
4195 {% not keyfloats
4196 % \end{macrocode}
4197 %
4198 % Not subfloat or \env{keyfloats}, so is an individual float.
4199 %
4200 % Close the minipage or float:
4201 %
4202 % See if in a \env{keywrap}:
4203 % \begin{macrocode}
4204 \ifbool{KFLT@keywrap}{%
4205 \endminipage%
4206 \par\addvspace{\baselineskip}%
4207 }%
4208 {% not keywrap
4209 % \end{macrocode}
4210 %
4211 % See if the float should [W]rap:
4212 % \begin{macrocode}
4213 \ifstrequal{#2}{W}%
4214 % \end{macrocode}
4215 % Place [W], so close the wrap float:
4216 % \begin{macrocode}
4217 {% [W]
4218 \endminipage%
4219 \endwrapfloat%
4220 }% [W]
4221 {% not[W]
4222 % \end{macrocode}
4223 %
4224 % See if the float should be positioned in the [M]argin:
4225 % \begin{macrocode}
4226 \ifstrequal{#2}{M}%
4227 % \end{macrocode}
4228 % [M], so close the marginfloat:
4229 % \changes{v2.00}{2019/03/18}{Added custom float types.}
4230 % \begin{macrocode}
4231 {% [M]
4232 \endKFLT@marginfloat%
4233 }% [M]
4234 % \end{macrocode}
4235 % [H] or float:
4236 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
4237 % \begin{macrocode}
4238 {% not [M]
4239 \ifstrequal{#2}{H}%
4240 {%
4241 \endminipage% [H]
4242 \vskip\intextsep%
4243 }%
4244 {% not [H]
4245 \IfBooleanTF{#1}% starred float?
4246 {\csuse{end\KFLT@type*}}%
4247 {\csuse{end\KFLT@type}}%
4248 }% not [H]
4249 }% not [M]
4250 }% not [W]
4251 }% not keywrap
4252 }% not keyfloats
4253 }% not subfloat
4254 }% endkeyboxouter
4255 % \end{macrocode}
4256 % \end{environment}
4257
4258
4259 % \begin{macro}{\KFLT@@ignorespaces} \marg{commandname}
4260 % Only do command if not nested inside something.
4261 % \changes{v2.00}{2019/01/22}{Added.}
4262 % \begin{macrocode}
4263 \newcommand*{\KFLT@@ignorespaces}[1]{%
4264 \ifboolexpr{%
4265 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or%
4266 bool{KFLT@inkeysubfloats}%
4267 }{}{\csuse{#1}}%
4268 }
4269 % \end{macrocode}
4270 % \end{macro}
4271
4272
4273 % \begin{macro}{\KFLT@ignorespaces}
4274 % Only \cs{ignorespaces} if not nested inside something.
4275 % \changes{v2.00}{2019/01/22}{Added.}
4276 % \begin{macrocode}
4277 \newcommand*{\KFLT@ignorespaces}{%
4278 \KFLT@@ignorespaces{ignorespaces}%
4279 }
4280 % \end{macrocode}
4281 % \end{macro}
4282
4283
4284 % \begin{macro}{\KFLT@envignorespaces}
4285 % Only \cs{ignorespaces} if not nested inside something.
4286 % \changes{v2.00}{2019/01/22}{Added.}
4287 % \begin{macrocode}
4288 \newcommand*{\KFLT@envignorespaces}{%
4289 \KFLT@@ignorespaces{ignorespacesafterend}%
4290 }
4291 % \end{macrocode}
4292 % \end{macro}
4293
4294
4295 % \subsection{The \cs{KFLT@keyflt} macro}
4296 %
4297 % \begin{macro}{\KFLT@keyflt}
4298 % \marg{1:star} \marg{2:loc} \marg{3:type} \marg{4:\keyvalsarg} \marg{5:contents}
4299 %
4300 % A lower-level macro to generate a float with its contents.
4301 % This is used by \cs{keyfig} and \cs{keyflt}.
4302 %
4303 % \changes{v2.00}{2019/03/17}{Added.}
4304 % \begin{macrocode}
4305 \NewDocumentCommand{\KFLT@keyflt}{m m m +m +m}
4306 {%
4307 % \end{macrocode}
4308 %
4309 % \changes{v2.02}{2021/05/18}{Work with \pkg{float}.}
4310 % \begin{macrocode}
4311 \ifcsdef{ftype@#3}{}{%
4312 \PackageError{keyfloat}%
4313 {%
4314 \protect\keyflt: Invalid float type.\MessageBreak%
4315 \protect\keyflt*[loc]{type}{keys/values}{contents}\MessageBreak%
4316 Also, \protect\keyflt\space is not an environment
4317 }%
4318 {%
4319 Check argument order and float type.
4320 }%
4321 }%
4322 % \end{macrocode}
4323 %
4324 % \begin{macrocode}
4325 \KFLT@ignorespaces%
4326 \KFLT@trackrows%
4327 \KFLT@boxkeys{#4}{#3}%
4328 \begingroup%
4329 \KFLT@boxouter{#1}{#2}%
4330 #5%
4331 \endKFLT@boxouter%
4332 \endgroup%
4333 \KFLT@ignorespaces%
4334 }
4335 % \end{macrocode}
4336 % \end{macro}
4337
4338
4339 % \subsection{The \cs{keyflt} macro}
4340
4341 % \begin{macro}{\keyflt} * \oarg{loc} \marg{type} \marg{\keyvalsarg} \marg{contents}
4342 %
4343 % A user-level macro to generate a float with its contents
4344 % centered inside an inner box.
4345 % This may be used by itself, or inside a \env{keyfloats} or
4346 % \env{keysubtabs} environment.
4347 %
4348 % \shownesting{\cs{keyflt}}{
4349 % \shownesting{\cs{KFLT@keyflt}}{
4350 % \shownesting{\env{KFLT@boxouter}}{
4351 % \showKFLTboxinner{Contents}
4352 % }
4353 % }
4354 % }
4355 %
4356 % \changes{v0.12}{2016/12/03}{Group around contents.}
4357 % \changes{v2.00}{2019/03/17}{Added.}
4358 % \begin{macrocode}
4359 \NewDocumentCommand{\keyflt}{s O{tbp} m +m +m}
4360 {%
4361 \KFLT@keyflt{#1}{#2}{#3}{#4}{%
4362 \KFLT@boxinner%
4363 \centering%
4364 #5%
4365 \endKFLT@boxinner%
4366 }%
4367 }
4368 % \end{macrocode}
4369 % \end{macro}
4370
4371 % \begin{macro}{\endkeyflt}
4372 %
4373 % Generates an error in case the user tried to use \cs{keyflt} as an environment.
4374 % \changes{v2.00}{2019/03/17}{Added.}
4375 % \begin{macrocode}
4376 \def\endkeyflt{%
4377 \PackageError{keyfloat}
4378 {%
4379 \protect\end{keyflt}:\MessageBreak
4380 \protect\keyflt\space is a macro, not an environment.\MessageBreak
4381 Perhaps you want the keyfloat environment instead%
4382 }
4383 {%
4384 Use \protect\begin{keyfloat} ... \protect\end{keyfloat}.
4385 }
4386 }
4387 % \end{macrocode}
4388 % \end{macro}
4389
4390
4391 % \subsection{The \env{keyfloat} environment}
4392
4393 % \begin{macro}{\KFLT@keyfloatstart} \marg{star?} \marg{loc} \marg{float type} \marg{\keyvalsarg}
4394 %
4395 % \changes{v2.00}{2019/03/18}{Factored.}
4396 % \begin{macrocode}
4397 \newcommand{\KFLT@keyfloatstart}[4]{%
4398 \KFLT@envignorespaces%
4399 \KFLT@boxkeys{#4}{#3}%
4400 \KFLT@boxouter{#1}{#2}%
4401 \KFLT@boxinner%
4402 }
4403 % \end{macrocode}
4404 % \end{macro}
4405
4406 % \begin{macro}{\KFLT@keyfloatend}
4407 % \changes{v2.00}{2019/03/18}{Factored.}
4408 % \begin{macrocode}
4409 \newcommand{\KFLT@keyfloatend}{%
4410 \endKFLT@boxinner%
4411 \endKFLT@boxouter%
4412 \KFLT@envignorespaces%
4413 }
4414 % \end{macrocode}
4415 % \end{macro}
4416
4417 % \begin{environment}{keyfloat} * \oarg{loc} \marg{float type} \marg{\keyvalsarg}
4418 %
4419 % \shownesting{\env{keyfloat}}{
4420 % \shownesting{\cs{KFLT@keyfloatstart}, \cs{KFLT@keyfloatend}}
4421 % {
4422 % \shownesting{\env{KFLT@boxouter}}{
4423 % \showKFLTboxinner{Contents}
4424 % }
4425 % }
4426 % }
4427 %
4428 % \changes{v2.00}{2019/03/18}{Added.}
4429 % \begin{macrocode}
4430 \NewDocumentEnvironment{keyfloat}{s O{tbp} m +m}
4431 {%
4432 \KFLT@keyfloatstart{#1}{#2}{#3}{#4}%
4433 }%
4434 {%
4435 \KFLT@keyfloatend%
4436 }
4437 % \end{macrocode}
4438 % \end{environment}
4439
4440 % Extra code to track rows outside of the \env{keyfloat} environment,
4441 % \DescribeObject{Before \env{keyfloat}}
4442 % before it starts. This is done to allow nesting without losing track
4443 % of the prior level.
4444 %
4445 % \begin{macrocode}
4446 \BeforeBeginEnvironment{keyfloat}{%
4447 \KFLT@trackrows%
4448 }
4449 % \end{macrocode}
4450
4451
4452 % \subsection{The \env{keyfigure} environment}
4453
4454 % \begin{environment}{keyfigure} * \oarg{loc} \marg{\keyvalsarg}
4455 %
4456 % \shownesting{\env{keyfigure}}{
4457 % \shownesting{\cs{KFLT@keyfloatstart}, \cs{KFLT@keyfloatend}}
4458 % {
4459 % \shownesting{\env{KFLT@boxouter}}{
4460 % \showKFLTboxinner{Contents}
4461 % }
4462 % }
4463 % }
4464 %
4465 % \begin{macrocode}
4466 \NewDocumentEnvironment{keyfigure}{s O{tbp} +m}
4467 {%
4468 \KFLT@keyfloatstart{#1}{#2}{figure}{#3}%
4469 }%
4470 {%
4471 \KFLT@keyfloatend%
4472 }
4473 % \end{macrocode}
4474 % \end{environment}
4475
4476 % Extra code to track rows outside of the \env{keyfigure} environment,
4477 % \DescribeObject{Before \env{keyfigure}}
4478 % before it starts. This is done to allow nesting without losing track
4479 % of the prior level.
4480 %
4481 % \begin{macrocode}
4482 \BeforeBeginEnvironment{keyfigure}{%
4483 \KFLT@trackrows%
4484 }
4485 % \end{macrocode}
4486
4487
4488 % \subsection{The \cs{keyfig} macro}
4489
4490 % \begin{macro}{\keyfig} * \oarg{2:loc} \marg{3:\keyvalsarg} \marg{4:image filename}
4491 %
4492 % A user-level macro to generate a figure with an image.
4493 % This may be used by itself, or inside a \env{keyfloats} or
4494 % \env{keysubfigs} environment.
4495 %
4496 % \shownesting{\cs{keyfig}}{
4497 % \shownesting{\cs{KFLT@keyflt}}{
4498 % \shownesting{\env{KFLT@boxouter}}{
4499 % \shownesting{
4500 % \begin{description}
4501 % \item[If \env{keysubfloats}:]
4502 % Uses a \env{subfigure}.
4503 % \item[If {[}H{]}, \env{keyfloats}, or inside a \env{keywrap}:]
4504 % Uses a \env{minipage}.
4505 % \item[If {[}W{]}:]
4506 % Uses a \env{wrapfloat} from the \pkg{wrapfig} package.
4507 % \item[If {[}M{]}:]
4508 % Uses a \env{KFLT@marginfloat}.
4509 % \item[Otherwise:]
4510 % Uses a \env{figure}.
4511 % \end{description}
4512 % }
4513 % {
4514 % \shownesting{\cs{KFLT@onefigureimage}}{
4515 % Rotate, frame, \cs{includegraphics}.
4516 % }
4517 % }
4518 % }
4519 % }
4520 % }
4521 %
4522 % \changes{v2.00}{2019/03/17}{Factored.}
4523 % \begin{macrocode}
4524 \NewDocumentCommand{\keyfig}{s O{tbp} +m m}
4525 {%
4526 \KFLT@keyflt{#1}{#2}{figure}{#3}{%
4527 \KFLT@onefigureimage{#4}%
4528 }%
4529 }
4530 % \end{macrocode}
4531 % \end{macro}
4532
4533
4534
4535 % \subsection{The \cs{keyfigbox} macro}
4536
4537 % \begin{macro}{\keyfigbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents}
4538 %
4539 % A user-level macro to generate a figure with arbitrary paragraph contents.
4540 % This may be used by itself, or inside a \env{keyfloats} or
4541 % \env{keysubtabs} environment.
4542 %
4543 % \shownesting{\cs{keyfigbox}}{
4544 % \shownesting{\env{KFLT@boxouter}}{
4545 % \showKFLTboxinner{Contents}
4546 % }
4547 % }
4548 %
4549 % \changes{v0.12}{2016/12/03}{Group around contents.}
4550 % \begin{macrocode}
4551 \NewDocumentCommand{\keyfigbox}{s O{tbp} +m +m}
4552 {%
4553 \KFLT@ignorespaces%
4554 \KFLT@trackrows%
4555 \KFLT@boxkeys{#3}{figure}%
4556 \begingroup%
4557 \KFLT@boxouter{#1}{#2}%
4558 \KFLT@boxinner%
4559 #4%
4560 \endKFLT@boxinner%
4561 \endKFLT@boxouter%
4562 \endgroup%
4563 \KFLT@ignorespaces%
4564 }
4565 % \end{macrocode}
4566 % \end{macro}
4567
4568
4569 % \subsection{The \cs{keyparbox} macro}
4570
4571 % \begin{macro}{\keyparbox} * \oarg{loc} \marg{\keyvalsarg} \marg{box contents}
4572 %
4573 % A user-level macro to generate a figure with arbitrary paragraph contents,
4574 % but no number or caption.
4575 % This is equal to a \cs{keyfigbox} with |cstar={}|.
4576 % This may be used by itself, or inside a \env{keyfloats} or
4577 % \env{keysubtabs} environment.
4578 %
4579 % \changes{v0.12}{2016/12/03}{Group around contents.}
4580 % \begin{macrocode}
4581 \NewDocumentCommand{\keyparbox}{s O{tbp} +m +m}
4582 {%
4583 \KFLT@ignorespaces%
4584 \KFLT@trackrows%
4585 \KFLT@boxkeys{#3}{figure}%
4586 % \end{macrocode}
4587 % Force |cstar={}|:
4588 % \begin{macrocode}
4589 \renewcommand{\KFLT@c}{}%
4590 \setboolean{KFLT@cstar}{true}%
4591 % \end{macrocode}
4592 % Continue like \cs{figbox}:
4593 % \begin{macrocode}
4594 \begingroup%
4595 \KFLT@boxouter{#1}{#2}%
4596 \KFLT@boxinner%
4597 #4%
4598 \endKFLT@boxinner%
4599 \endKFLT@boxouter%
4600 \endgroup%
4601 \KFLT@ignorespaces%
4602 }
4603 % \end{macrocode}
4604 % \end{macro}
4605
4606
4607 % \subsection{The \cs{keytab} macro}
4608
4609 % \begin{macro}{\keytab} * \oarg{loc} \marg{\keyvalsarg} \marg{tabular contents}
4610 %
4611 % A user-level macro to generate a table with tabular contents.
4612 % This may be used by itself, or inside a \env{keyfloats} or
4613 % \env{keysubtabs} environment.
4614 %
4615 % \shownesting{\cs{keytab}}{
4616 % \shownesting{\cs{keyflt}}{
4617 % \shownesting{\cs{KFLT@keyflt}}{
4618 % \shownesting{\env{KFLT@boxouter}}{
4619 % \showKFLTboxinner{Contents}
4620 % }
4621 % }
4622 % }
4623 % }
4624 %
4625 % \changes{v2.00}{2019/03/17}{Factored.}
4626 % \begin{macrocode}
4627 \NewDocumentCommand{\keytab}{s O{tbp} +m +m}
4628 {%
4629 \IfBooleanTF{#1}{%
4630 \keyflt*[#2]{table}{#3}{#4}%
4631 }{%
4632 \keyflt[#2]{table}{#3}{#4}%
4633 }%
4634 }
4635 % \end{macrocode}
4636 % \end{macro}
4637
4638
4639 % \subsection{The \env{keytable} environment}
4640
4641 % \begin{environment}{keytable} * \oarg{loc} \marg{\keyvalsarg}
4642 %
4643 % \shownesting{\env{keytable}}{
4644 % \shownesting{\cs{KFLT@keyfloatstart}, \cs{KFLT@keyfloatend}}{
4645 % \shownesting{\env{KFLT@boxouter}}{
4646 % \showKFLTboxinner{Contents}
4647 % }
4648 % }
4649 % }
4650 %
4651 % \begin{macrocode}
4652 \NewDocumentEnvironment{keytable}{s O{tbp} +m}
4653 {%
4654 \KFLT@keyfloatstart{#1}{#2}{table}{#3}%
4655 }%
4656 {%
4657 \KFLT@keyfloatend%
4658 }
4659 % \end{macrocode}
4660 % \end{environment}
4661
4662 % Extra code to track rows outside of the \env{keytable} environment,
4663 % \DescribeObject{Before \env{keytable}}
4664 % before it starts. This is done to allow nesting without losing track
4665 % of the prior level.
4666 %
4667 % \begin{macrocode}
4668 \BeforeBeginEnvironment{keytable}{%
4669 \KFLT@trackrows%
4670 }
4671 % \end{macrocode}
4672
4673
4674
4675 % \subsection{A row of floats}
4676
4677 % \begin{macro}{\KFLT@nonest} Error message if tried to nest subfloats.
4678 % \begin{macrocode}
4679 \newcommand*{\KFLT@nonest}{%
4680 \ifboolexpr{%
4681 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or
4682 bool {KFLT@inkeysubfloats}%
4683 }%
4684 {%
4685 \PackageError{keyfloat}%
4686 {%
4687 Cannot nest keysubfigs or keysubtabs.\MessageBreak%
4688 (Not in outer par mode.)%
4689 }%
4690 {%
4691 The subcaption package do not support nested environments,%
4692 \MessageBreak
4693 so the keyfloat package cannot place a\MessageBreak
4694 keysubfigs or keysubtabs environment inside another,%
4695 \MessageBreak
4696 or inside a keyfloats.%
4697 }%
4698 }%
4699 {}%
4700 }
4701 % \end{macrocode}
4702 % \end{macro}
4703
4704
4705 % \begin{macro}{\KFLT@LWR@hook@keyfloats} Used by \pkg{lwarp}.
4706 % \begin{macrocode}
4707 \newcommand*{\KFLT@LWR@hook@keyfloats}{}%
4708 % \end{macrocode}
4709 % \end{macro}
4710
4711
4712 % \begin{environment}{KFLT@LWR@hook@keyfloatsminipage} \marg{contents}
4713 %
4714 % Modified by \pkg{lwarp}.
4715 % \changes{v2.06}{2021/06/25}{Added vertical alignment.}
4716 % \begin{macrocode}
4717 \newenvironment*{KFLT@LWR@hook@keyfloatsminipage}[1]
4718 {\noindent\minipage[\KFLT@va]{#1}}
4719 {\endminipage}
4720 % \end{macrocode}
4721 % \end{environment}
4722
4723 % \begin{environment}{keyfloats} * \oarg{loc} \marg{num columns} \oarg{shared keys/values}
4724 %
4725 % User-level macro to create rows of figures/tables.
4726 % Wrapping occurs after the number of specified columns.
4727 % \env{keyfloats} environments may be nested to create
4728 % a vertical set of figures next to a single larger figure,
4729 % for example.
4730 %
4731 % Place \cs{keyfig}, \cs{keyfigbox}, and \cs{keytab} commands
4732 % inside the \env{keyfloats} environment.
4733 %
4734 % Note that |lw| linewidth keys may need to be adjusted inside
4735 % a \env{keyfloats}, \env{keysubfigs}, or \env{keysubtabs}, since
4736 % \cs{linewidth} changes depending on the number of columns.
4737 % Likewise, manually-selected |w| width and |h| tags may need to be
4738 % adjusted to prevent overflow.
4739 %
4740 % \shownesting{\env{keyfloats}}
4741 % {
4742 % \shownesting{
4743 % \begin{description}
4744 % \item[If {[}H{]}, nested, subfloats, or \env{keywrap}:]
4745 % Uses a \env{minipage}.
4746 % \item[If {[}W{]}:] Uses a \env{wrapfloat}.
4747 % \item[If {[}M{]}:] Uses \cs{KFLT@marginfloat}.
4748 % \item[Otherwise:] Uses a \env{figure}.
4749 % \end{description}
4750 % }{Contents}
4751 % }
4752 %
4753 % \changes{v0.15}{2017/05/12}{Adjustments for \protect\env{keywrap}.}
4754 %
4755 % \begin{macrocode}
4756 \NewDocumentEnvironment{keyfloats}{s O{tbp} m O{}}
4757 {%
4758 \KFLT@envignorespaces%
4759 % \end{macrocode}
4760 % A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
4761 % \begin{macrocode}
4762 \KFLT@LWR@hook@keyfloats%
4763 % \end{macrocode}
4764 % Track the depth:
4765 % \begin{macrocode}
4766 \addtocounter{KFLT@keyfloatdepth}{1}%
4767 % \end{macrocode}
4768 % Nest the group's keys.
4769 % \changes{v2.06}{2021/06/25}{Added shared keys.}
4770 % \begin{macrocode}
4771 \edef\KFLT@outersharedkeys{\KFLT@sharedkeys}%
4772 \edef\KFLT@sharedkeys{\KFLT@sharedkeys,#4}%
4773 % \end{macrocode}
4774 % If [H], nested, subfloats, or keywrap, use a minipage instead of a float:
4775 % \begin{macrocode}
4776 \ifboolexpr{%
4777 test {\ifstrequal{#2}{H}} or
4778 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
4779 bool {KFLT@inkeysubfloats} or
4780 bool {KFLT@keywrap}%
4781 }%
4782 % \end{macrocode}
4783 % Create an inline minipage:
4784 % \begin{macrocode}
4785 {% [H] or nested
4786 % \end{macrocode}
4787 % If nested, use different spacing as was computed in the outer nesting level:
4788 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
4789 % \begin{macrocode}
4790 \ifboolexpr{%
4791 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
4792 bool {KFLT@inkeysubfloats}
4793 }%
4794 {%
4795 % \end{macrocode}
4796 % Use the keys from the outer container.
4797 % Expansion required for \pkg{xkeyval}.
4798 % \changes{v2.06}{2021/06/25}{Added shared keys.}
4799 % \begin{macrocode}
4800 \edef\next{\noexpand\setkeys{KFLT@keys}{\KFLT@outersharedkeys}}%
4801 \next%
4802 % \end{macrocode}
4803 % Create the containing minipage:
4804 % \begin{macrocode}
4805 \KFLT@LWR@hook@keyfloatsminipage{\KFLT@rowboxwidth}%
4806 }%
4807 {%
4808 \vskip\intextsep%
4809 \KFLT@LWR@hook@keyfloatsminipage{\linewidth}%
4810 }%
4811 % \end{macrocode}
4812 % Reset font and color:
4813 % \changes{v2.01}{2019/09/11}{Fix: Font and color.}
4814 % \begin{macrocode}
4815 \normalcolor\reset@font\normalsize%
4816 % \end{macrocode}
4817 % If inside subfloats, generate subfigures by default:
4818 % \begin{macrocode}
4819 \ifbool{KFLT@inkeysubfloats}%
4820 {}%
4821 {\captionsetup*{type=figure}}%
4822 }% [H] or nested
4823 % \end{macrocode}
4824 % Isn't [H] or nested
4825 % \begin{macrocode}
4826 {% See if [W]:
4827 \ifstrequal{#2}{W}
4828 {% [W]:
4829 % \end{macrocode}
4830 % [W]:
4831 % \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [W].}
4832 % \begin{macrocode}
4833 \wrapfloat{figure}{O}{.5\linewidth}%
4834 \minipage{\linewidth}%
4835 % \end{macrocode}
4836 %
4837 % Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
4838 % \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
4839 % \begin{macrocode}
4840 \hbadness=10000\relax%
4841 % \end{macrocode}
4842 % \begin{macrocode}
4843 \normalcolor\reset@font\normalsize%
4844 }%
4845 {% not [H]:
4846 \ifstrequal{#2}{M}%
4847 {% [M]:
4848 % \end{macrocode}
4849 % [M]:
4850 % \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [M].}
4851 % \begin{macrocode}
4852 \KFLT@marginfloat{figure}%
4853 }%
4854 % \end{macrocode}
4855 % A normal figure:
4856 % \begin{macrocode}
4857 {% figure
4858 \IfBooleanTF{#1}% starred figure, two-col figure in a two-col format
4859 {\begin{figure*}[#2]}%
4860 {\begin{figure}[#2]}%
4861 }% figure
4862 }% not [H]
4863 }%
4864 % \end{macrocode}
4865 % Compute the width of each entry:
4866 % \begin{macrocode}
4867 \ifboolexpr{%
4868 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
4869 bool {KFLT@inkeysubfloats}
4870 }%
4871 % \end{macrocode}
4872 % Nested or subfloats:
4873 % \begin{macrocode}
4874 {\setlength{\KFLT@rowboxwidth}{.9\KFLT@rowboxwidth/\real{#3}}}%
4875 % \end{macrocode}
4876 % Keyfloats:
4877 % \begin{macrocode}
4878 {\setlength{\KFLT@rowboxwidth}{.9\linewidth/\real{#3}}}%
4879 % \end{macrocode}
4880 % Center the contents:
4881 % \begin{macrocode}
4882 \centering%
4883 % \end{macrocode}
4884 % Count columns using \cs{defcounter} for a local effect:
4885 % \begin{macrocode}
4886 \defcounter{KFLT@numcols}{#3}%
4887 \defcounter{KFLT@thiscol}{0}%
4888 }% starting keyfloats environment
4889 % \end{macrocode}
4890 %
4891 % When ending a \env{keyfloats} environment:
4892 % \begin{macrocode}
4893 {% ending keyfloats environment
4894 % \end{macrocode}
4895 % [H] or rows/subfigs? Close a minipage:
4896 % \begin{macrocode}
4897 \ifboolexpr{%
4898 test {\ifstrequal{#2}{H}} or
4899 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or
4900 bool {KFLT@inkeysubfloats} or
4901 bool {KFLT@keywrap}
4902 }%
4903 {% was [H], etc.
4904 \endKFLT@LWR@hook@keyfloatsminipage%
4905 % \end{minipage}%
4906 % \end{macrocode}
4907 % Spacing if nested or not:
4908 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
4909 % \begin{macrocode}
4910 \ifboolexpr{
4911 test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{0}} or
4912 bool {KFLT@keywrap}
4913 }%
4914 {}{% not nested
4915 \vskip\intextsep%
4916 }%
4917 }% was [H], etc.
4918 % \end{macrocode}
4919 % Not [H]:
4920 % \begin{macrocode}
4921 {% not [H], etc.
4922 \ifstrequal{#2}{W}%
4923 {% [W]:
4924 % \end{macrocode}
4925 % [W]:
4926 % \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [W].}
4927 % \begin{macrocode}
4928 \endminipage%
4929 \endwrapfloat%
4930 }%
4931 {%
4932 \ifstrequal{#2}{M}%
4933 {% [M]:
4934 % \end{macrocode}
4935 % [M]:
4936 % \changes{v2.01}{2019/09/16}{Added \env{keyfloats} [M].}
4937 % \begin{macrocode}
4938 \endKFLT@marginfloat%
4939 }%
4940 {% figure
4941 % \end{macrocode}
4942 % A figure:
4943 % \begin{macrocode}
4944 \IfBooleanTF{#1}% starred figure?
4945 {\end{figure*}}{\end{figure}}%
4946 }%
4947 }%
4948 }% not [H], etc.
4949 % \end{macrocode}
4950 % Unnest the environment:
4951 % \begin{macrocode}
4952 \addtocounter{KFLT@keyfloatdepth}{-1}%
4953 \KFLT@envignorespaces%
4954 }
4955 % \end{macrocode}
4956 % \end{environment}
4957
4958
4959
4960 % Extra code to track rows outside of the \env{keyfloats} environment,
4961 % \DescribeObject{Before \env{keyfloats}}
4962 % before it starts. This is done to allow nesting without losing track
4963 % of the prior level.
4964 %
4965 % \begin{macrocode}
4966 \BeforeBeginEnvironment{keyfloats}{%
4967 \KFLT@trackrows%
4968 }
4969 % \end{macrocode}
4970
4971
4972 % \subsection{Subfloats}
4973
4974 % \begin{macro}{\KFLT@subgrpdefaults} Sets defaults before reading the keys.
4975 % \begin{macrocode}
4976 \newcommand*{\KFLT@subgrpdefaults}{%
4977 \setboolean{KFLT@subgrpcont}{false}%
4978 \renewcommand{\KFLT@subgrpc}{}%
4979 \setboolean{KFLT@subgrpcstar}{false}%
4980 \renewcommand{\KFLT@subgrpsc}{}%
4981 \setboolean{KFLT@subgrpscgiven}{false}%
4982 \renewcommand{\KFLT@subgrptype}{figure}%
4983 \renewcommand{\KFLT@subgrpl}{}%
4984 \renewcommand{\KFLT@subgrpap}{}%
4985 \renewcommand{\KFLT@subgrpaf}{}%
4986 \renewcommand{\KFLT@subgrpal}{}%
4987 \renewcommand{\KFLT@subgrpas}{}%
4988 \renewcommand{\KFLT@subgrpaup}{}%
4989 \renewcommand{\KFLT@subgrpauf}{}%
4990 \renewcommand{\KFLT@subgrpaul}{}%
4991 \renewcommand{\KFLT@subgrpaus}{}%
4992 \renewcommand{\KFLT@subgrpt}{}%
4993 \renewcommand{\KFLT@subgrptextalign}{}%
4994 }
4995 % \end{macrocode}
4996 % \end{macro}
4997
4998
4999 % \DescribeBoolean{KFLT@subcaptionistop} Saves the value of \cs{caption@position},
5000 % which may become unreliable if using Komascript and
5001 % \begin{sourceverb}
5002 % \captionsetup[table]{position=above}
5003 % \end{sourceverb}
5004 %
5005 % \begin{macrocode}
5006 \newbool{KFLT@subcaptionistop}
5007 % \end{macrocode}
5008
5009
5010
5011 % \begin{macro}{\KFLT@subfloats} \marg{starred?} \marg{loc} \marg{cols} \marg{\keyvalsarg}
5012 %
5013 % \shownesting{\cs{KFLT@subfloats}, \cs{KTLT@endsubfloats}}
5014 % {
5015 % \shownesting{
5016 % \begin{description}
5017 % \item[If {[}H{]} or \env{keywrap}:] Uses a \env{minipage}.
5018 % \item[If {[}W{]}:] Uses a \env{wrapfloat} and a \env{minipage}.
5019 % \item[If {[}M{]}:] Uses \cs{KFLT@marginfloat}.
5020 % \item[Otherwise:] Uses a \env{subfigure}, etc.
5021 % \end{description}
5022 % }
5023 % {Contents}
5024 % }
5025 %
5026 % \changes{v0.13}{2017/01/16}{Fix: Subfloat type selection.}
5027 % \changes{v0.15}{2017/05/12}{Adjustments for \protect\env{keywrap}.}
5028 %
5029 % Start a subfloat environment
5030 % \begin{macrocode}
5031 \NewDocumentCommand{\KFLT@subfloats}{m m m +m}
5032 {%
5033 \KFLT@envignorespaces%
5034 % \end{macrocode}
5035 % Parse the key-value combinations:
5036 % \begin{macrocode}
5037 \setkeys{KFLT@subgrpkeys}{#4}%
5038 % \end{macrocode}
5039 % Nest the environment:
5040 % \begin{macrocode}
5041 \setboolean{KFLT@inkeysubfloats}{true}%
5042 % \end{macrocode}
5043 % Figure out the width of each subfloat.
5044 % If starred, use the full-page \cs{textwidth}, else use \cs{linewidth}.
5045 % .9 is used to leave a little room between columns.
5046 % \begin{macrocode}
5047 \IfBooleanTF{#1}%
5048 {\setlength{\KFLT@rowboxwidth}{.9\textwidth/\real{#3}}}%
5049 {\setlength{\KFLT@rowboxwidth}{.9\linewidth/\real{#3}}}%
5050 % \end{macrocode}
5051 % If [H], or in a \env{keywrap}, create an inline minipage:
5052 % \changes{v2.01}{2019/09/11}{Fix: Font and color.}
5053 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
5054 % \begin{macrocode}
5055 \ifboolexpr{%
5056 test {\ifstrequal{#2}{H}} or
5057 bool {KFLT@keywrap}
5058 }%
5059 {%
5060 \vskip\intextsep\noindent\begin{minipage}{\linewidth}%
5061 \normalcolor\reset@font\normalsize%
5062 }%
5063 % \end{macrocode}
5064 % Not [H]:
5065 % \begin{macrocode}
5066 {%
5067 \ifstrequal{#2}{W}%
5068 {% [W]
5069 % \end{macrocode}
5070 % [W]:
5071 % \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [W].}
5072 % \begin{macrocode}
5073 \wrapfloat{\KFLT@subgrptype}{O}{.5\linewidth}%
5074 \setlength{\KFLT@rowboxwidth}{.5\KFLT@rowboxwidth}%
5075 \minipage{\linewidth}%
5076 % \end{macrocode}
5077 %
5078 % Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
5079 % \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
5080 % \begin{macrocode}
5081 \hbadness=10000\relax%
5082 % \end{macrocode}
5083 % \begin{macrocode}
5084 \normalcolor\reset@font\normalsize%
5085 }%
5086 {% not [H]:
5087 \ifstrequal{#2}{M}%
5088 {% [M]:
5089 % \end{macrocode}
5090 % [M]:
5091 % \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [M].}
5092 % \begin{macrocode}
5093 \KFLT@marginfloat{\KFLT@subgrptype}%
5094 \setlength{\KFLT@rowboxwidth}{.9\marginparwidth/\real{#3}}%
5095 }% [M]
5096 {% subfloat
5097 % \end{macrocode}
5098 % A subfloat:
5099 % \begin{macrocode}
5100 \IfBooleanTF{#1}%
5101 {\begin{\KFLT@subgrptype*}[#2]}%
5102 {\begin{\KFLT@subgrptype}[#2]}%
5103 }%
5104 }% not [H]
5105 }%
5106 % \end{macrocode}
5107 % Set the caption type:
5108 % \begin{macrocode}
5109 \captionsetup*{type=\KFLT@subgrptype}%
5110 % \end{macrocode}
5111 % Process continued floats:
5112 % \begin{macrocode}
5113 \ifbool{KFLT@subgrpcont}%
5114 {\ContinuedFloat}%
5115 {}%
5116 % \end{macrocode}
5117 % Center the contents:
5118 % \begin{macrocode}
5119 \center\unskip%
5120 % \end{macrocode}
5121 % Place the caption above the contents depending on \pkg{caption} \optn{position} option:
5122 % \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
5123 % \begin{macrocode}
5124 \caption@iftop%
5125 {\booltrue{KFLT@subcaptionistop}}%
5126 {\boolfalse{KFLT@subcaptionistop}}%
5127 \ifbool{KFLT@subcaptionistop}{\KFLT@caption{subgrp}}{}%
5128 % \end{macrocode}
5129 % Not yet started a row of subfloats.
5130 % The use of \cs{defcounter} makes these changes local.
5131 % \begin{macrocode}
5132 \defcounter{KFLT@numcols}{#3}%
5133 \defcounter{KFLT@thiscol}{0}%
5134 % \end{macrocode}
5135 % Creat a group for the subfloats.
5136 % Necessary in case they change \cs{tdartisttextcenter}, etc.
5137 % \begin{macrocode}
5138 \begingroup%
5139 }
5140 % \end{macrocode}
5141 % \end{macro}
5142
5143
5144
5145 % \begin{macro}{\KFLT@endsubfloats} \marg{starred?} \marg{loc}
5146 %
5147 % Ends a subfloat environment.
5148 % \begin{macrocode}
5149 \newcommand*{\KFLT@endsubfloats}[2]{%
5150 % \end{macrocode}
5151 % End the group containing the subfloats:
5152 % \begin{macrocode}
5153 \endgroup%
5154 \unskip%
5155 \endcenter%
5156 % \end{macrocode}
5157 % A little extra space at the bottom:
5158 % \begin{macrocode}
5159 \par\addvspace{\bigskipamount}%
5160 % \end{macrocode}
5161 % Optionally print artist's name and additional text:
5162 % \begin{macrocode}
5163 \KFLT@addartisttext{subgrp}%
5164 % \end{macrocode}
5165 % Place the caption below the contents depending on \pkg{caption} \optn{position} option:
5166 % \changes{v2.01}{2019/09/11}{Fix: Positions with \brand{Komascript}.}
5167 % \begin{macrocode}
5168 \ifbool{KFLT@subcaptionistop}{}{\KFLT@caption{subgrp}}%
5169 % \end{macrocode}
5170 % End the float or minipage:
5171 % \changes{v2.01}{2019/09/14}{Improved vertical space.}
5172 % \begin{macrocode}
5173 \ifboolexpr{%
5174 test {\ifstrequal{#2}{H}} or
5175 bool{KFLT@keywrap}
5176 }%
5177 {\end{minipage}\vskip\intextsep}% was [H]
5178 {% not [H]:
5179 \ifstrequal{#2}{W}%
5180 {% [W]
5181 % \end{macrocode}
5182 % \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [W].}
5183 % \begin{macrocode}
5184 \endminipage%
5185 \endwrapfloat%
5186 }%
5187 {% not [W]:
5188 \ifstrequal{#2}{M}%
5189 {% [M]:
5190 % \end{macrocode}
5191 % \changes{v2.01}{2019/09/16}{Added \env{keysubfloats} [M].}
5192 % \begin{macrocode}
5193 \endKFLT@marginfloat%
5194 }% [M]
5195 {% subfloat
5196 \IfBooleanTF{#1}% starred?
5197 {\end{\KFLT@subgrptype*}}%
5198 {\end{\KFLT@subgrptype}}%
5199 }%
5200 }% not [W]
5201 }% not [H]
5202 % \end{macrocode}
5203 % Unnest the environment:
5204 % \begin{macrocode}
5205 \setboolean{KFLT@inkeysubfloats}{false}%
5206 \KFLT@envignorespaces%
5207 }
5208 % \end{macrocode}
5209 % \end{macro}
5210
5211
5212 % \begin{macro}{\KFLT@LWR@hook@keysubfloats} Used by \pkg{lwarp}.
5213 % \begin{macrocode}
5214 \newcommand*{\KFLT@LWR@hook@keysubfloats}{}
5215 % \end{macrocode}
5216 % \end{macro}
5217
5218 % \begin{environment}{KFLT@keysubfloats} \marg{1: star?}
5219 % \marg{2: loc} \marg{3: float type} \marg{4: numcols}
5220 % \marg{5: \keyvalsarg} \marg{6: shared keys/values}
5221 %
5222 % A group of subfigures typeset in rows.
5223 %
5224 % \shownesting{\env{KFLT@keysubfloats}}
5225 % {
5226 % \shownesting{\cs{KFLT@subfloats}, \cs{KFLT@endsubfloats}}
5227 % {
5228 % \shownesting{
5229 % \begin{description}
5230 % \item[If {[}H{]} or \env{keywrap}:] Uses a \env{minipage}.
5231 % \item[If {[}W{]}:] Uses a \env{wrapfloat} and a \env{minipage}.
5232 % \item[If {[}M{]}:] Uses \cs{KFLT@marginfloat}.
5233 % \item[Otherwise:] Uses a \env{subfigure}, etc.
5234 % \end{description}
5235 % }
5236 % {Contents}
5237 % }
5238 % }
5239 %
5240 % \begin{macrocode}
5241 \NewDocumentEnvironment{KFLT@keysubfloats}{m m m m +m m}
5242 {%
5243 % \end{macrocode}
5244 % Error if trying to nest environments:
5245 % \begin{macrocode}
5246 \KFLT@nonest%
5247 % \end{macrocode}
5248 % A hook for \pkg{lwarp} to set \cs{linewidth}, etc.
5249 % \begin{macrocode}
5250 \KFLT@LWR@hook@keysubfloats%
5251 % \end{macrocode}
5252 % Default the options:
5253 % \begin{macrocode}
5254 \KFLT@subgrpdefaults%
5255 % \end{macrocode}
5256 % Nest the group's keys:
5257 % \changes{v2.06}{2021/06/25}{Added shared keys.}
5258 % \begin{macrocode}
5259 \edef\KFLT@sharedkeys{\KFLT@sharedkeys,#6}%
5260 % \end{macrocode}
5261 % Default to figure float type:
5262 % \begin{macrocode}
5263 \renewcommand{\KFLT@subgrptype}{#3}%
5264 % \end{macrocode}
5265 % Start of the environment:
5266 % \begin{macrocode}
5267 \KFLT@subfloats{#1}{#2}{#4}{#5}%
5268 }% the start of the environment
5269 % \end{macrocode}
5270 % end of the environment:
5271 % \begin{macrocode}
5272 {%
5273 \KFLT@endsubfloats{#1}{#2}%
5274 }
5275 % \end{macrocode}
5276 % \end{environment}
5277 %
5278 %
5279 %
5280 % \begin{environment}{keysubfloats} * \oarg{2: loc} \marg{3: float type}
5281 % \marg{4: numcols} \marg{5: \keyvalsarg} \oarg{6: shared \keyvalsarg}
5282 %
5283 % A group of subfloats typeset in rows.
5284 %
5285 % \shownesting{\env{keysubfloats}, \env{keysubfigs}, or \env{keysubtabs}}
5286 % {
5287 % \shownesting{\env{KFLT@keysubfloats}}
5288 % {
5289 % \shownesting{\cs{KFLT@subfloats}, \cs{KFLT@endsubfloats}}
5290 % {
5291 % \shownesting{
5292 % \begin{description}
5293 % \item[If {[}H{]} or \env{keywrap}:] Uses a \env{minipage}.
5294 % \item[If {[}W{]}:] Uses a \env{wrapfloat} and a \env{minipage}.
5295 % \item[If {[}M{]}:] Uses \cs{KFLT@marginfloat}.
5296 % \item[Otherwise:] Uses a \env{subfigure}, etc.
5297 % \end{description}
5298 % }
5299 % {Contents}
5300 % }
5301 % }
5302 % }
5303 %
5304 % \changes{v2.06}{2021/06/25}{Added shared keys.}
5305 % \begin{macrocode}
5306 \NewDocumentEnvironment{keysubfloats}{s O{tbp} m m +m O{}}
5307 {\KFLT@keysubfloats{#1}{#2}{#3}{#4}{#5}{#6}}
5308 {\endKFLT@keysubfloats}
5309 % \end{macrocode}
5310 % \end{environment}
5311
5312
5313 % \begin{environment}{keysubfigs} * \oarg{2: loc} \marg{3: numcols}
5314 % \marg{4: \keyvalsarg} \oarg{5: shared \keyvalsarg}
5315 %
5316 % A group of subfigures typeset in rows.
5317 %
5318 % \changes{v2.06}{2021/06/25}{Added shared keys.}
5319 % \begin{macrocode}
5320 \NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m O{}}
5321 {\KFLT@keysubfloats{#1}{#2}{figure}{#3}{#4}{#5}}
5322 {\endKFLT@keysubfloats}
5323 % \end{macrocode}
5324 % \end{environment}
5325
5326
5327 % \begin{environment}{keysubtabs} * \oarg{2: loc} \marg{3: numcols}
5328 % \marg{4: \keyvalsarg} \oarg{5: shared \keyvalsarg}
5329 %
5330 % A group of subtables typeset in rows.
5331 % \changes{v2.06}{2021/06/25}{Added shared keys.}
5332 % \begin{macrocode}
5333 \NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m O{}}
5334 {\KFLT@keysubfloats{#1}{#2}{table}{#3}{#4}{#5}}
5335 {\endKFLT@keysubfloats}
5336 % \end{macrocode}
5337 % \end{environment}
5338 %
5339 %
5340 %
5341 %
5342 % \subsection{Margin floats}
5343 %
5344 % \begin{environment}{KFLT@marginfloat} \oarg{offset} \marg{type}
5345 %
5346 % \shownesting{\env{KFLT@marginfloat}}
5347 % {
5348 % \shownesting{\cs{marginpar}}
5349 % {\shownesting{\env{minipage}}{Contents}}
5350 % }
5351 %
5352 % \changes{v2.01}{2019/09/11}{Fix: Font and color.}
5353 % \begin{macrocode}
5354 \newsavebox{\KFLT@marginfloatbox}
5355
5356 \NewDocumentEnvironment{KFLT@marginfloat}{O{-1.2ex} m}
5357 {% start
5358 \FloatBarrier% keep floats in order
5359 \KFLT@envignorespaces%
5360 \begin{lrbox}{\KFLT@marginfloatbox}%
5361 \begin{minipage}{\marginparwidth}%
5362 \captionsetup{type=#2}%
5363 \hbox{}\vspace*{#1}%
5364 \noindent%
5365 \normalcolor\reset@font\normalsize%
5366 }% start
5367 {% end
5368 \end{minipage}%
5369 \end{lrbox}%
5370 \marginpar{\usebox{\KFLT@marginfloatbox}}%
5371 \KFLT@envignorespaces%
5372 }% end
5373 % \end{macrocode}
5374 % \end{environment}
5375 %
5376 %
5377 % Provided in case \pkg{tufte-book} is not loaded:
5378 %
5379 % \begin{environment}{marginfigure} \oarg{offset}
5380 %
5381 % \shownesting{\env{marginfigure}}
5382 % {
5383 % \shownesting{\env{KFLT@marginfloat}}
5384 % {
5385 % \shownesting{\cs{marginpar}}
5386 % {\shownesting{\env{minipage}}{Contents}}
5387 % }
5388 % }
5389 %
5390 %
5391 % \changes{v0.12}{2016/12/03}{Added.}
5392 % \begin{macrocode}
5393 \ProvideDocumentEnvironment{marginfigure}{O{-1.2ex}}
5394 {\begin{KFLT@marginfloat}[#1]{figure}}
5395 {\end{KFLT@marginfloat}}
5396 % \end{macrocode}
5397 % \end{environment}
5398 %
5399 %
5400 % \begin{environment}{margintable} \oarg{offset}
5401 % \changes{v0.12}{2016/12/03}{Added.}
5402 % \begin{macrocode}
5403 \ProvideDocumentEnvironment{margintable}{O{-1.2ex}}
5404 {\begin{KFLT@marginfloat}[#1]{table}}
5405 {\end{KFLT@marginfloat}}
5406 % \end{macrocode}
5407 % \end{environment}
5408 %
5409 %
5410 %
5411 %
5412 % \subsection{Wrapped floats}
5413 %
5414 % \DescribeBoolean{KFL@keywrap} Tells the next keyfloat to wrap around some text.
5415 % \begin{macrocode}
5416 \newboolean{KFLT@keywrap}
5417 \boolfalse{KFLT@keywrap}
5418 % \end{macrocode}
5419 %
5420 %
5421 % \DescribeLength{\KFLT@keywrapwidth} The width of the object to be wrapped beside the text.
5422 % \begin{macrocode}
5423 \newlength{\KFLT@keywrapwidth}
5424 % \end{macrocode}
5425 %
5426 % \DescribeLength{\KFLT@keywrapparskip} The \cs{parskip} outside of the keywrap.
5427 % \begin{macrocode}
5428 \newlength{\KFLT@keywrapparskip}
5429 % \end{macrocode}
5430 %
5431 % \DescribeLength{\KFLT@keywrapparindent} The \cs{parindent} outside of the keywrap.
5432 % \begin{macrocode}
5433 \newlength{\KFLT@keywrapparindent}
5434 % \end{macrocode}
5435 %
5436 %
5437 % \begin{environment}{keywrap} \marg{width} \marg{wrapped content}
5438 %
5439 % The main text is placed in a minipage to the left,
5440 % and the wrapped content is later placed in another minipage to the right.
5441 %
5442 % \shownesting{\env{keywrap}}
5443 % {
5444 % \shownesting[.4]{\env{minipage}}
5445 % {Main text.\newline Multiple paragraphs.}
5446 % \hfill
5447 % \cs{hfill}
5448 % \hfill
5449 % \shownesting*[.35]{\env{minipage}}
5450 % {Wrapped content.}
5451 % }
5452 %
5453 % \changes{v0.15}{2017/05/11}{Added.}
5454 % \changes{v2.01}{2019/09/11}{Fix: Font and color.}
5455 % \changes{v2.01}{2019/09/16}{Fix: \cs{noindent}.}
5456 % \begin{macrocode}
5457 \DeclareDocumentEnvironment{keywrap}{m +m}%
5458 {%
5459 \par\noindent%
5460 \setlength{\KFLT@keywrapwidth}{\linewidth}%
5461 \addtolength{\KFLT@keywrapwidth}{-#1}%
5462 \addtolength{\KFLT@keywrapwidth}{-2em}%
5463 \minipage[t]{\KFLT@keywrapwidth}%
5464 %
5465 \setlength{\parskip}{\KFLT@keywrapparskip}%
5466 \setlength{\parindent}{\KFLT@keywrapparindent}%
5467 \booltrue{KFLT@keywrap}%
5468 }
5469 {%
5470 \par%
5471 \endminipage%
5472 \hfill%
5473 \begin{minipage}[t]{#1}%
5474 \booltrue{KFLT@keywrap}%
5475 \normalcolor\reset@font\normalsize%
5476 % \end{macrocode}
5477 %
5478 % Inside this minipage, temporarily prevent underfull \cs{hbox} warnings:
5479 % \changes{v2.02}{2021/05/28}{Avoid underfull \cs{hbox} warning.}
5480 % \begin{macrocode}
5481 \hbadness=10000\relax%
5482 % \end{macrocode}
5483 % \begin{macrocode}
5484 #2%
5485 \par%
5486 \unskip\vspace{\smallskipamount}%
5487 \end{minipage}%
5488 \par%
5489 }
5490
5491 \BeforeBeginEnvironment{keywrap}{%
5492 \setlength{\KFLT@keywrapparskip}{\parskip}%
5493 \setlength{\KFLT@keywrapparindent}{\parindent}%
5494 }
5495 % \end{macrocode}
5496 %
5497 % \end{environment}
5498 %
5499 %
5500 % \clearpage
5501 %
5502 % \section{\pkg{keyfloat} package maintenance}
5503 %
5504 % To compile \filenm{keyfloat.sty} and \cs{keyfloat.pdf}
5505 % from \filenm{keyfloat.dtx} and \filenm{keyfloat.ins}:
5506 %
5507 % \begin{sourceverb}
5508 % pdflatex keyfloat.ins
5509 % pdflatex keyfloat.dtx
5510 % pdflatex keyfloat.dtx
5511 % pdflatex keyfloat.dtx
5512 % makeindex -s gglo.ist -o keyfloat.gls keyfloat.glo
5513 % splitindex keyfloat.idx -- -s gind.ist
5514 % pdflatex keyfloat.dtx
5515 % pdflatex keyfloat.dtx
5516 % \end{sourceverb}
5517 %
5518 %
5519 % \iffalse
5520 %</package>
5521 % \fi
5522 %
5523 %
5524 %
5525 %
5526 % \clearpage
5527 % \pagestyle{plain}
5528 %
5529 % \renewcommand{\partname}{}
5530 % \renewcommand{\thepart}{}
5531 % ^^A \part{Change History and Index}
5532 %
5533 %
5534 % \Finale
5535 %
5536 \endinput