From 60cbc8437dcfde310f54a43fd254865ec7e5296a Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 9 Jan 2013 00:39:21 +0000
Subject: caption (8jan13)

git-svn-id: svn://tug.org/texlive/trunk@28765 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/caption/caption.sty | 364 ++++++++++++------------
 1 file changed, 189 insertions(+), 175 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 324e981af4f..bf396d89096 100644
--- a/Master/texmf-dist/tex/latex/caption/caption.sty
+++ b/Master/texmf-dist/tex/latex/caption/caption.sty
@@ -6,7 +6,7 @@
 %%
 %% caption.dtx  (with options: `package')
 %% 
-%% Copyright (C) 1994-2012 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
+%% Copyright (C) 1994-2013 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
 %% 
 %% --------------------------------------------------------------------------
 %% 
@@ -28,9 +28,10 @@
 %% bicaption.sty, ltcaption.sty, subcaption.sty, and newfloat.sty,
 %% and the user manuals caption-deu.tex, caption-eng.tex, and caption-rus.tex.
 %% 
+ % bicaption.sty, ltcaption.sty, subcaption.sty, and newfloat.sty,
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{caption}[2012/02/19 v3.2f Customizing captions (AR)]
-\RequirePackage{caption3}[2011/08/30] % needs v1.4 or newer
+\ProvidesPackage{caption}[2013/01/06 v3.3 Customizing captions (AR)]
+\RequirePackage{caption3}[2012/12/26] % needs v1.5 or newer
 \caption@ifbool{documentclass}{}{%
   \caption@WarningNoLine{%
     Unsupported document class (or package) detected,\MessageBreak
@@ -65,7 +66,6 @@
 \@onlypreamble@key{caption}{figurename}
 \DeclareCaptionOption{tablename}{\caption@SetName{table}{#1}}
 \@onlypreamble@key{caption}{tablename}
-\DeclareCaptionOption{name}{\caption@setname\@captype{#1}}
 \DeclareCaptionOption{listfigurename}{\caption@SetName{listfigure}{#1}}
 \@onlypreamble@key{caption}{listfigurename}
 \DeclareCaptionOption{listtablename}{\caption@SetName{listtable}{#1}}
@@ -73,6 +73,7 @@
 \newcommand*\caption@SetName[2]{%
   \caption@NewFloat{\newfloat@setname{#1}{#2}}}
 \@onlypreamble\caption@SetName
+\DeclareCaptionOption{name}{\caption@setname\@captype{#1}}
 \newcommand*\caption@setname[2]{%
   \@namedef{#1name}{#2}}
 \newcommand*\caption@DeclareWithinOption[1]{%
@@ -97,6 +98,16 @@
    \InputIfFileExists{#1.cfg}%
      {\typeout{*** Local configuration file #1.cfg used ***}}%
      {\caption@Warning{Configuration file #1.cfg not found}}}
+\newcommand*\caption@selectlistentry[1]{%
+  \caption@ifinlist{#1}{heading}{%
+    \let\caption@iflistheading\@firstoftwo
+  }{\caption@ifinlist{#1}{default,list-entry,entry}{%
+    \let\caption@iflistheading\@secondoftwo
+  }{%
+    \caption@Error{Undefined list-entry selection `#1'}%
+  }}}
+\DeclareCaptionOption{list-entry}{\caption@selectlistentry{#1}}
+\captionsetup{list-entry=default}
 \newcommand*\caption@setparboxrestore[1]{%
   \caption@ifinlist{#1}{full}{%
     \caption@setfullparboxrestore
@@ -128,9 +139,6 @@
 \DeclareCaptionOptionNoValue*{center}{%
   \caption@setformat{plain}%
   \caption@setjustification{centering}}
-\DeclareCaptionOptionNoValue*{anne}{%
-  \caption@setformat{plain}%
-  \caption@setjustification{centerlast}}
 \DeclareCaptionOptionNoValue*{centerlast}{%
   \caption@setformat{plain}%
   \caption@setjustification{centerlast}}
@@ -263,12 +271,14 @@
 }
 \caption@SetupOptions{caption}{\caption@setkeys{#1}{#2}}
 \caption@ProcessOptions*{caption}
+\newif\ifcaption@caption
+\newif\ifcaption@subcaption
+\newif\ifcaption@ContinuedFloat
 \def\caption@caption{%
   \caption@iftype
     {\caption@checkgrouplevel\@empty\caption
      \caption@star
-       {\@nameuse{donemaincaptiontrue}%
-        \caption@refstepcounter\@captype}%
+       {\caption@refstepcounter\@captype}%
        {\caption@dblarg{\@caption\@captype}}}%
     {\caption@Error{\noexpand\caption outside float}%
      \caption@gobble}}
@@ -278,6 +288,7 @@
   \ifcaption@star \else
     \caption@prepareanchor{#1}{#2}%
     \memcaptioninfo{#1}{\csname the#1\endcsname}{#2}{#3}%
+    \@nameuse{nag@hascaptiontrue}%
   \fi
   \par
   \caption@beginex{#1}{#2}{#3}%
@@ -298,7 +309,7 @@
 \providecommand\memcaptioninfo[4]{}
 \newcommand*\caption@prepareanchor[2]{%
   \caption@makecurrent{#1}{#2}%
-  \caption@ifhypcap\caption@@start{}%
+  \caption@ifhypcap\caption@@start\relax
   \M@gettitle{#2}}
 \long\def\caption@makecaption#1#2{%
   \caption@iftop
@@ -337,7 +348,7 @@
     }}%
   \caption@CheckCommand\caption{%
     % float.sty [2001/11/08 v1.3d Float enhancements (AL)]
-    \renewcommand\caption{%
+    \long\def\caption{%
       \ifx\@captype\@undefined
         \@latex@error{\noexpand\caption outside float}\@ehd
         \expandafter\@gobble
@@ -391,7 +402,7 @@
   \caption@CheckCommand\caption{%
     % memhfixc.sty [2010/08/17 v1.15 nameref/hyperref package fixes for memoir class]
     % \let\m@moldhypcaption\caption
-    \renewcommand{\caption}{\donemaincaptiontrue\m@moldhypcaption}}%
+    \long\def\caption{\donemaincaptiontrue\m@moldhypcaption}}%
   \caption@IfCheckCommand{}{%
     \caption@InfoNoLine{%
       Incompatible package detected (regarding \string\caption).\MessageBreak
@@ -422,6 +433,13 @@
         \fi
         \beamer@makecaption{#1}{\ignorespaces #3}\par\nobreak
         \endgroup}}%
+  \caption@CheckCommand\@caption{%
+    % memhfixc.sty [2010/08/17 v1.15 nameref/hyperref package fixes for memoir class]
+    \long\def\@caption#1[#2]#3{%
+      \MNR@old@caption{#1}[{#2}]{#3}%
+      \def\@currentlabelname{#2}%
+      \M@gettitle{#2}%
+    }}%
   \caption@CheckCommand\@caption{%
     % magyar.ldf [2005/03/30 v1.4j Magyar support from the babel system]
     \long\def\@caption#1[#2]#3{%
@@ -682,6 +700,11 @@
     {\caption@@settype{sub}*{sub\@captype}}%
     {\caption@@settype{sub}{sub\@captype}}}%
 \newcommand*\caption@settype{%
+  \global\caption@captionfalse
+  \global\caption@subcaptionfalse
+  \global\caption@ContinuedFloatfalse
+  \caption@set@type}
+\newcommand*\caption@set@type{%
   \caption@@settype{}}
 \newcommand*\caption@@settype[1]{%
   \caption@teststar{\caption@@@settype{#1}}\@firstoftwo\@secondoftwo}
@@ -704,7 +727,6 @@
       The #1caption type was already set to
       `\csname @#1captype\endcsname'\MessageBreak}}%
   \fi
-  \let\caption@ifrefstepcounter\@secondoftwo
   #2{}{%
     \let\@currentlabel\caption@undefinedlabel
     \ifx\caption@x@label\@undefined
@@ -766,34 +788,33 @@
     \caption@addcontentsline{#2}{#3}%
   \@esphack}
 \newcommand*\captionbox{%
-  \let\captionbox@settype\@gobble
-  \caption@withoptargs\caption@box}
-\newcommand\caption@box[2]{%
-  \@testopt{\caption@ibox{#1}{#2}}{\wd\@tempboxa}}
-\long\def\caption@ibox#1#2[#3]{%
-  \@testopt{\caption@iibox{#1}{#2}{#3}}\captionbox@hj@default}
-\long\def\caption@iibox#1#2#3[#4]#5{%
-  \setbox\@tempboxa\hbox{#5}%
+  \caption@withoptargs{\caption@ibox\@gobble}}
+\newcommand\caption@ibox[3]{%
+  \@testopt{\caption@iibox{#1}{#2}{#3}}{\wd\@tempboxa}}
+\long\def\caption@iibox#1#2#3[#4]{%
+  \@testopt{\caption@iiibox{#1}{#2}{#3}{#4}}\captionbox@hj@default}
+\long\def\caption@iiibox#1#2#3#4[#5]#6{%
+  \setbox\@tempboxa\hbox{#6}%
   \begingroup
-  \captionbox@settype*% set \caption@position
+  #1*% set \caption@position
   \caption@iftop{%
     \endgroup
-    \parbox[t]{#3}{%
-      \captionbox@settype\relax
+    \parbox[t]{#4}{%
+      #1\relax
       \caption@setposition t%
-      \vbox{\caption#1{#2}}%
+      \vbox{\caption#2{#3}}%
       \captionbox@hrule
-      \csname caption@hj@#4\endcsname
+      \csname caption@hj@#5\endcsname
       \unhbox\@tempboxa}%
   }{%
     \endgroup
-    \parbox[b]{#3}{%
-      \captionbox@settype\relax
+    \parbox[b]{#4}{%
+      #1\relax
       \caption@setposition b%
-      \csname caption@hj@#4\endcsname
+      \csname caption@hj@#5\endcsname
       \unhbox\@tempboxa
       \captionbox@hrule
-      \vtop{\caption#1{#2}}}%
+      \vtop{\caption#2{#3}}}%
   }}
 \newcommand*\captionbox@hj@default{c}
 \newcommand*\captionbox@hrule{\hrule\@height\z@\relax}
@@ -803,42 +824,38 @@
 \providecommand*\caption@hj@s{}
 \def\ContinuedFloat{%
   \caption@iftype
-    {\addtocounter\@captype\m@ne
-     \caption@ContinuedFloat\@captype}%
+    {\caption@ContinuedFloat\@captype}%
     {\caption@Error{\noexpand\ContinuedFloat outside float}}}
-\def\caption@ContinuedFloat#1{%
-  \@ifstar{\caption@Continued@Float@{#1}}{\caption@Continued@Float{#1}}}
-\def\caption@Continued@Float@{%
-  \addtocounter\@captype\@ne
-  \@stpelt{ContinuedFloat}\stepcounter{ContinuedFloat}%
-  \def\caption@resetContinuedFloat##1{\xdef\caption@CFtype{##1}}%
-  \caption@@ContinuedFloat}
-\def\caption@Continued@Float#1{%
+\newcommand*\caption@ContinuedFloat[1]{%
+  \@ifstar
+    {\caption@@refstepcounter\@captype
+     \caption@@ContinuedFloat{#1}}%
+    {\caption@Continued@Float{#1}}}
+\newcommand*\caption@Continued@Float[1]{%
   \edef\caption@tempa{#1}%
   \ifx\caption@tempa\caption@CFtype
-    \stepcounter{ContinuedFloat}%
-    \let\caption@resetContinuedFloat\@gobble
     \caption@@ContinuedFloat{#1}%
-    \sf@ContinuedFloat{#1}%
   \else
     \caption@Error{Continued `#1' after `\caption@CFtype'}%
   \fi}
-\def\caption@@ContinuedFloat#1{%
+\newcommand*\caption@@ContinuedFloat[1]{%
+  \global\caption@ContinuedFloattrue
+  \stepcounter{ContinuedFloat}%
+  \caption@@@ContinuedFloat{#1}}
+\newcommand*\caption@@@ContinuedFloat[1]{%
+  \caption@setoptions{ContinuedFloat}%
+  \caption@setoptions{continued#1}%
   \expandafter\l@addto@macro\csname the#1\endcsname\theContinuedFloat
   \@ifundefined{theH#1}{}{%
     \expandafter\l@addto@macro\csname theH#1\endcsname{%
       \@alph\c@ContinuedFloat}}%
-  \caption@setoptions{ContinuedFloat}%
-  \caption@setoptions{continued#1}}
-\providecommand*\sf@ContinuedFloat[1]{}
+  \let\caption@@@ContinuedFloat\@gobble}
 \newcommand*\caption@CFtype{??}
 \newcounter{ContinuedFloat}
 \let\theContinuedFloat\@empty
 \newcommand*\caption@resetContinuedFloat[1]{%
-  \@stpelt{ContinuedFloat}%
   \xdef\caption@CFtype{#1}%
-  \def\ContinuedFloat{\caption@Error{%
-    \noexpand\ContinuedFloat must be placed at the top of the environment}}}
+  \@stpelt{ContinuedFloat}}
 \newcommand\phantomcaption{%
   \caption@iftype
     {\caption@refstepcounter\@captype}%
@@ -846,28 +863,63 @@
 \newcommand*\caption@refstepcounter[1]{%
   \@ifundefined{c@#1}%
     {\caption@Error{No float type '#1' defined}}%
-    {\caption@resetContinuedFloat{#1}%
-     \caption@@refstepcounter{#1}%
-     \let\caption@ifrefstepcounter\@firstoftwo}}
-\newcommand*\caption@@refstepcounter{\refstepcounter}
-\let\caption@ifrefstepcounter\@secondoftwo
-\caption@ifundefined\kernel@ifnextchar
-  {\newcommand\caption@dblarg[1]{\@ifnextchar[{#1}{\caption@xdblarg{#1}}}}%
-  {\newcommand\caption@dblarg[1]{\kernel@ifnextchar[{#1}{\caption@xdblarg{#1}}}}%
-\newcommand\caption@xdblarg[2]{#1[{#2\relax}]{#2}}%
+    {\caption@ref@stepcounter{#1}%
+     \caption@fixposition
+     \caption@iftop{\global\caption@captiontrue}{\global\caption@captionfalse}%
+     \global\caption@subcaptionfalse
+     \@nameuse{donemaincaptiontrue}}}
+\newcommand*\caption@ref@stepcounter{%
+  \ifcaption@ContinuedFloat
+    \let\caption@tempa\caption@@refcounter
+    \global\caption@ContinuedFloatfalse
+  \else
+    \let\caption@tempa\caption@@refstepcounter
+    \ifcaption@caption \else
+      \ifcaption@subcaption
+        \let\caption@tempa\caption@@refcounter
+      \fi
+    \fi
+  \fi
+  \caption@tempa}
+\newcommand*\caption@@refcounter[1]{%
+  \let\caption@stepcounter@ORI\stepcounter
+  \def\stepcounter##1{%
+    \def\caption@tempa{#1}%
+    \def\caption@tempb{##1}%
+    \ifx\caption@tempa\caption@tempb \else
+      \caption@stepcounter@ORI{##1}%
+    \fi}%
+   \caption@@@refstepcounter{#1}%
+   \let\stepcounter\caption@stepcounter@ORI}
+\newcommand*\caption@@refstepcounter[1]{%
+  \caption@prepare@stepcounter{#1}{ref}%
+  \caption@@@refstepcounter{#1}}
+\newcommand*\caption@@stepcounter[1]{%
+  \caption@prepare@stepcounter{#1}{}%
+  \caption@@@stepcounter{#1}}
+\newcommand*\caption@prepare@stepcounter[2]{%
+  \flushsubcaptionlistentries[#2stepcounter]%
+  \caption@resetContinuedFloat{#1}}
+\newcommand*\caption@@@refstepcounter{\refstepcounter}
+\newcommand*\caption@@@stepcounter{\stepcounter}
+\@ifundefined{kernel@ifnextchar}{\let\kernel@ifnextchar\@ifnextchar}{}
+\newcommand\caption@dblarg[1]{%
+  \kernel@ifnextchar[{\caption@ydblarg{#1}}{\caption@xdblarg{#1}}}
+\newcommand\caption@xdblarg[2]{%
+  #1[{#2\relax}]{#2}}
+\long\def\caption@ydblarg#1[#2]#3{%
+  \caption@iflistheading{#1[{#3}]{#3}}{#1[{#2}]{#3}}}
 \newcommand*\caption@begin[1]{%
+  \caption@fixposition
   \begingroup
-    \caption@setfnum{#1}%
-    \caption@fixposition
-    \global\let\caption@fixedposition\caption@position}
+    \caption@setfnum{#1}}
 \newcommand\caption@beginex[3]{%
   \caption@begin{#1}%
   \let\lst@@caption\relax
   \caption@addcontentsline{#1}{#2}%
   \caption@ifempty{#3}{}}
 \newcommand*\caption@end{%
-  \endgroup
-  \let\caption@position\caption@fixedposition}
+  \endgroup}
 \newcommand*\caption@setfnum[1]{%
   \@ifundefined{fnum@#1}{\iftrue}{\ifx\caption@lfmt\caption@lfmt@default\else}%
     \@namedef{fnum@#1}{\caption@fnum{#1}}%
@@ -904,7 +956,6 @@
     {\NR@gettitle{#1}}}
 \def\caption@DeclareSubType sub#1\@nil{%
   \caption@Debug{Initializing subtype for `#1'\@gobble}%
-  \@namedef{caption@c@#1}{0}%
   \@namedef{caption@beginsub#1}{\caption@beginsubfloat{#1}}}
 \@onlypreamble\caption@DeclareSubType
 \caption@For*{subtypelist}{\caption@DeclareSubType sub#1\@nil}
@@ -915,21 +966,20 @@
 \newcommand*\caption@subtypehook{%
   \ifx\caption\caption@subcaption \else
     \caption@warmup
-    \caption@ifrefstepcounter{}{%
-      % no \caption or \subcaption in this (floating) environment yet
-      \caption@Debug{Increment \@captype\ counter =\the\value\@captype}%
-      \caption@l@stepcounter\@captype
-      \let\caption@@@addcontentsline\caption@addsubcontentsline}%
-    \ifnum\csname caption@c@\@captype\endcsname=\value\@captype \else
-      \caption@Debug{Reset sub\@captype\ counter}%
-      \expandafter\xdef\csname caption@c@\@captype\endcsname{%
-        \the\value\@captype}%
-      \@stpelt\@subcaptype
+    \ifcaption@caption \else
+      \let\caption@add@contentsline\caption@addsubcontentsline
+      \ifcaption@subcaption \else
+        \ifcaption@ContinuedFloat
+          \global\caption@ContinuedFloatfalse
+        \else
+          \caption@@stepcounter\@captype
+        \fi
+        \global\caption@subcaptiontrue
+      \fi
     \fi
     \c@ContinuedFloat=0\relax
-    \let\caption@resetContinuedFloat\@gobble
-    \let\caption@addcontentsline\caption@kernel@addcontentsline
     \let\caption@setfloatcapt\@firstofone
+    \caption@setbox{parbox}%
     \caption@clearmargin
     \caption@iflist{}{\let\caption@setlist\@gobble}%
     \caption@setoptions{sub}%
@@ -954,25 +1004,20 @@
 \newcommand*\caption@subcaption{%
   \caption@checkgrouplevel{sub}\subcaption
   \caption@star
-    {\caption@refstepcounter\@subcaptype}%
+    {\caption@@@refstepcounter\@subcaptype}%
     {\caption@dblarg{\@caption\@subcaptype}}}
 \newcommand*\caption@subphantom{%
   \caption@checkgrouplevel{sub}\phantomsubcaption
-  \caption@refstepcounter\@subcaptype}
-\let\caption@kernel@addcontentsline\caption@addcontentsline
-\renewcommand\caption@addcontentsline[2]{%
-  \sf@ifpositiontop{\@listsubcaptions{#1}}{}%
-  \caption@kernel@addcontentsline{#1}{#2}%
-  \sf@ifpositiontop{}{\@listsubcaptions{#1}}%
-  \caption@addsubcontentslines{#1}}
-\newcommand*\caption@addsubcontentslines[1]{%
-  \begingroup
-    \caption@subcontentslines
-  \endgroup
-  \caption@clearsubcontentslines}%
+  \caption@@@refstepcounter\@subcaptype}
+\newcommand*\caption@clearsubcontentslines{%
+  \global\let\caption@subcontentslines\@empty}
+\caption@clearsubcontentslines
 \newcommand*\caption@addsubcontentsline[4]{%
+  \caption@Debug{\string\caption@addsubcontentsline{#1}{#2}}%
   \begingroup
-  \let\label\caption@gobble \let\index\caption@gobble \let\glossary\caption@gobble
+  \let\label\caption@gobble
+  \let\index\caption@gobble
+  \let\glossary\caption@gobble
   \protected@edef\@tempa{\endgroup
     \noexpand\g@addto@macro\noexpand\caption@subcontentslines{%
       \noexpand\@namedef{the#2}{\csname the#2\endcsname}%
@@ -981,20 +1026,22 @@
       \fi
       \protect\caption@@@addcontentsline{#1}{#2}{#3}{#4}}}%
   \@tempa}
-\newcommand*\caption@checksubcontentslines{%
-  \ifx\caption@subcontentslines\@empty \else
-    \caption@Error{%
-      Something's wrong--perhaps a missing \protect\caption\MessageBreak
-      in the last figure or table}%
-    \caption@clearsubcontentslines
-  \fi}
-\newcommand*\caption@clearsubcontentslines{%
-  \global\let\caption@subcontentslines\@empty}
-\caption@AtBeginDocument*{%
-  \caption@ifundefined\sf@ifpositiontop{\let\sf@ifpositiontop\@gobbletwo}{}%
-  \caption@clearsubcontentslines
-  \g@addto@macro\caption@typehook{\caption@checksubcontentslines}%
-  \AtEndDocument{\caption@checksubcontentslines}}%
+\newcommand*\flushsubcaptionlistentries[1][user]{%
+  \caption@Debug{\string\flushsubcaptionlistentries (#1)}%
+  \begingroup
+    \caption@subcontentslines
+  \endgroup
+  \caption@clearsubcontentslines}
+\AtBeginDocument{\caption@ifundefined\chapter{}{%
+  \let\caption@chapter@ORI\chapter
+  \def\chapter{%
+    \flushsubcaptionlistentries[chapter]\caption@chapter@ORI}}}
+\AtBeginDocument{\caption@ifundefined\appendix{}{%
+  \let\caption@appendix@ORI\appendix
+  \def\appendix{%
+    \flushsubcaptionlistentries[appendix]\caption@appendix@ORI}}}
+\AtEndDocument{%
+  \flushsubcaptionlistentries[AtEndDocument]}
 \caption@ifundefined\smf@makecaption{}{\let\smf@makecaption\@makecaption}
 \@ifclassloaded{beamer}{%
   \caption@InfoNoLine{beamer document class}%
@@ -1085,19 +1132,13 @@
 \caption@setbool{needfreeze}{0}
 \caption@AtBeginDocument*{%
   \caption@ifneedfreeze{%
-  \newcommand*\caption@freeze{%
+  \newcommand*\caption@freeze[1]{%
+    \caption@settype*{#1}%
+    \captionsetup*[sub]{hypcap=true}% Note: This is just a (q&d) workaround!
     \let\caption@frozen@ContinuedFloat\ContinuedFloat
     \def\ContinuedFloat{%
-      \caption@withoptargs\caption@SC@ContinuedFloat}%
-    \def\caption@SC@ContinuedFloat##1{%
-      \caption@@freeze{\ContinuedFloat##1}%
-      \let\caption@frozen@setcounter\setcounter
-      \let\caption@frozen@addtocounter\addtocounter
-      \def\setcounter####1####2{\csname c@####1\endcsname####2\relax}%
-      \def\addtocounter####1####2{\advance\csname c@####1\endcsname ####2\relax}%
-      \caption@frozen@ContinuedFloat##1%
-      \let\setcounter\caption@frozen@setcounter
-      \let\addtocounter\caption@frozen@addtocounter}%
+      \caption@@freeze{\caption@@@ContinuedFloat\@captype}%
+      \caption@frozen@ContinuedFloat}%
     \let\caption@frozen@setup\caption@setup
     \def\caption@setup##1{%
       \caption@@freeze{\caption@setup{##1}}%
@@ -1110,11 +1151,7 @@
         \caption@gobble}%
       \@ifstar
       {\caption@SC@caption*}%
-      {\let\caption@frozen@refstepcounter\caption@@refstepcounter
-       \let\caption@@refstepcounter\caption@l@stepcounter
-       \caption@refstepcounter\@captype
-       \let\caption@@refstepcounter\caption@frozen@refstepcounter
-       \let\@currentlabel\caption@SClabel
+      {\let\@currentlabel\caption@SClabel
        \caption@withoptargs\caption@SC@caption}}%
     \long\def\caption@SC@caption##1##2{%
       \caption@@freeze{\caption##1{##2}}%
@@ -1141,6 +1178,8 @@
       \let\caption@setup\caption@frozen@setup
       \let\caption\caption@frozen@caption
       \let\label\caption@frozen@label}}%
+    \newcommand*\caption@prepare@defrost{%
+      \let\caption@settype\caption@set@type}
   \newcommand*\caption@defrost{%
     \ifx\caption@frozen@caption\@undefined
       \caption@frozen@content
@@ -1227,13 +1266,7 @@
     \def\FP@captype{#1}%
     \begin{lrbox}{\FP@floatCorpusBOX}%
     \minipage\hsize % changes from LR mode to vertical mode
-    \caption@settype*{#1}%
-    \caption@freeze
-    \global\let\FP@Label\@empty
-    \caption@ifFPrefcap
-      {}%
-      {\def\caption@freeze@label##1##2{%
-          \g@addto@macro\FP@Label{\FP@label##1{##2}}}}%
+    \caption@freeze{#1}%
     \ignorespaces}%
   \renewcommand*\FP@floatEnd{%
     \endminipage
@@ -1241,33 +1274,16 @@
     \stepcounter{FP@\FP@captype C}%
     \caption@label\FP@positionLabel
     \FP@helpNote\FP@captype\FP@positionLabel
-    \edef\FP@RestoreCounter{%
-      \noexpand\setcounter{\FP@captype}{\the\value\FP@captype}%
-      \noexpand\setcounter{ContinuedFloat}{\the\value{ContinuedFloat}}}%
     \FP@float
       {\FP@positionLabel}% location label test
-      {\begin\FP@captype[p!]%
+      {\caption@prepare@defrost
+       \begin\FP@captype[p!]%
          \usebox\FP@floatCorpusBOX
-         \let\caption@SClentry\@empty
-         \def\caption{\caption@dblarg{\@caption\@captype}}%
-         \long\def\@caption##1[##2]##3{\def\caption@SClentry{##2}}%
-         \let\FP@label\label
-         \let\label\caption@gobble
-         \caption@defrost
-         \caption@ifFPlistcap
-           {\caption@refstepcounter\@captype
-            \expandafter\caption@makecurrent\expandafter\@captype
-                                         \expandafter{\caption@SClentry}}%
-           {\ifx\caption@SClentry\@empty \else
-               \expandafter\captionlistentry\expandafter{\caption@SClentry}%
-             \fi}%
-         \caption@makeanchor\relax
-         \FP@Label
        \end\FP@captype}%
-      {\FP@RestoreCounter
-       \@ifundefined{theH\FP@captype}{}{%
+      {\@ifundefined{theH\FP@captype}{}{%
          \expandafter\l@addto@macro\csname theH\FP@captype\endcsname{.FP}}}%
-      {\begin\FP@captype[b!]%
+      {\caption@prepare@defrost
+       \begin\FP@captype[b!]%
          \let\FP@savedSetfnumCommand\caption@setfnum
          \def\caption@setfnum##1{%
            \FP@savedSetfnumCommand{##1}%
@@ -1278,7 +1294,6 @@
          \setlength\belowcaptionskip{2pt plus 2pt minus 1pt}% length below caption
          \caption@setoptions{FP\@captype}%
          \FP@separatorCaption
-         \caption@ifFPlistcap{}{\let\caption@addcontentsline\@gobbletwo}%
          \caption@defrost
        \end\FP@captype}%
   }%
@@ -1305,7 +1320,7 @@
       because hyperref has stopped early}%
   }{%
     \g@addto@macro\caption@prepareslc{\measuring@true}%
-    \renewcommand*\caption@@refstepcounter{\H@refstepcounter}%
+    \renewcommand*\caption@@@refstepcounter{\H@refstepcounter}%
     \renewcommand*\caption@makecurrent[2]{%
       \caption@makecurrentHref{#1}%
       \caption@Debug{hyperref current=\@currentHref}%
@@ -1383,6 +1398,12 @@
         \caption@startanchor\caption@currentHref
         \global\let\caption@currentHref\@undefined
       \fi}%
+    \caption@ifundefined\HyNew@float@makebox{}{%
+      \caption@ifundefined\HyOrg@float@makebox{%
+        \caption@Debug{%
+          Correcting wrong load order hyperref-float\@gobble}%
+        \let\HyOrg@float@makebox\float@makebox
+        \let\float@makebox\HyNew@float@makebox}{}}%
     \caption@ifundefined\HyOrg@float@makebox{}{%
       \caption@Debug{%
         Redefining \noexpand\float@makebox (again)\@gobble}%
@@ -1466,7 +1487,7 @@
       \caption@setoptions{@longtable}%
       \caption@setautoposition{\ifcase\LT@rows t\else b\fi}%
       \caption@startrue#1\caption@starfalse
-      \caption@resetContinuedFloat\LTcaptype
+      \caption@prepare@stepcounter\LTcaptype{LT}%
       \caption@begin\LTcaptype
         \caption@normalsize
         \vskip-\ht\strutbox
@@ -1551,18 +1572,14 @@
   \def\rotcaptionof{%
     \caption@teststar\caption@of{\rotcaption*}\rotcaption}%
   \long\def\@makerotcaption#1#2{%
-    \ifdim\captionwidth=\z@
-      \setcaptionwidth{.8\textheight}%
-      \caption@slc{#1}{#2}{.8\vsize}{%
-        \let\caption@makerot\caption@@make
-        \caption@clearmargin
-        \let\caption@parbox\@secondoftwo}%
-      \caption@set@bool\caption@ifslc0% been there, done that
-    \fi
-    \rotatebox{90}{\caption@makerot{#1}{#2}}%
+    \rotatebox{90}{%
+      \ifdim\captionwidth=\z@
+        \setcaptionwidth{.8\vsize}%
+        \l@addto@macro\caption@singleline{\caption@setbox{none}}%
+      \fi
+      \let\caption@calcmargin\relax
+      \caption@@make{#1}{#2}}%
     \nobreak\hspace{12pt}}%
-  \newcommand\caption@makerot[2]{%
-    \begin{minipage}\captionwidth\caption@@make{#1}{#2}\end{minipage}}%
 }{}
 \caption@IfPackageLoaded{sidecap}[2003/06/06 v1.6f]{%
   \caption@setbool{needfreeze}{1}%
@@ -1570,20 +1587,12 @@
   \def\SC@zfloat#1#2#3[#4]{%
     \caption@ORI@SC@zfloat{#1}{#2}{#3}[#4]%
     \SC@RestoreCommands
-    \caption@settype*{#2}%
-    \caption@freeze
+    \caption@freeze{#2}%
     \let\SC@label\label}%
   \providecommand*\SC@RestoreCommands{%
     \let\caption=\SC@orig@caption \let\label=\SC@orig@label}%
   \let\caption@ORI@endSC@FLOAT\endSC@FLOAT
   \def\endSC@FLOAT{%
-    \let\caption@ORI@settype\caption@settype
-    \def\caption@settype##1{% will be done in \@xfloat
-      \caption@ORI@settype*{##1}% do not change \@currentlabel
-      \caption@setSC@justify
-%%%   \caption@setoptions{SCfloat}%
-      \caption@setoptions{SC\@captype}%
-      \caption@start}%
     \def\caption@setSC@justify{%
       \caption@clearmargin
         \ifx\SC@justify\@empty \else
@@ -1591,8 +1600,13 @@
           \let\SC@justify\@empty
         \fi}%
     \let\caption\SC@orig@caption
-    \def\SC@orig@caption[##1]##2{\caption@defrost}%
+    \def\SC@orig@caption[##1]##2{%
+      \caption@setSC@justify
+%%%   \caption@setoptions{SC}%
+      \caption@setoptions{SC\@captype}%
+      \caption@defrost}%
     \caption@setSC@justify % for compatibility mode
+    \caption@prepare@defrost
     \caption@ORI@endSC@FLOAT}%
 }{}
 \caption@IfPackageLoaded{subfigure}[2002/01/23 v2.1]{%
@@ -1708,7 +1722,7 @@
     \@ifundefined{fst@#1}{}{\@float@setevery{#1}}%
     \caption@settype{#1}%
     \caption@clearmargin
-%%%    \caption@setoptions{wrapfloat}%
+%%%    \caption@setoptions{wrap}%
     \caption@setoptions{wrap#1}}%
 }{}
 \endinput
-- 
cgit v1.2.3

