From bd36712a3846fe8b17a13b5edfdcf10dc8787235 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Tue, 21 Jul 2020 03:03:08 +0000
Subject: CTAN sync 202007210303

---
 macros/latex/contrib/caption/caption3.dtx | 74 +++++++++++++++++++++----------
 1 file changed, 50 insertions(+), 24 deletions(-)

(limited to 'macros/latex/contrib/caption/caption3.dtx')

diff --git a/macros/latex/contrib/caption/caption3.dtx b/macros/latex/contrib/caption/caption3.dtx
index 031c84fa67..8edc856461 100644
--- a/macros/latex/contrib/caption/caption3.dtx
+++ b/macros/latex/contrib/caption/caption3.dtx
@@ -28,7 +28,7 @@
 %   caption-deu.tex, caption-eng.tex, caption-rus.tex.
 % 
 % \fi
-% \CheckSum{3585}
+% \CheckSum{3606}
 %
 % \iffalse
 %<*driver>
@@ -191,7 +191,7 @@
 %
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{caption3}[2020/07/19 v1.12a caption3 kernel (AR)]
+\ProvidesPackage{caption3}[2020/07/20 v1.12b caption3 kernel (AR)]
 %    \end{macrocode}
 %
 % \section{Workaround for bug in package \package{arabtex}}
