diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/caption/caption.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/caption/caption.dtx | 178 |
1 files changed, 113 insertions, 65 deletions
diff --git a/Master/texmf-dist/source/latex/caption/caption.dtx b/Master/texmf-dist/source/latex/caption/caption.dtx index 1bf48731430..1c5a196e139 100644 --- a/Master/texmf-dist/source/latex/caption/caption.dtx +++ b/Master/texmf-dist/source/latex/caption/caption.dtx @@ -18,14 +18,17 @@ % % This Current Maintainer of this work is Axel Sommerfeldt. % -% This work consists of the files caption.ins, caption.dtx, caption2.dtx, -% caption3.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx, and newfloat.dtx, -% the derived files caption.sty, caption2.sty, caption3.sty, -% bicaption.sty, ltcaption.sty, subcaption.sty, and newfloat.sty, -% and the user manuals caption-deu.tex, caption-eng.tex, and caption-rus.tex. +% This work consists of the files +% caption.ins, caption.dtx, caption2.dtx, caption3.dtx, +% bicaption.dtx, ltcaption.dtx, subcaption.dtx, totalcount.dtx, +% the derived files +% caption.sty, caption2.sty, caption3.sty, +% bicaption.sty, ltcaption.sty, subcaption.sty, totalcount.sty, +% and the user manuals +% caption-deu.tex, caption-eng.tex, caption-rus.tex. % % \fi -% \CheckSum{3006} +% \CheckSum{3044} % % \iffalse %<*driver> @@ -215,13 +218,13 @@ % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1994/12/01] -\ProvidesPackage{caption}[2020/01/01 v3.4c Customizing captions (AR)] +\ProvidesPackage{caption}[2020/01/03 v3.4h Customizing captions (AR)] % \end{macrocode} % % \section{Loading the kernel} % % \begin{macrocode} -\RequirePackage{caption3}[2019/12/31] % needs v1.8f or newer +\RequirePackage{caption3}[2020/01/03] % needs v1.8h or newer % \end{macrocode} % % \section{Check against unknown document classes} @@ -378,6 +381,7 @@ % % \begin{macro}{\caption@NewFloat} % \changes{v3.2f}{2012/01/12}{This macro added} +% \changes{v3.4h}{2020/01/03}{Usage of \cs{caption@ifpackageloaded} replaced by \cs{RequirePackage}} % |\caption@NewFloat|\marg{code} % loads the \package{newfloat} package and executes the given code afterwards. % Note: Since the \package{newfloat} package uses the crappy \package{keyval} @@ -388,7 +392,8 @@ \newcommand*\caption@NewFloat[1]{% \let\KV@prefix@ORI\KV@prefix \let\@tempc@ORI\@tempc - \caption@ifpackageloaded{newfloat}{#1}{}% + \caption@ifdefined\newfloatsetup{}{\RequirePackage{newfloat}}% + #1% \let\@tempc\@tempc@ORI \let\KV@prefix\KV@prefix@ORI} % \end{macrocode} @@ -1212,6 +1217,7 @@ % % \begin{macro}{\setcaptiontype} % \changes{v3.2}{2010/10/24}{This macro added} +% \changes{v3.4e}{2020/01/02}{Check added if the subtype is defined} % Like |\captionsetup{type=xxx}|, but also works if \cs{captionsetup} was redefined. % \begin{macrocode} \newcommand\setcaptiontype{% @@ -1246,6 +1252,7 @@ % \changes{v3.1g}{2008/01/12}{Usage of \cs{ifcaptionsetup@star} added} % \changes{v3.2}{2010/10/26}{Error message moved from here to \cs{caption@refstepcounter}} % \changes{v3.3}{2011/12/28}{Resetting of \cs{ifcaption@caption} and \cs{ifcaption@subcaption} added} +% \changes{v3.4e}{2020/01/02}{Checks added to prevent misuse regading subtypes} % |\caption@settype*|\marg{type}\par % sets |\@captype| and executes the options associated with it % (using |\caption@set|\-|options|). @@ -1273,41 +1280,42 @@ \newcommand*\caption@@@settype[3]{% % #1 = "" or "sub" % #2 = \@firstoftwo in star form, \@secondoftwo otherwise -% #3 = <type>, e.g. "figure" or "table" +% #3 = <type>, e.g. "figure" or "subfigure" \caption@Debug{#1type=#3}% - \caption@checkgrouplevel{#1}{% - \captionsetup{#1type#2*\@empty=...}#2{ or - \@backslashchar#1captionof}{}}% + \@nameuse{caption@check#1type}{#3}% + {\caption@checkgrouplevel{#1}{% + \captionsetup{#1type#2*\@empty=...}#2{ or + \@backslashchar#1captionof}{}}% % \end{macrocode} % \begin{macrocode} - \edef\caption@tempa{#3}% - \expandafter\ifx\csname @#1captype\endcsname\caption@tempa \else - \ifcaptionsetup@star\else\@nameuse{caption@#1type@warning}\fi - \fi - \expandafter\let\csname @#1captype\endcsname\caption@tempa + \edef\caption@tempa{#3}% + \expandafter\ifx\csname @#1captype\endcsname\caption@tempa \else + \ifcaptionsetup@star\else\@nameuse{caption@#1type@warning}\fi + \fi + \expandafter\let\csname @#1captype\endcsname\caption@tempa % \end{macrocode} % \begin{macrocode} - \@nameuse{caption@#1typehook}% + \@nameuse{caption@#1typehook}% % \end{macrocode} % \begin{macrocode} - \caption@setoptions{#3}% - \ifx\caption@opt\relax - \@nameundef{caption@#1type@warning}% - \else - \@namedef{caption@#1type@warning}{\caption@Warning{% - The #1caption type was already set to - `\csname @#1captype\endcsname'\MessageBreak}}% - \fi + \caption@setoptions{#3}% + \ifx\caption@opt\relax + \@nameundef{caption@#1type@warning}% + \else + \@namedef{caption@#1type@warning}{\caption@Warning{% + The #1type was already set to + `\csname @#1captype\endcsname'\MessageBreak}}% + \fi % \end{macrocode} % \begin{macrocode} - #2{}{% - \let\@currentlabel\caption@undefinedlabel -% \let\@currentHlabel\@undefined - \ifx\caption@x@label\@undefined - \let\caption@x@label\label - \let\label\caption@xlabel - \fi - \caption@start}} + #2{}{% + \let\@currentlabel\caption@undefinedlabel +% \let\@currentHlabel\@undefined + \ifx\caption@x@label\@undefined + \let\caption@x@label\label + \let\label\caption@xlabel + \fi + \caption@start}}} % \end{macrocode} % \end{macro} % @@ -1320,6 +1328,26 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\caption@checktype} +% \changes{v3.4g}{2020/01/02}{This macro and its usage added} +% |\setcaptiontype| should not be used with a subtype, +% and |\setcaptionsubtype| should not be used with an undefined subtype. +% \begin{macrocode} +\newcommand*\caption@checktype[1]{% + \caption@ifsubtype{#1}% + {\caption@Error{Should not be used with subtype `#1'}% + \@gobble}% + \@firstofone} +% \end{macrocode} +% \begin{macrocode} +\newcommand*\caption@checksubtype[1]{% + \caption@ifsubtype{#1}% + \@firstofone + {\caption@Error{Undefined subtype `#1'}% + \@gobble}} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\caption@checkgrouplevel} % \changes{v3.1}{2007/07/15}{This macro and its usage added} % \changes{v3.1f}{2007/11/28}{Error changed to warning (compatibility)} @@ -1983,6 +2011,7 @@ % \changes{v3.3}{2013/05/01}{Redefinition of \cs{caption@settype} added} % \changes{v3.3}{2013/06/17}{Missing redefinition of \cs{captionlistentry} added} % \changes{v3.3}{2018/09/06}{Adapted to the \package{chkfloat} package} +% \changes{v3.4f}{2020/01/03}{Redefinition of \cs{@caption} added since it was redefined by the \env{threeparttable} environment} % Hook, will be used inside \cs{caption@setsubtype}.\par % (Note: If we are inside an |sub|\-|float|\-|row| environment we have to keep % the |\@make|\-|caption| code of the \package{floatrow} package intact.) @@ -2033,6 +2062,7 @@ % \begin{macrocode} % redefine \caption \let\caption\caption@subcaption + \let\@caption\caption@@caption \let\phantomcaption\caption@subphantom \let\captionlistentry\caption@sublistentry % \let\@captype\@subcaptype @@ -3321,22 +3351,23 @@ % \changes{v3.1k}{2008/03/29}{Bugfix 08-10-16-dctt: \texttt{rule=0} added} % \changes{v3.2}{2010/10/26}{Bugfix 10-07-20a: Set \cs{hsize} to \cs{linewidth}, if necessary} % \changes{v3.4c}{2020/01/01}{Ugly workaround for usage in lists added} +% \changes{v3.4d}{2020/01/01}{Ugly workaround for usage in lists revised} % To support the \package{listings} package we need to redefine % |\lst@MakeCaption| so the original stuff is nested with % |\caption@begin| and |\caption@end| etc.\par % Unfortunately |\lst@MakeCaption| is sometimes used with |\linewidth| intact but sometimes with |\linewidth| adapted. % So we either could write a bunch of very ugly code which is using internals of the \package{listings} package, or % we could simply ignore this fact since |\hsize| will be left untouched by the \package{listings} package. -% (This is reason why the caption is mis-aligned when using one of the options |linewidth=|, |xleftmargin=|, |yleftmargin=|, or |resetmargins=|, -% even the \package{caption} package isn't used. This needs to be fixed within the \package{listings} package, for example by using +% (This is the reason why the caption is mis-aligned when using one of the options |linewidth=|, |xleftmargin=|, |yleftmargin=|, or |resetmargins=|, +% even if the \package{caption} package isn't used. This needs to be fixed within the \package{listings} package, for example by using % |\lst@MakeCaption| inside a parbox of correct width.) % % The \package{listings} package calls |\lst@MakeCaption| sometimes with original |\linewidth|, sometimes with adapted |\linewidth|. % So we need to detect if |\linewidth| is already adapted or not. % We realize this by setting a flag inside the "Init" hook of the \package{listings} package (where the adaption takes place). % \begin{macrocode} -%% \caption@setbool{lst@Init}{0}% -%% \lst@AddToHook{Init}{\caption@setbool{lst@Init}{1}}% + \caption@setbool{lst@Init}{0}% + \lst@AddToHook{Init}{\caption@setbool{lst@Init}{1}}% % \end{macrocode} % \begin{macrocode} \let\caption@ORI@lst@MakeCaption\lst@MakeCaption @@ -3348,38 +3379,34 @@ \begingroup % \end{macrocode} % \begin{macrocode} -%% \caption@Debug{% -%% linewidth=\lst@linewidth, -%% xleftmargin=\lst@xleftmargin,\MessageBreak -%% xrightmargin=\lst@xrightmargin, -%% resetmargins=\lst@ifresetmargins true\else false\fi}% +%% \caption@Debug{% +%% linewidth=\lst@linewidth, +%% xleftmargin=\lst@xleftmargin,\MessageBreak +%% xrightmargin=\lst@xrightmargin, +%% resetmargins=\lst@ifresetmargins true\else false\fi}% % \end{macrocode} -% If |\linewidth| isn't adapted by the \package{listings} package yet, do the adaption here. +% If |\linewidth| isn't adapted by the \package{listings} package yet, do the adaption now. % \begin{macrocode} -%% \caption@iflst@Init{}{%\lsthk@PreInit\lsthk@Init => has unwanted side-effects (like an extra horizontal line) -%% \linewidth\lst@linewidth\relax -%% \lst@ifresetmargins -%% \advance\linewidth\@totalleftmargin -%% \advance\linewidth\rightmargin -%% \@totalleftmargin\z@ -%% \fi -%% \advance\linewidth-\lst@xleftmargin -%% \advance\linewidth-\lst@xrightmargin -%% \advance\@totalleftmargin\lst@xleftmargin\relax}% +%% \caption@iflst@Init{}{% +%% \linewidth\lst@linewidth\relax +%% \lst@ifresetmargins +%% \advance\linewidth\@totalleftmargin +%% \advance\linewidth\rightmargin +%% \@totalleftmargin\z@ +%% \fi +%% \advance\linewidth-\lst@xleftmargin +%% \advance\linewidth-\lst@xrightmargin +%% \advance\@totalleftmargin\lst@xleftmargin\relax}% % \end{macrocode} % Inside lists the \package{listings} package ignores the left margin (|\@totalleftmargin|) for captions. % We emulate this behaviour by adding a negativ skip which will be typeset ahead of |\caption@box|.\par -% This does not result in correct justification of the caption, but captions inside listings inside -% lists are not justified correctly anyway. (Again, this needs to be fixed by the \package{listings} package.)\par -% Note: We cannot use |\@totalleftmargin| here since it was usually resetted by the \package{listings} package. -% So we have to calculate the total left margin on our own which makes this code even more dirty. +% Note: We only need to do this if the ``Init'' hook of the \package{listings} package wasn't called yet. % \begin{macrocode} - \l@addto@macro\caption@beginhook{% - \@tempdima\leftmargin - \multiply\@tempdima\@listdepth - \hskip-\@tempdima\relax}% + \caption@iflst@Init{}{% + \edef\caption@lst@leftskip{\noexpand\hskip-\the\@totalleftmargin\noexpand\relax}% + \l@addto@macro\caption@beginhook\caption@lst@leftskip}% % \end{macrocode} -% First of all, we set |position=#1| and if it was set to `top', +% We set |position=#1| and if it was set to `top', % we swap the skips so the default behavior of the \package{listings} package % will not be changed. (Note that the \package{listings} package has set its % own |\abovecaptionskip| \& |\belowcaptionskip| values prior to calling @@ -3391,7 +3418,7 @@ \belowcaptionskip\abovecaptionskip \abovecaptionskip\@tempdima}{}% % \end{macrocode} -% Workaround for issue with wrong skips (FIXME: should be examined further) +% Workaround for issue with wrong skips (FIXME: This should be examined further) % \begin{macrocode} \caption@setup{rule=0}% % \end{macrocode} @@ -3698,6 +3725,27 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\flrow@setlist} +% \changes{v3.4g}{2020/01/03}{Redefinition of this macro added} +% The \package{floatrow} package uses |\flrow@setlist{{table}{longtable}}| inside its redefinition of |\LT@array| without setting |\@captype| first, +% and this makes |\captionsetup[table]{name=...}| doomed to fail for longtables (``Undefined control sequence''). +% Unfortunately we cannot easily patch |\LT@array| again to fix this bug in \package{floatrow} since it will be patched |\AtBeginDocument|. +% Therefore we patch |\flrow@setlist| instead to catch and fix the bug on-the-fly. +% \begin{macrocode} + \caption@AtBeginDocument{\caption@ifdefined\flrow@setlist@{% + \caption@InfoNoLine{Fixing longtable code of `floatrow' package}% + \let\caption@flrow@setlist@\flrow@setlist@ + \renewcommand\flrow@setlist@[1]{% + \def\caption@tempa{{table}{longtable}}% + \def\caption@tempb{#1}% + \ifx\caption@tempa\caption@tempb + \def\@captype{table}% + \fi + \caption@flrow@setlist@{#1}}% + }{}}% +% \end{macrocode} +% \end{macro} +% % \begin{macrocode} }{} % \end{macrocode} |