From 40fc7787788cdfcaccef2c17d47de2f8cc68643d Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sat, 4 Jan 2020 22:04:42 +0000
Subject: caption (4jan20)

git-svn-id: svn://tug.org/texlive/trunk@53318 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/caption/caption.sty | 119 ++++++++++++++----------
 1 file changed, 71 insertions(+), 48 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/caption/caption.sty')

diff --git a/Master/texmf-dist/tex/latex/caption/caption.sty b/Master/texmf-dist/tex/latex/caption/caption.sty
index a876598fd56..f905114ef8f 100644
--- a/Master/texmf-dist/tex/latex/caption/caption.sty
+++ b/Master/texmf-dist/tex/latex/caption/caption.sty
@@ -34,8 +34,8 @@
 %%   caption-deu.tex, caption-eng.tex, caption-rus.tex.
 %% 
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{caption}[2020/01/01 v3.4c Customizing captions (AR)]
-\RequirePackage{caption3}[2019/12/31] % needs v1.8f or newer
+\ProvidesPackage{caption}[2020/01/03 v3.4h Customizing captions (AR)]
+\RequirePackage{caption3}[2020/01/03] % needs v1.8h or newer
 \caption@ifbool{documentclass}{}{%
   \caption@WarningNoLine{%
     Unknown document class (or package),\MessageBreak
@@ -93,7 +93,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}
 \DeclareCaptionOption*{config}[caption]{%
@@ -433,31 +434,42 @@
   \caption@teststar{\caption@@@settype{#1}}\@firstoftwo\@secondoftwo}
 \newcommand*\caption@@@settype[3]{%
   \caption@Debug{#1type=#3}%
-  \caption@checkgrouplevel{#1}{%
-    \captionsetup{#1type#2*\@empty=...}#2{ or
-                  \@backslashchar#1captionof}{}}%
-  \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
-  \@nameuse{caption@#1typehook}%
-  \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
-  #2{}{%
-    \let\@currentlabel\caption@undefinedlabel
-    \ifx\caption@x@label\@undefined
-      \let\caption@x@label\label
-      \let\label\caption@xlabel
-    \fi
-    \caption@start}}
+  \@nameuse{caption@check#1type}{#3}%
+    {\caption@checkgrouplevel{#1}{%
+       \captionsetup{#1type#2*\@empty=...}#2{ or
+                     \@backslashchar#1captionof}{}}%
+     \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
+     \@nameuse{caption@#1typehook}%
+     \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
+     #2{}{%
+       \let\@currentlabel\caption@undefinedlabel
+       \ifx\caption@x@label\@undefined
+         \let\caption@x@label\label
+         \let\label\caption@xlabel
+       \fi
+       \caption@start}}}
 \newcommand*\caption@iftype{\caption@ifdefined\@captype}
+\newcommand*\caption@checktype[1]{%
+  \caption@ifsubtype{#1}%
+     {\caption@Error{Should not be used with subtype `#1'}%
+      \@gobble}%
+     \@firstofone}
+\newcommand*\caption@checksubtype[1]{%
+  \caption@ifsubtype{#1}%
+     \@firstofone
+     {\caption@Error{Undefined subtype `#1'}%
+      \@gobble}}
 \caption@ifeTeX{%
   \newcommand*\caption@checkgrouplevel[2]{%
     \@ifundefined{#1caption@grouplevel}{%
@@ -727,6 +739,7 @@
         \caption@Error{##2 inside \@subcaptype}%
       \fi}%
     \let\caption\caption@subcaption
+    \let\@caption\caption@@caption
     \let\phantomcaption\caption@subphantom
     \let\captionlistentry\caption@sublistentry
     \let\caption@refstepcounter\caption@@@refstepcounter
@@ -1175,30 +1188,29 @@
     \renewcommand*\caption@hypcapspace{\hypcapspace}%
   \fi}{}
 \caption@IfPackageLoaded{listings}[2004/02/13 v1.2]{%
-%%  \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}}%
   \let\caption@ORI@lst@MakeCaption\lst@MakeCaption
   \def\lst@MakeCaption#1{% #1 is `t' or `b'
     \begingroup
-%%      \caption@Debug{%
-%%        linewidth=\lst@linewidth,
-%%        xleftmargin=\lst@xleftmargin,\MessageBreak
-%%        xrightmargin=\lst@xrightmargin,
-%%        resetmargins=\lst@ifresetmargins true\else false\fi}%
-%%      \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}%
-      \l@addto@macro\caption@beginhook{%
-        \@tempdima\leftmargin
-        \multiply\@tempdima\@listdepth
-        \hskip-\@tempdima\relax}%
+%%    \caption@Debug{%
+%%      linewidth=\lst@linewidth,
+%%      xleftmargin=\lst@xleftmargin,\MessageBreak
+%%      xrightmargin=\lst@xrightmargin,
+%%      resetmargins=\lst@ifresetmargins true\else false\fi}%
+%%    \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}%
+      \caption@iflst@Init{}{%
+        \edef\caption@lst@leftskip{\noexpand\hskip-\the\@totalleftmargin\noexpand\relax}%
+        \l@addto@macro\caption@beginhook\caption@lst@leftskip}%
       \caption@setposition{#1}%
       \caption@iftop{%
         \@tempdima\belowcaptionskip
@@ -1274,6 +1286,17 @@
     \fi
     \caption@setoptions{longtable}%
     \caption@setoptions{@longtable}}%
+  \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}}%
+  }{}}%
 }{}
 \providecommand*\caption@LT@setup{}
 \caption@IfPackageLoaded{picinpar}{%
-- 
cgit v1.2.3

