From af70cd8f8e37de544dc2ea4f05fc755842569c46 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 29 Jun 2021 19:55:06 +0000 Subject: keyfloat (29jun21) git-svn-id: svn://tug.org/texlive/trunk@59759 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty | 142 ++++++++++++++++------ 1 file changed, 102 insertions(+), 40 deletions(-) (limited to 'Master/texmf-dist/tex/latex/keyfloat') diff --git a/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty b/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty index a31f6ea7c75..5b90a20a7c3 100644 --- a/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty +++ b/Master/texmf-dist/tex/latex/keyfloat/keyfloat.sty @@ -18,7 +18,8 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{keyfloat} - [2021/06/11 v2.05 Key/value interface for floats and subfloats.] + [2021/06/29 v2.06 Key/value interface for floats and subfloats.] + @@ -187,13 +188,16 @@ \newlength{\KFLT@w} \define@key{KFLT@keys}{h}{\setlength{\KFLT@h}{#1}} \newlength{\KFLT@h} +\define@key{KFLT@keys}{kar}[false]{% + \renewcommand{\KFLT@keepaspectratio}{keepaspectratio}% +} +\newcommand{\KFLT@keepaspectratio}{} \define@key{KFLT@keys}{s}{\renewcommand{\KFLT@s}{#1}} \newcommand*{\KFLT@s}{1} \define@key{KFLT@keys}{r}{\renewcommand{\KFLT@r}{#1}} \newcommand*{\KFLT@r}{0} \define@key{KFLT@keys}{f}[true]{\setboolean{KFLT@f}{#1}} \newboolean{KFLT@f} - \define@key{KFLT@keys}{ft}[true]{\setboolean{KFLT@ft}{#1}} \newboolean{KFLT@ft} @@ -364,6 +368,20 @@ {}% no frame }% not looseframe } +\newlength{\KFLT@testwidth} +\newcommand*{\KFLT@includegraphics}[2][]{% + \settowidth{\KFLT@testwidth}{\includegraphics[#1]{#2}}% + \ifboolexpr{% + test {\ifdimgreater{\KFLT@testwidth}{\linewidth-.01pt}} and + test {\ifdimless{\KFLT@testwidth}{\linewidth+1pt}} + }% + {\setlength{\KFLT@testwidth}{\linewidth-.01pt}}% + {}% + \ifdimgreater{\KFLT@testwidth}{\linewidth}{% + \PackageWarning{keyfloat}{The image is wider than the line width}% + }{}% + \includegraphics[#1]{#2}% +} \NewDocumentCommand{\KFLT@onefigureimage}{m}% {% \begin{lrbox}{\KFLT@envbox}% @@ -373,23 +391,55 @@ {% width is given \ifdimgreater{\KFLT@h}{0pt}% {% w and h - \includegraphics% - [scale=\KFLT@s,% - width=\KFLT@imagewidth,height=\KFLT@h]{#1}% + \KFLT@includegraphics[% + scale=\KFLT@s,% + width=\KFLT@imagewidth,% + height=\KFLT@h,% + \KFLT@keepaspectratio,% + ]{#1}% }% w and h {% only w - \includegraphics% - [scale=\KFLT@s,width=\KFLT@imagewidth]{#1}% + \KFLT@includegraphics[% + scale=\KFLT@s,% + width=\KFLT@imagewidth,% + \KFLT@keepaspectratio,% + ]{#1}% }% only w }% width is given {% width is not given \ifdimgreater{\KFLT@h}{0pt}% - {\includegraphics[scale=\KFLT@s,height=\KFLT@h]{#1}}% - {\includegraphics[scale=\KFLT@s]{#1}}% + {% + \KFLT@includegraphics[% + scale=\KFLT@s,% + height=\KFLT@h,% + \KFLT@keepaspectratio,% + ]{#1}% + }% + {% + \KFLT@includegraphics[% + scale=\KFLT@s,% + \KFLT@keepaspectratio,% + ]{#1}% + }% }% width is not given }% not linewidth {% linewidth given - \includegraphics[scale=\KFLT@s,width=\KFLT@imagewidth]{#1}% + \ifdimgreater{\KFLT@h}{0pt}% + {% lw and h given + \KFLT@includegraphics[% + scale=\KFLT@s,% + width=\KFLT@imagewidth,% + height=\KFLT@h,% + \KFLT@keepaspectratio,% + ]{#1}% + }% + {% lw w/o h + \KFLT@includegraphics[% + scale=\KFLT@s,% + width=\KFLT@imagewidth,% + \KFLT@keepaspectratio,% + ]{#1}% + }% }% \end{lrbox}% \unskip% @@ -503,17 +553,22 @@ \addcontentsline{\csuse{ext@\KFLT@listtype}}% {\csuse{KFLT@#1type}}{\KFLT@sc}% }% non-empty cstar and sc - \KFLT@docaption*{\csuse{KFLT@#1c}}{#1}% + \ifcsempty{KFLT@#1c}% + {\KFLT@docaption*{}{#1}}% + {\KFLT@docaption*{\csuse{KFLT@#1c}}{#1}}% }% }% starred caption {% unstarred caption \ifcsempty{KFLT@#1sc}% {% no short cap - \KFLT@docaption{\csuse{KFLT@#1c}}{#1}% + \ifcsempty{KFLT@#1c}% + {\KFLT@docaption{}{#1}}% + {\KFLT@docaption{\csuse{KFLT@#1c}}{#1}}% }% no short cap {% short cap - \KFLT@docaption[\csuse{KFLT@#1sc}]% - {\csuse{KFLT@#1c}}{#1}% + \ifcsempty{KFLT@#1c}% + {\KFLT@docaption[\csuse{KFLT@#1sc}]{}{#1}}% + {\KFLT@docaption[\csuse{KFLT@#1sc}]{\csuse{KFLT@#1c}}{#1}}% }% short cap \ifcsempty{KFLT@#1l}% {}% @@ -543,6 +598,7 @@ \renewcommand{\KFLT@lw}{}% \setlength{\KFLT@w}{0pt}% \setlength{\KFLT@h}{0pt}% + \renewcommand{\KFLT@keepaspectratio}{}% \renewcommand{\KFLT@s}{1}% \renewcommand{\KFLT@r}{0}% \setboolean{KFLT@f}{false}% @@ -681,10 +737,14 @@ \par% }% endkeyboxinner +\newcommand*{\KFLT@sharedkeys}{} + \NewDocumentCommand{\KFLT@boxkeys}{+m m} {% \KFLT@defaults% \renewcommand{\KFLT@type}{#2}% + \edef\next{\noexpand\setkeys{KFLT@keys}{\KFLT@sharedkeys}}% + \next% \setkeys{KFLT@keys}{#1}% } @@ -756,7 +816,9 @@ }% not subfloat \ifbool{KFLT@cont}{\ContinuedFloat}{}% \KFLT@findwidths% - \caption@iftop{\booltrue{KFLT@captionistop}}{\boolfalse{KFLT@captionistop}}% + \caption@iftop% + {\booltrue{KFLT@captionistop}}% + {\boolfalse{KFLT@captionistop}}% \ifbool{KFLT@captionistop}{\KFLT@caption{}}{}% \center\unskip% }% boxouter @@ -987,9 +1049,11 @@ (Not in outer par mode.)% }% {% - The subcaption package do not support nested environments,\MessageBreak + The subcaption package do not support nested environments,% + \MessageBreak so the keyfloat package cannot place a\MessageBreak - keysubfigs or keysubtabs environment inside another,\MessageBreak + keysubfigs or keysubtabs environment inside another,% + \MessageBreak or inside a keyfloats.% }% }% @@ -999,14 +1063,16 @@ \newcommand*{\KFLT@LWR@hook@keyfloats}{}% \newenvironment*{KFLT@LWR@hook@keyfloatsminipage}[1] - {\noindent\minipage{#1}} - {\endminipage}% + {\noindent\minipage[\KFLT@va]{#1}} + {\endminipage} -\NewDocumentEnvironment{keyfloats}{s O{tbp} m} +\NewDocumentEnvironment{keyfloats}{s O{tbp} m O{}} {% \KFLT@envignorespaces% \KFLT@LWR@hook@keyfloats% \addtocounter{KFLT@keyfloatdepth}{1}% + \edef\KFLT@outersharedkeys{\KFLT@sharedkeys}% + \edef\KFLT@sharedkeys{\KFLT@sharedkeys,#4}% \ifboolexpr{% test {\ifstrequal{#2}{H}} or test {\ifnumgreater{\value{KFLT@keyfloatdepth}}{1}} or @@ -1019,6 +1085,8 @@ bool {KFLT@inkeysubfloats} }% {% + \edef\next{\noexpand\setkeys{KFLT@keys}{\KFLT@outersharedkeys}}% + \next% \KFLT@LWR@hook@keyfloatsminipage{\KFLT@rowboxwidth}% }% {% @@ -1168,7 +1236,9 @@ {\ContinuedFloat}% {}% \center\unskip% - \caption@iftop{\booltrue{KFLT@subcaptionistop}}{\boolfalse{KFLT@subcaptionistop}}% + \caption@iftop% + {\booltrue{KFLT@subcaptionistop}}% + {\boolfalse{KFLT@subcaptionistop}}% \ifbool{KFLT@subcaptionistop}{\KFLT@caption{subgrp}}{}% \defcounter{KFLT@numcols}{#3}% \defcounter{KFLT@thiscol}{0}% @@ -1211,11 +1281,12 @@ \newcommand*{\KFLT@LWR@hook@keysubfloats}{} -\NewDocumentEnvironment{KFLT@keysubfloats}{m m m m +m} +\NewDocumentEnvironment{KFLT@keysubfloats}{m m m m +m m} {% \KFLT@nonest% \KFLT@LWR@hook@keysubfloats% \KFLT@subgrpdefaults% + \edef\KFLT@sharedkeys{\KFLT@sharedkeys,#6}% \renewcommand{\KFLT@subgrptype}{#3}% \KFLT@subfloats{#1}{#2}{#4}{#5}% }% the start of the environment @@ -1223,26 +1294,17 @@ \KFLT@endsubfloats{#1}{#2}% } -\NewDocumentEnvironment{keysubfloats}{s O{tbp} m m +m} -{% - \KFLT@keysubfloats{#1}{#2}{#3}{#4}{#5}% -}{% - \endKFLT@keysubfloats% -} +\NewDocumentEnvironment{keysubfloats}{s O{tbp} m m +m O{}} + {\KFLT@keysubfloats{#1}{#2}{#3}{#4}{#5}{#6}} + {\endKFLT@keysubfloats} -\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m} -{% - \KFLT@keysubfloats{#1}{#2}{figure}{#3}{#4}% -}{% - \endKFLT@keysubfloats% -} +\NewDocumentEnvironment{keysubfigs}{s O{tbp} m +m O{}} + {\KFLT@keysubfloats{#1}{#2}{figure}{#3}{#4}{#5}} + {\endKFLT@keysubfloats} -\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m} -{% - \KFLT@keysubfloats{#1}{#2}{table}{#3}{#4}% -}{% - \endKFLT@keysubfloats% -} +\NewDocumentEnvironment{keysubtabs}{s O{tbp} m +m O{}} + {\KFLT@keysubfloats{#1}{#2}{table}{#3}{#4}{#5}} + {\endKFLT@keysubfloats} \newsavebox{\KFLT@marginfloatbox} \NewDocumentEnvironment{KFLT@marginfloat}{O{-1.2ex} m} -- cgit v1.2.3