@@ -742,14 +742,15 @@
 %    \begin{macrocode}
 \newcommand*\@captionsetup[1]{%
   \captionsetup@startrue#1\captionsetup@starfalse
-  \@ifnextchar[\caption@setup@options\caption@setup}
+  \@ifnextchar[%]
+    \caption@setup@options\caption@setup}
 %    \end{macrocode}
 %    \begin{macrocode}
 \newcommand*\caption@setup{\caption@setkeys{caption}}
 %    \end{macrocode}
 %    \begin{macrocode}
 \def\caption@setup@options[#1]{%
-  \@ifnextchar[%
+  \@ifnextchar[%]
     {\caption@stepthecounter
      \caption@withoptargs{\@expandtwoargs
        \caption@setup@options@i{#1}{@\caption@thecounter}}}%
@@ -3635,6 +3636,7 @@
 % \changes{v1.8}{2018/05/16}{Redefinition of \cs{acused} added}
 % \changes{v1.8}{2018/05/26}{Definition method changed so it can be pre-defined by other packages}
 % \changes{v1.8}{2018/05/27}{Redefinition of \cs{hypertarget} added}
+% \changes{v1.12b}{2020/07/20}{Special adaption to \class{beamer} added}
 %  |\caption@prepareslc|\par
 %  Re-define anything which would disturb the single-line-check.
 %    \begin{macrocode}
@@ -3643,16 +3645,32 @@
   \let\label\caption@gobble
   \let\hypertarget\@gobbletwo
 %    \end{macrocode}
+% We re-define \cs{footnote} so
+% \begin{enumerate}
+% \item The footnote counter will not be increased twice (but still the correct footnote mark will be used within the single-line-check)
+% \item The footnote text will not be evaluated twice
+% \end{enumerate}
 %    \begin{macrocode}
-  \let\caption@endnotemark@ORI\endnotemark
+  \let\caption@footnote@ORI\footnote
+  \def\footnote{\caption@withoptargs\caption@footnote}%
+  \let\caption@footnotemark@ORI\footnotemark
+  \def\footnotemark{\caption@withoptargs\caption@footnotemark}%
+  \let\caption@footnotetext@ORI\@footnotetext
+  \let\@footnotetext\caption@gobble
+%    \end{macrocode}
+% Same for \cs{endnote}
+%    \begin{macrocode}
+  \let\caption@endnote@ORI\endnote
   \def\endnote{\caption@withoptargs\caption@endnote}%
+  \let\caption@endnotemark@ORI\endnotemark
   \def\endnotemark{\caption@withoptargs\caption@endnotemark}%
+  \let\caption@endnotetext@ORI\@endnotetext
   \let\@endnotetext\caption@gobble
 %    \end{macrocode}
 %    \begin{macrocode}
   \let\pagenote\caption@gobble
 %    \end{macrocode}
-% Adaption to the \package{acronym} package.\par
+% Adaption to the \package{acronym} package\par
 % See also \url{https://tex.stackexchange.com/questions/428788}
 %    \begin{macrocode}
   \let\acused\@gobble
@@ -3671,43 +3689,50 @@
 %    \begin{macrocode}
 }
 %    \end{macrocode}
-%
-% The following patch of \cs{footnote} assumes that the optional arguments of
-% \cs{footnote} and \cs{footnotemark} match. Since this is not the case in
-% \class{beamer} based documents, and since \class{beamer} extents the
-% syntax of \cs{footnote} in a way we don't support, we don't apply the patch there.
-%    \begin{macrocode}
-\caption@ifclassloaded{beamer}{}{%
-  \g@addto@macro\caption@prepareslc{%
-    \let\caption@footnote@ORI\footnote
-    \def\footnote{\caption@withoptargs\caption@footnote}%
-    \let\caption@footnotemark@ORI\footnotemark
-    \def\footnotemark{\caption@withoptargs\caption@footnotemark}%
-    \let\caption@footnotetext@ORI\@footnotetext
-    \let\@footnotetext\caption@gobble}}
-%    \end{macrocode}
 %    \begin{macrocode}
 \newcommand\caption@footnote[2]{%
   \caption@footnotemark{#1}}
+%    \end{macrocode}
+%    \begin{macrocode}
 \newcommand\caption@footnotemark[1]{%
   \begingroup
     \let\stepcounter\caption@l@stepcounter
-    \caption@footnotemark@ORI#1%
+    \caption@footnotemark@ORI#1\relax
   \endgroup}
 %    \end{macrocode}
 %    \begin{macrocode}
 \newcommand\caption@endnote[2]{%
   \caption@endnotemark{#1}}
+%    \end{macrocode}
+%    \begin{macrocode}
 \newcommand\caption@endnotemark[1]{%
   \begingroup
     \let\stepcounter\caption@l@stepcounter
-    \caption@endnotemark@ORI#1
+    \caption@endnotemark@ORI#1\relax
   \endgroup}
 %    \end{macrocode}
 %    \begin{macrocode}
 \newcommand*\caption@l@stepcounter[1]{%
   \advance\csname c@#1\endcsname\@ne\relax}
 %    \end{macrocode}
+% The patch above assumes that the optional arguments of \cs{footnote} and
+% \cs{footnotemark} match. Since this is not the case in \class{beamer} based documents,
+% and since \class{beamer} extents the syntax of \cs{footnote} in a special way,
+% we need a special patch here.\par
+% \emph{Note:} For this patch we assume that \cs{footnote} will always end with the usage of
+% \cs{beamer@footnotetext}. (Unfortunately \cs{footnote} is defined too monolithic
+% in \class{beamer} to offer a less dirty patch.)
+%    \begin{macrocode}
+\caption@ifclassloaded{beamer}{%
+  \g@addto@macro\caption@prepareslc{%
+    \def\footnote{%
+      \begingroup
+      \let\stepcounter\caption@l@stepcounter
+      \renewcommand<>\beamer@framefootnotetext[1]{%
+        \endgroup}%
+      \let\@footnotetext\beamer@framefootnotetext
+      \caption@footnote@ORI}}}{}
+%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@applyfont}
@@ -4113,7 +4138,8 @@
 %  |\caption@For|\marg{elt-list}\marg{code with \#1}\\
 %  |\caption@For*|\marg{elt-list}\marg{code with \#1}
 %    \begin{macrocode}
-\newcommand*\caption@For{\caption@withoptargs\caption@@For}
+\newcommand*\caption@For{%
+  \caption@withoptargs\caption@@For}
 %\@onlypreamble\caption@For
 %    \end{macrocode}
 %    \begin{macrocode}
-- 
cgit v1.2.3

