From 5183558ea817194c76ec71a3c8310ae6f06f5a69 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 31 May 2006 16:48:45 +0000
Subject: caption 3.0j

git-svn-id: svn://tug.org/texlive/trunk@1627 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/latex/caption/caption.dtx | 2678 ++++++++++++++------
 1 file changed, 1844 insertions(+), 834 deletions(-)

(limited to 'Master/texmf-dist/source/latex/caption/caption.dtx')

diff --git a/Master/texmf-dist/source/latex/caption/caption.dtx b/Master/texmf-dist/source/latex/caption/caption.dtx
index e18f1629e5d..42690e04ce7 100644
--- a/Master/texmf-dist/source/latex/caption/caption.dtx
+++ b/Master/texmf-dist/source/latex/caption/caption.dtx
@@ -2,7 +2,7 @@
 % 
 % This is file `caption.dtx'.
 % 
-% Copyright (C) 1994-2004 Axel Sommerfeldt (caption@sommerfeldt.net)
+% Copyright (C) 1994-2006 Axel Sommerfeldt (caption@sommerfee.de)
 % 
 % --------------------------------------------------------------------------
 % 
@@ -19,23 +19,25 @@
 % This Current Maintainer of this work is Axel Sommerfeldt.
 % 
 % This work consists of the files caption.ins, caption.dtx,
-% caption2.dtx, caption.xml, and anleitung.tex and the derived files
+% caption2.dtx, and anleitung.tex and the derived files
 % caption.sty, caption2.sty, caption3.sty, and manual.tex.
 % 
 % \fi
-% \CheckSum{1800}
+% \CheckSum{1956}
 %
 % \iffalse
 %<*driver>
+\NeedsTeXFormat{LaTeX2e}[1994/12/01]
 \documentclass{ltxdoc}
 \setlength\parindent{0pt}
 \setlength\parskip{\smallskipamount}
 %
 \newcommand\NEWfeature{\NEW{New feature}}
 \newcommand\NEWdescription{\NEW{New description}}
-\newcommand\NEW[2]{%
-  \hskip 1sp \marginpar{\footnotesize\sffamily\raggedleft
-    #1\\#2}}
+\newcommand\NEW[2]{\hskip 1sp \marginpar{\footnotesize\sffamily\raggedleft#1\\#2}}
+%
+\font\manual=manfnt
+\newcommand\DANGER{\hskip 1sp \marginpar{\raggedleft\textcolor{blue}{{\manual\char127}}}}
 %
 \ifx\pdfoutput\undefined\else
   \ifcase\pdfoutput\else
@@ -45,11 +47,24 @@
   \fi
 \fi
 %
-\usepackage{caption}[2004/11/28]
+%\usepackage[french,USenglish]{babel}
+\usepackage{color,setspace}
+%
 %\usepackage{float}
-\usepackage{longtable,hyperref}
+\usepackage{longtable}
 %\usepackage[raggedright]{sidecap}
 %
+\usepackage{caption}[2005/08/24]
+\DeclareCaptionLabelSeparator{endash}{\space\textendash\space}
+\usepackage{hyperref}
+%
+\DeclareCaptionFont{singlespacing}{\singlespacing}
+\DeclareCaptionFont{onehalfspacing}{\onehalfspacing}
+\DeclareCaptionFont{doublespacing}{\doublespacing}
+\DeclareCaptionFont{red}{\color{red}}
+\DeclareCaptionFont{green}{\color{green}}
+\DeclareCaptionFont{blue}{\color{blue}}
+%
 \DeclareCaptionLabelSeparator{period-newline}{. \\}
 \DeclareCaptionStyle{period-newline}[labelsep=period]{labelsep=period-newline}
 \DeclareCaptionStyle{period-newline2}[labelsep=period,justification=centering]{labelsep=period-newline}
@@ -62,17 +77,21 @@
 \DeclareRobustCommand{\KOMAScript}{\textsf{K\kern.05em O\kern.05em%
     M\kern.05em A\kern.1em-\kern.1em Script}}
 %
+%<+driver>\OnlyDescription
+%
 \begin{document}
   \DocInput{caption.dtx}
 \end{document}
 %</driver>
 % \fi
 %
-% \newcommand*{\purerm}[1]{{\upshape\mdseries\rmfamily #1}}
-% \newcommand*{\puresf}[1]{{\upshape\mdseries\sffamily #1}}
-% \newcommand*{\purett}[1]{{\upshape\mdseries\ttfamily #1}}
+% \newcommand*\purerm[1]{{\upshape\mdseries\rmfamily #1}}
+% \newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}}
+% \newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}}
 % \let\package\puresf\def\thispackage{\package{caption}}
 % \let\env\purett \let\opt\purett
+%
+% \newcommand*\version[1]{$v#1$}
 % 
 % \newenvironment{Options}[1]%
 %   {\list{}{\renewcommand{\makelabel}[1]{\texttt{##1}\hfil}%
@@ -95,11 +114,10 @@
 % \title{Typesetting captions with the
 %        \thispackage\ package\thanks{This package has version number
 %        \fileversion, last revised \filedate.}}
-% \author{Axel Sommerfeldt\\\href{mailto:caption@sommerfeldt.net}{\texttt{caption@sommerfeldt.net}}}
-% \date{2005/06/13}
+% \author{Axel Sommerfeldt\\\href{mailto:caption@sommerfee.de}{\texttt{caption@sommerfee.de}}}
+% \date{2006/01/12}
 % \maketitle
 % 
-% 
 % \begin{abstract}
 % The \thispackage\ package provides many ways to customise the captions
 % in floating environments such |figure| and |table| and cooperates with
@@ -108,16 +126,17 @@
 % this new enhanced version 3.0.}
 % \end{abstract}
 % 
-% \iffalse
 % \tableofcontents
-% \fi
 % 
-% \newcommand\figuretext{%
+% \newcommand\figuretext{^^A
 %   White sand beaches. The pink smoothness of the conch shell. A sea abundant
 %   with possibilities. Duty-free shops filled with Europe's finest gifts and
 %   perfumes. Play your favorite game of golf amidst the tropical greens on one
 %   of the many championship courses.}
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \section{Introduction}
 % 
@@ -132,11 +151,14 @@
 % add an extra margin, typeset the caption label with the same font family and
 % shape as your headings etc. Just like this one:
 % 
-% \example{belowskip=\abovecaptionskip,size=small,margin=10pt,labelfont=bf}{\figuretext}
+% \example{belowskip=\abovecaptionskip,size=small,margin=10pt,labelfont=bf,labelsep=endash}{\figuretext}
 % 
 % With this package you can do this easily as there are many ready-to-use
 % caption formatting options, but you are free to define your very own stuff, too.
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \pagebreak[4]
 % \section{Using the package}
@@ -189,9 +211,26 @@
 % (For a description of the optional parameter \meta{float type} see
 %  section \ref{misc}: \textit{``Useful stuff''}.)
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
+%
+% \pagebreak[3]
 % \section{Options}
+% 
 % \def\OptionLabel{RaggedRight}
+% \def\UserDefined{\ldots}
+% \makeatletter
+% \newcommand*\Section{\@ifstar{\@Section\relax}{\@Section{section}}}
+% \newcommand*\@Section[3]{#1 \ref{#2}: \textit{``#3''}}
+% \makeatother
+% \newcommand*\See[1]{{\small (See #1)}}
+% \newcommand*\SeeUserDefined[1][]{%
+%   \See{\Section{declare}{Do it yourself}#1}}
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Formatting}
 % 
@@ -209,18 +248,25 @@
 % \end{quote}
 % having the name of the caption format as its argument.
 %
-% There are two standard caption formats:\footnote{You have the option to
+% There are two standard caption formats:
+% \iffalse
+% \footnote{You have the option to
 % define your own ones, too. See section \ref{declare}:
 % \textit{``Do it yourself!''} for details.}
+% \fi
 % 
 % \begin{Options}{\OptionLabel}
-%   \item[default]
+%   \item[plain]\NEWdescription{v3.0h}
 %   Typesets the captions as a normal paragraph.
 %   (This is the default behaviour, it
 %   is adapted from the standard \LaTeX\ document classes.)
 % 
 %   \item[hang]
 %   Indents the caption text, so it will `hang' under the first line of the text.
+% 
+%   \item[\UserDefined]
+%   Own formats can be defined using |\DeclareCaptionFormat|.
+%   \SeeUserDefined
 % \end{Options}
 % 
 % \begin{Example}
@@ -233,7 +279,7 @@
 % \end{Example}
 % 
 % \DescribeMacro{indention=}
-% For both formats (\texttt{default} and \texttt{hang}) you can setup an extra
+% For both formats (\texttt{plain} and \texttt{hang}) you can setup an extra
 % indention starting at the second line of the caption. You do this with the
 % option
 % \begin{quote}
@@ -244,10 +290,10 @@
 % 
 % \begin{Example}
 %   \begin{quote}
-%     |format=default,indention=.5cm|
+%     |format=plain,indention=.5cm|
 %   \end{quote}
 %   \captionsetup{aboveskip=0pt}
-%   \example{format=default,indention=.5cm}{\figuretext}
+%   \example{format=plain,indention=.5cm}{\figuretext}
 % \end{Example}
 % 
 % \begin{Example}
@@ -258,8 +304,10 @@
 %   \example{format=hang,indention=-0.5cm}{\figuretext}
 % \end{Example}
 % 
+% \pagebreak[3]
 % \DescribeMacro{labelformat=}
 % With the option
+% \nopagebreak[3]
 % \begin{quote}
 %   |labelformat=|\meta{label format name}
 % \end{quote}
@@ -282,6 +330,10 @@
 % 
 %   \item[parens]
 %   The number of the caption label will be typeset in parentheses.
+% 
+%   \item[\UserDefined]
+%   Own label formats can be defined using |\DeclareCaptionLabelFormat|.
+%   \SeeUserDefined
 % \end{Options}
 % 
 % \begin{Example}
@@ -321,9 +373,17 @@
 % 
 %   \item[newline]
 %   The caption label and text will be separated by a line break (|\\|).
+% 
+%   \item[endash]\NEWfeature{v3.0h}
+%   The caption label and text will be separated by an en-dash,
+%   surrounded by spaces (| -- |).
+% 
+%   \item[\UserDefined]
+%   Own separators can be defined using |\DeclareCaptionLabelSeparator|.
+%   \SeeUserDefined
 % \end{Options}
 % 
-% Two examples:
+% Three examples:
 % \begin{Example}
 %   \begin{quote}
 %     |labelsep=period|
@@ -340,8 +400,20 @@
 %   \example{labelsep=newline,singlelinecheck=false}{\figuretext}
 % \end{Example}
 % 
+% \begin{Example}
+%   \begin{quote}
+%     |labelsep=endash|
+%   \end{quote}
+%   \captionsetup{aboveskip=0pt}
+%   \example{labelsep=endash}{\figuretext}
+% \end{Example}
+%
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Justification}
+% \label{justification}
 % 
 % \DescribeMacro{justification=}
 % As addition to the caption format you could also specify a
@@ -395,6 +467,10 @@
 %   Each line of the caption will be moved to the right margin using
 %   the command |\RaggedLeft| from the \package{ragged2e} package.
 % \fi
+% 
+%   \item[\UserDefined]
+%   Own justifications can be defined using |\DeclareCaptionJustification|.
+%   \SeeUserDefined
 % \end{Options}
 % 
 % Two examples:
@@ -423,14 +499,15 @@
 % \end{Example}
 % 
 % \DescribeMacro{singlelinecheck=}
-% If the caption fit in a single line it will always be centered, ignoring
-% the justification you set:
+% The standard \LaTeX\ document classes (|article|, |report|, and |book|)
+% automatically center a caption if it fits in one single line:
 %
 % \example{belowskip=\abovecaptionskip}{A short caption.}
 %
-% This behaviour is adapted from the standard \LaTeX\ document classes
-% |article|, |report|, and |book|), but using the \thispackage\ package
-% you can switch this special treatment of such short captions off
+% \DANGER
+% The \thispackage\ package adapts this behaviour and therefore usually
+% ignores the justification you have set with |justification=| in such case.
+% But you can switch this special treatment of such short captions off
 % with the option
 % \begin{quote}
 %   |singlelinecheck=|\meta{bool}\quad.
@@ -451,8 +528,12 @@
 % Using |true|, |yes|, |on| or |1| for \meta{bool} you switch on the
 % extra centering again. (The default is on.)
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Fonts}
+% \label{fonts}
 % 
 % \DescribeMacro{font=}
 % \DescribeMacro{labelfont=}
@@ -489,6 +570,10 @@
 %   \item[rm]           {\rmfamily Roman family}
 %   \item[sf]           {\sffamily Sans Serif family}
 %   \item[tt]           {\ttfamily Typewriter family}
+% 
+%   \item[\UserDefined]
+%   Own font options can be defined using |\DeclareCaptionFont|.
+%   \SeeUserDefined
 % \end{Options}
 % 
 % If you use only one of these options you can omit the braces;
@@ -527,8 +612,12 @@
 %   \example{font=small,labelfont=bf,textfont=it}{\figuretext}
 % \end{Example}
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Margins and further paragraph options}
+% \label{margins}
 % 
 % \DescribeMacro{margin=}
 % \DescribeMacro{width=}
@@ -614,6 +703,9 @@
 %     show how these options affect the layout of the caption.}
 % \end{Example}
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Styles}
 % \label{style}
@@ -635,12 +727,18 @@
 % \end{quote}
 % has the same effect as specifying all these options:
 % \begin{quote}
-%   |format=default,labelformat=simple,labelsep=colon,|\\
-%   |justification=justified,font=default,labelfont=default,|\\
+%   |format=default,labelformat=default,labelsep=default,|\\
+%   |justification=default,font=default,labelfont=default,|\\
 %   |textfont=default,margin=0pt,indention=0pt,parindent=0pt|\\
 %   |hangindent=0pt,singlelinecheck=true|
 % \end{quote}
 % 
+% Own caption styles can be defined using |\DeclareCaptionStyle|.
+% \SeeUserDefined
+% 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Skips}
 % 
@@ -729,8 +827,9 @@
 % 
 % \DescribeMacro{tableposition=}
 % This option is especially useful when used together with the optional
-% argument of the |\captionsetup| command. (See section \ref{misc}:
-% \textit{``Useful stuff''} for details.) E.g.,
+% argument of the |\captionsetup| command.
+% \See{\Section{misc}{Useful stuff} for details}\par
+% E.g.,
 % \begin{quote}
 %   |\captionsetup[table]{position=top}|
 % \end{quote}
@@ -748,8 +847,11 @@
 %   |\captionsetup[table]{position=top}|
 % \end{quote}
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
-% \pagebreak[4]
+% \pagebreak[3]
 % \section{Useful stuff}
 % \label{misc}
 % 
@@ -794,7 +896,7 @@
 %   |  \begin{tabular}{cc}|\\
 %   |    A & B \\|\\
 %   |    C & D \\|\\
-%   |  \end{longtable}|\\
+%   |  \end{tabular}|\\
 %   |\end{table}|
 % \end{quote}
 % 
@@ -864,8 +966,8 @@
 % \end{Example}
 % 
 % \DescribeMacro{\captionsetup}
-% We already know the |\captionsetup| command (see section \ref{usage}:
-% \textit{``Using the package''}), but this time we get enlighten about
+% We already know the |\captionsetup| command (see \Section{usage}
+% {Using the package}), but this time we get enlighten about
 % the optional argument \meta{float type}.
 % 
 % Remember, the syntax of this command is
@@ -918,10 +1020,14 @@
 % 
 % As \meta{float type} you can usually give one of these only two:
 % |figure| and |table|.
-% But as we will see later some \LaTeX\ packages exist (like the \package{float}
-% package for example) who can define additional floating enviroments and these two
-% commands also works with them.
+% But as we will see later that some \LaTeX\ packages exist (like the
+% \package{float}, \package{longtable}, and \package{sidecap} package
+% for example) who can define additional floating enviroments and these two
+% commands can also be used with them.
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \pagebreak[3]
 % \section{Do it yourself!}
@@ -940,10 +1046,10 @@
 %   |\DeclareCaptionFormat|\marg{name}\marg{code using \#1, \#2 and \#3}\quad.
 % \end{quote}
 % At usage the system replaces \#1 with the caption label, \#2 with the
-% separator and \#3 with the text. So the standard format |default| is defined
+% separator and \#3 with the text. So the standard format |plain| is defined
 % inside |caption.sty| as
 % \begin{quote}
-%   |\DeclareCaptionFormat{default}{#1#2#3\par}|
+%   |\DeclareCaptionFormat{plain}{#1#2#3\par}|
 % \end{quote}
 % 
 % \DescribeMacro{\DeclareCaptionLabelFormat}
@@ -1015,6 +1121,26 @@
 %   |\DeclareCaptionFont{small}{\small}|\quad and\\
 %   |\DeclareCaptionFont{bf}{\bfseries}|\quad.
 % \end{quote}
+% The line spacing could be customized using the \package{setspace} package,
+% for example:\NEWdescription{v3.0h}
+% regeln:
+% \begin{quote}
+%   |\usepackage{setspace}|\\
+%   |\DeclareCaptionFont{singlespacing}{\singlespacing}|\\
+%   |\DeclareCaptionFont{onehalfspacing}{\onehalfspacing}|\\
+%   |\DeclareCaptionFont{doublespacing}{\doublespacing}|\\
+%   |\captionsetup{font={onehalfspacing,small},labelfont=bf}|
+% \end{quote}
+% \example{font={onehalfspacing,small},labelfont=bf,singlelinecheck=off}\figuretext
+% An example which brings color into life:
+% \begin{quote}
+%   |\usepackage{color}|\\
+%   |\DeclareCaptionFont{red}{\color{red}}|\\
+%   |\DeclareCaptionFont{green}{\color{green}}|\\
+%   |\DeclareCaptionFont{blue}{\color{blue}}|\\
+%   |\captionsetup{labelfont=blue,textfont=green}|
+% \end{quote}
+% \example{labelfont=blue,textfont=green,singlelinecheck=off}\figuretext
 % 
 % \DescribeMacro{\DeclareCaptionStyle}
 % The best one comes at last: You can define your own caption styles with
@@ -1025,8 +1151,8 @@
 % under a given name. You can wake up these options at any time with the
 % option |style=|\meta{style name}.
 %
-% All caption styles are based on the default set of options. (See section
-% \ref{style}: \textit{``Styles''} for a complete list.) So you only need
+% All caption styles are based on the default set of options. (See \Section
+% {style}{Styles} for a complete list.) So you only need
 % to specify options which are different to them.
 % 
 % If you specify \meta{additional options} they get used in addition when
@@ -1038,6 +1164,9 @@
 %   |\DeclareCaptionStyle{default}[justification=centering]{}|
 % \end{quote}
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Examples}
 % 
@@ -1137,6 +1266,9 @@
 %   \captionof{figure}[]{\figuretext}
 % \end{Example}
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \pagebreak[3]
 % \section{Using non-standard document classes}
@@ -1158,13 +1290,16 @@
 % Using the \thispackage\ package together with document classes not mentioned
 % so far is not recommended at the moment -- unwanted layout changes,
 % side effects or failures could occur. (But future versions of the
-% \thispackage\ package will contain adaptions for more document classes!
+% \thispackage\ package will contain adaptations for more document classes!
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \section{Using other packages}
 % \label{packages}
 % 
-% The \thispackage\ package contains special adaptions to other packages who
+% The \thispackage\ package contains special adaptations to other packages who
 % handle with captions, too, so the captions always should look like you
 % have specified them to look like.
 %
@@ -1205,8 +1340,12 @@
 % at the documentation belonging to it or buy yourself
 % The \LaTeX\ Companion\cite{companion}.
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{The \package{float} package}
+% \label{float}
 % 
 % A very useful feature is provided by the \package{float} package\cite{float}:
 % It offers the float placement specifier |H| which is much more restrictive
@@ -1287,8 +1426,12 @@
 % \textbf{Note:} For successful cooperation you need the float package
 % version 1.3 or newer.
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{The \package{listings} package}
+% \label{listings}
 % 
 % \NEWdescription{v3.0b}
 % The \package{listings} package\cite{listings} is a source code printer for \LaTeX.
@@ -1302,8 +1445,12 @@
 % version 1.2 or higher. You'll get an error message when using an
 % older version!
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{The \package{longtable} package}
+% \label{longtable}
 % 
 % The \package{longtable} package\cite{longtable} offers the environment
 % |longtable| which behaves similar to the |tabular| environment, but
@@ -1312,16 +1459,24 @@
 % \textbf{Note:} For successful cooperation you need the longtable package
 % version 3.15 or newer.
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{The \package{rotating} package}
+% \label{rotating}
 % 
 % The \package{rotating} package\cite{rotating} offers the floating
 % environments \texttt{sideways\-figure} and \texttt{sideways\-table}
 % which are just like normal figures and tables but rotated by 90 degree.
 % Furthermore they always use a full page on their own.
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{The \package{sidecap} package}
+% \label{sidecap}
 % 
 % \NEWdescription{v3.0b}
 % The \package{sidecap} package\cite{sidecap} offers the floating
@@ -1389,8 +1544,12 @@
 % 
 % \fi
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{The \package{supertabular} package}
+% \label{supertabular}
 % 
 % The \package{supertabular} package\cite{supertabular} offers the environment
 % |supertabular| which is quite similar to the |longtable| environment provided
@@ -1399,6 +1558,9 @@
 % differences between these powerful packages please take a look at
 % The \LaTeX\ Companion\cite{companion}.
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \subsection{Known incompatibilities}
 % 
@@ -1407,13 +1569,18 @@
 % is not recommended; usually this would cause unwanted side effects or even
 % errors:
 % \begin{quote}
-% \package{ccaption}, \package{hvfloat}, \package{nonfloat}
+%   \package{ccaption}, \package{ftcap}, \package{hvfloat}, and
+%   \package{nonfloat}
 % \end{quote}
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \section{Compatibility to older versions}
+% \label{compatibility}
 % 
-% \subsection{\thispackage\ version $1.x$}
+% \subsection{The \thispackage\ package version $1.x$}
 % 
 % This version of the \thispackage\ package still supports the old options
 % and commands provided by the version $1.x$ of this package. So there
@@ -1421,60 +1588,178 @@
 % old options and commands with the new ones. This isn't supported and can
 % yield to ugly side effects.
 % 
-% Here comes a short oversight of the old options and commands and how they
-% are replaced within this version of the \thispackage\ package:
+% Here comes a short oversight of the obsolete options and commands and how
+% they have been replaced within this version of the \thispackage\ package:
 % 
-% \begin{small}\begin{longtable}{ll}
-% \thispackage\ $1.\mathit{x}$ & \thispackage\ $3.\mathit{x}$\\
+% {\small\begin{longtable}{ll}
+% \thispackage\ \version{1.x} & \thispackage\ \version{3.x}\\
 % \hline
 % \endhead
-% |normal|                           & |format=default|\\
-% |hang|                             & |format=hang|\\
-% |isu|                              & |format=hang|\\
-% |center|                           & |justification=centering|\\
-% |centerlast|                       & |justification=centerlast|\\
-% |anne|                             & |justification=centerlast|\\
-% |nooneline|                        & |singlelinecheck=off|\\
-% |scriptsize|                       & |font=scriptsize|\\
-% |footnotesize|                     & |font=footnotesize|\\
-% |small|                            & |font=small|\\
-% |normalsize|                       & |font=normalsize|\\
-% |large|                            & |font=large|\\
-% |Large|                            & |font=Large|\\
-% |up|                               & |labelfont=up|\\
-% |it|                               & |labelfont=it|\\
-% |sl|                               & |labelfont=sl|\\
-% |sc|                               & |labelfont=sc|\\
-% |md|                               & |labelfont=md|\\
-% |bf|                               & |labelfont=bf|\\
-% |rm|                               & |labelfont=rm|\\
-% |sf|                               & |labelfont=sf|\\
-% |tt|                               & |labelfont=tt|\\
-% |\setlength{\captionmargin}|       & |margin=|\meta{amount}\\
-% |\renewcommand{\captionfont}|      & |\DeclareCaptionFont|\\
-%                                    & $+$ |\captionsetup{font=|\meta{name}|}|\\
-% |\renewcommand{\captionsize}|      & |\DeclareCaptionFont|\\
-%                                    & $+$ |\captionsetup{font=|\meta{name}|}|\\
-% |\renewcommand{\captionlabelfont}| & |\DeclareCaptionLabelFont|\\
-%                                    & $+$ |\captionsetup{labelfont=|\meta{name}|}|\\
-% \end{longtable}\end{small}
-% 
-% 
-% \subsection{\package{caption2} version $2.x$}
+% |normal|        & |format=plain|\\
+% |hang|          & |format=hang|\\
+% |isu|           & |format=hang|\\
+% |center|        & |justification=centering|\\
+% |centerlast|    & |justification=centerlast|\\
+% \iffalse
+% |anne|          & |justification=centerlast|\\
+% \fi
+% |nooneline|     & |singlelinecheck=off|\\
+% |scriptsize|    & |font=scriptsize|\\
+% |footnotesize|  & |font=footnotesize|\\
+% |small|         & |font=small|\\
+% |normalsize|    & |font=normalsize|\\
+% |large|         & |font=large|\\
+% |Large|         & |font=Large|\\
+% |up|            & |labelfont=up|\\
+% |it|            & |labelfont=it|\\
+% |sl|            & |labelfont=sl|\\
+% |sc|            & |labelfont=sc|\\
+% |md|            & |labelfont=md|\\
+% |bf|            & |labelfont=bf|\\
+% |rm|            & |labelfont=rm|\\
+% |sf|            & |labelfont=sf|\\
+% |tt|            & |labelfont=tt|\\
+% \end{longtable}}
+% 
+% Beside the options for setting up the desired font there were also
+% the commands |\captionsize| resp.~|\captionfont| and |\captionlabelfont|
+% who could be redefined with |\renewcommand| and allowed an alternate and
+% more flexible way to change the font used for captions.
+% This mechanism was replaced by the commands
+% \begin{minipage}\linewidth\begin{quote}
+%   |\DeclareCaptionFont{|\ldots|}{|\ldots|}|\qquad and\\
+%   |\captionsetup{font=|\ldots|,labelfont=|\ldots|}|\qquad.
+% \end{quote}\SeeUserDefined\strut\end{minipage}
+% 
+% Setting the margin for captions was done in \version{1.x} with
+% \begin{quote}
+%   |\setlength{\captionmargin}{|\ldots|}|\quad.
+% \end{quote}
+% This was replaced by
+% \begin{quote}
+%   |\captionsetup{margin=|\ldots|}|\qquad.
+% \end{quote}
+% \See{\Section{margins}{Margins and further paragraph options}}
+% 
+% For example the old-style code
+% \begin{quote}
+% |\usepackage[hang,bf]{caption}|\\
+% |\renewcommand\captionfont{\small\sffamily}|\\
+% |\setlength\captionmargin{10pt}|
+% \end{quote}
+% should now be written as
+% \begin{quote}
+% |\usepackage[format=hang,labelfont=bf,font={small,sf},|\\
+% |            margin=10pt]{caption}|
+% \end{quote}
+% or
+% \begin{quote}
+% |\usepackage{caption}|\\
+% |\captionsetup{format=hang,labelfont=bf,font={small,sf},|\\
+% |              margin=10pt}|\qquad.
+% \end{quote}
+% 
+% The quite exotic option |ruled| who allowed a partial usage of
+% the caption settings for |ruled| floats defined with the
+% \package{float} package will be emulated by this version of the
+% caption package, too.
+% But using this option is not recommended anymore since this
+% version of the \thispackage\ package offers a more flexible way
+% for changing the captions of these floating environments:
+% \begin{quote}
+%   |\DeclareCaptionStyle{ruled}{|\ldots|}|
+% \end{quote}
+% resp.
+% \begin{quote}
+%   |\captionsetup[ruled]{|\ldots|}|\qquad.
+% \end{quote}
+% \SeeUserDefined[, \Section*{misc}{Useful stuff}, and
+%                 \Section*{float}{The \package{float} package}]
+% 
+% \subsection{The \package{caption2} package version $2.x$}
 % 
 % Although they do very similar stuff the packages \package{caption} and
-% \package{caption2} have a very different implementation design. So this
-% version of the \thispackage\ package isn't compatible to the
-% \package{caption2} package at all. Of course for compiling old documents
-% you can still use the \package{caption2} package, the latest version
-% is provided with this package. But newly created documents shouldn't use
-% the \package{caption2} package, please use the \thispackage\ package
-% instead as described in this manual.
+% its experimental and now obsolete variant \package{caption2} have a
+% very different implementation design.
+% Therefore a full compatibility could not be offered.
+% For that reason you will still find a file called |caption2.sty| in
+% this package distribution, so old documents using the \package{caption2}
+% package will still compile fine.
+% 
+% Newly created documents should use the actual version of the
+% \thispackage\ package instead. In most cases it's sufficient to replace
+% the command
+% \begin{quote}
+%   |\usepackage[...]{caption2}|
+% \end{quote}
+% by
+% \begin{quote}
+%   |\usepackage[...]{caption}|\qquad.
+% \end{quote}
+% But some options and commands will not be emulated, so you can get
+% error messages afterwards. This section will help you removing
+% these errors. If you have problems migrating from \package{caption2}
+% to \package{caption} please don't hesitate to send me an e-mail.
+% 
+% In addition to the obsolete options shown in the last section
+% these ones will be emulated, too:
+% 
+% {\small\begin{longtable}{ll}
+% \package{caption2} \version{2.x} & \thispackage\ \version{3.x}\\
+% \hline
+% \endhead
+% |flushleft|   & |justification=raggedright|\\
+% |flushright|  & |justification=raggedleft|\\
+% |oneline|     & |singlelinecheck=on|\\
+% \end{longtable}}
+% 
+% Setting the margin for captions was done in \version{2.x} with
+% \begin{quote}\leavevmode\hbox{%
+%   |\setcaptionmargin{|\ldots|}| resp.
+%   |\setcaptionwidth{|\ldots|}|\quad.
+% }\end{quote}
+% This was replaced by
+% \begin{quote}\leavevmode\hbox{%
+%   |\captionsetup{margin=|\ldots|}| resp.
+%   |\captionsetup{width=|\ldots|}|\quad.
+% }\end{quote}
+% \See{\Section{margins}{Margins and further paragraph options}}
+% 
+% The so-called single-line-check was controlled by the commands
+% |\oneline|\-|captions|\-|false| (for switching the check off) and
+% |\oneline|\-|captions|\-|true| (for switching the check on).
+% This was replaced by
+% |\captionsetup{|\discretionary{}{}{}|singlelinecheck=|\discretionary{}{}{}|off}|
+% resp.
+% |\captionsetup{|\discretionary{}{}{}|singlelinecheck=|\discretionary{}{}{}|on}|.
+% \See{\Section{justification}{Justification}}
+% 
+% The commands
+% \begin{quote}
+%   |\captionstyle|, |\captionlabeldelim|, |\captionlabelsep|,\\
+%   |\captionindent|, |\captionlabelfalse|, |\defcaptionstyle|,\\
+%   |\newcaptionstyle|, and |\renewcaptionstyle|
+% \end{quote}
+% do not have a simple replacement and therefore will not be emulated
+% by this version of the \thispackage\ package. (So using them will
+% yield to error messages.) Rewriting such code is not always easy and
+% straight-ahead, but by conscientious reading of this manual you should
+% find appropriate options and commands instead.
 % 
 % \iffalse
-% TODO: Table like the "caption 1.x => caption 3.x" one
+% ... (some examples)
 % \fi
 % 
+% The \version{2.x} option |ignoreLTcapwidth| do not have a replacement, too.
+% But in most cases you could simply drop using that option because
+% in this version of the \thispackage\ package the value of |\LTcapwidth|
+% will be ignored anyway (unless you set it to a different value than the
+% default one).
+% \See{\Section{longtable}{The \package{longtable} package}}
+% 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \pagebreak[3]
 % \section{Further reading}
@@ -1492,19 +1777,20 @@
 % 
 % \item
 %   \textsf{epslatex} from Keith Reckdahl contains many tips around
-%   graphics in \LaTeXe. You will find this document in the directory
-%   \begin{quote}\url{ftp://ftp.ctan.org/pub/tex/info/}\end{quote}
-%   as \texttt{epslatex.ps} and \texttt{epslatex.pdf}.
-%
-%   There is also a french translation available:
-%   \begin{quote}\url{ftp://ftp.ctan.org/pub/tex/info/fepslatex.ps}\end{quote}
+%   including graphics in \LaTeXe\ documents.
+%   You will find this document in the directory
+%   \begin{quote}\url{ftp://ftp.ctan.org/pub/tex/info/epslatex/}\end{quote}
 % \end{itemize}
 % 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 % 
 % \section{Thanks}
 % 
-% I would like to thank Katja Melzner, Steven D. Cochran, Frank Mittelbach,
-% David Carlisle, Carsten Hinz, and Olga Lapko.
+% I would like to thank Katja Melzner,
+% Steven D. Cochran, Frank Mittelbach,
+% David Carlisle, Carsten Hinz, Olga Lapko, and Keith Reckdahl.
 % Thanks a lot for all your help, ideas, patience, spirit, and support!
 % 
 % Also I would like to thank
@@ -1515,24 +1801,19 @@
 % Matthias Pospiech,
 % J\"urgen Wieferink,
 % Christoph Bartoschek,
-% Uwe St\"ohr, and
-% Ralf Stubner
+% Uwe St\"ohr,
+% Ralf Stubner,
+% Geoff Vallis,
+% Florian Keiler,
+% J\"urgen G\"obel,
+% and
+% Uwe Siart
 % who all helped to make this package a better one.
-%
-%
-% \changes{v1.0}{27 Oct 94}{First release}
-% \changes{v1.1}{ 3 Nov 94}{New captiontype \cs{centerlast}}
-% \changes{v1.2}{28 Nov 94}{Support of the {\sf float} package}
-% \changes{v1.3}{ 8 Jan 95}{Support of \cs{captionlabelfont} in subcaptions}
-% \changes{v1.4}{30 Jan 95}{New option \cs{nooneline}}
-% \changes{v3.0}{10 Jul 03}{Rewritten; many new commands and features}
-% \changes{v3.0a}{22 Jan 04}{Some bugfixes and small design changes}
-% \changes{v3.0b}{14 May 04}{Some bugfixes and small improvements}
-% \changes{v3.0c}{15 Jul 04}{Bugfix regarding rotating and sidecap package support}
-% \changes{v3.0d}{12 Feb 05}{Split into 2 packages; some bugfixes and improvements}
-% \changes{v3.0e}{ 5 May 05}{Some bugfixes}
-% \changes{v3.0f}{11 May 05}{hypcap support; bugfix regarding float support}
-%
+% 
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
+% 
 % \StopEventually{\begin{thebibliography}{9}
 %   \bibitem{companion}
 %   Frank Mittelbach and Michel Goossens:
@@ -1582,14 +1863,23 @@
 %   \bibitem{subfig}
 %   Steven D. Cochran:
 %   \emph{The subfig package},
-%   2004/01/16
+%   2005/07/05
 % 
 %   \bibitem{supertabular}
 %   Johannes Braams und Theo Jurriens:
 %   \emph{The supertabular environment},
 %   2002/07/19
+%
+%   \bibitem{Anne}
+%   Anne Br\"uggemann-Klein:
+%   \emph{Einf\"uhrung in die Dokumentverarbeitung},
+%   B.G. Teubner, Stuttgart, 1989
 % \end{thebibliography}}
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
+% 
 % \DoNotIndex{\\,\_,\ ,\@@par}
 % \DoNotIndex{\@classoptionslist,\@currext,\@currname}
 % \DoNotIndex{\@ehc,\@ehd,\@empty,\@expandtwoargs}
@@ -1630,20 +1920,34 @@
 % \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
 % \DoNotIndex{\ProcessOptions,\ProvidesPackage}
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
+% 
 % \clearpage
 % \setlength{\parskip}{0pt plus 1pt}
 %
 % \section{The Implementation}
 %
-% The \package{caption} package consists of two parts -- the kernel and the
-% main package.
+% \changes{v1.0}{1994/10/27}{First release}
+% \changes{v1.1}{1994/11/03}{New captiontype \cs{centerlast}}
+% \changes{v1.2}{1994/11/28}{Support of the \package{float} package}
+% \changes{v1.3}{1995/01/09}{Support of \cs{captionlabelfont} in subcaptions}
+% \changes{v1.4}{1995/01/30}{New option \cs{nooneline}}
+% \changes{v1.4b}{1995/04/05}{Bugfix release}
+% \changes{v3.0}{2003/12/20}{Rewritten; many new commands and features}
+% \changes{v3.0d}{2004/11/28}{Split into two packages: \package{caption} \& \package{caption3}}
+%
+% The \package{caption} package consists of two parts -- the kernel
+% (|caption3.sty|) and the main package (|caption.sty|).
 %
 % The kernel provides all the user commands and internal macros which are
 % necessary for typesetting captions and setting parameters regarding these.
 % While the standard \LaTeX\ document classes provides an internal command
 % called |\@makecaption| and no options to control its behavior (except the
-% vertical skips above and below them), we provide similar commands called
-% |\caption@make| and |\caption@@make|, but with a lot of options.
+% vertical skips above and below the caption itself), we provide similar
+% commands called |\caption@make| and |\caption@@make|, but with a lot of
+% options which can be selected with |\captionsetup|.
 % Loading the kernel part do not change the output of a \LaTeX\ document
 % -- it just provides functionality which can be used by \LaTeXe\ packages
 % which typesets captions, like the \package{caption} package or the
@@ -1653,14 +1957,19 @@
 % |\caption|, |\@caption|, and |\@makecaption| and maps the latter one to
 % |\caption@@make|, giving the user the possibility to control the captions of
 % the floating environments |figure| and |table|. Furthermore it does similar
-% to the caption stuff coming from other packages like the \package{longtable}
-% package: Mapping the appropriate internal commands (like |\LT@makecaption|)
-% to the ones offered by the \package{caption} kernel.
+% to the caption stuff coming from other packages (like the \package{longtable}
+% or \package{supertabular} package):
+% Mapping the appropriate internal commands (like |\LT@makecaption| or
+% |\ST@caption|) to the ones offered by the \package{caption} kernel.
 % So you can think of the \package{caption} package as a layer package, it
-% simply provides adaption layers between the caption stuff coming from
-% \LaTeX\ itself or any \LaTeXe\ package and the caption stuff offered by the
+% simply provides adaptation layers between the caption stuff coming from
+% \LaTeXe\ itself or a \LaTeXe\ package and the caption stuff offered by the
 % \package{caption} kernel.
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
+%
 % \subsection{Kernel}
 % \iffalse
 %<*kernel>
@@ -1670,16 +1979,17 @@
 %
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{caption3}[2005/06/11 v3.0f caption3 kernel (AS)]
+\ProvidesPackage{caption3}[2006/03/16 v3.0j caption3 kernel (AR)]
+%<+debug>\PackageWarning{caption3}{DEBUG VERSION}
 %    \end{macrocode}
 %
 % \subsubsection*{Generic helpers}
 %
 % \begin{macro}{\@nameundef}
-% This is the opposite part to |\@namedef| which is offered by the \LaTeX\ kernel.
-% We use it to remove the definition of some commands and keyval options after
-% |\begin{document}| (to save \TeX\ memory) or to remove caption options defined
-% with |\captionsetup|\oarg{type}.
+%  This is the opposite to |\@namedef| which is offered by the \LaTeX\ kernel.
+%  We use it to remove the definition of some commands and keyval options after
+%  |\begin{document}| (to save \TeX\ memory) and to remove caption options defined
+%  with |\captionsetup|\oarg{type}.
 %    \begin{macrocode}
 \providecommand*\@nameundef[1]{%
   \expandafter\let\csname #1\endcsname\@undefined}
@@ -1687,9 +1997,9 @@
 % \end{macro}
 %
 % \begin{macro}{\l@addto@macro}
-% The \LaTeXe\ kernel offers the internal helper macro |\g@addto@macro| which
-% globally adds commands to any existising macro, like in |\AtBeginDocument|.
-% This is the same but it works local, not global.
+%  The \LaTeXe\ kernel offers the internal helper macro |\g@addto@macro| which
+%  globally adds commands to any existising macro, like in |\AtBeginDocument|.
+%  This is the same but it works local, not global.
 %    \begin{macrocode}
 \providecommand\l@addto@macro[2]{%
   \begingroup
@@ -1701,15 +2011,17 @@
 %
 % \begin{macro}{\bothIfFirst}
 % \begin{macro}{\bothIfSecond}
-% |\bothIfFirst| tests if the first argument is not empty, |\bothIfSecond|
-% tests if the second argument is not empty. If yes both arguments get
-% typeset, otherwise none of them.
+%  |\bothIfFirst| tests if the first argument is not empty, |\bothIfSecond|
+%  tests if the second argument is not empty. If yes both arguments get
+%  typeset, otherwise none of them.
 %    \begin{macrocode}
 \def\bothIfFirst#1#2{%
   \protected@edef\caption@tempa{#1}%
   \ifx\caption@tempa\@empty\else
     #1#2%
   \fi}
+%    \end{macrocode}
+%    \begin{macrocode}
 \def\bothIfSecond#1#2{%
   \protected@edef\caption@tempa{#2}%
   \ifx\caption@tempa\@empty\else
@@ -1720,12 +2032,12 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@ifinlist}
-% This helper macro checks if the first argument is in the list which is
-% offered as second argument. So for example
-% \begin{quote}
-%   |\caption@ifinlist{frank}{axel,frank,steven}{yes}{no}|
-% \end{quote}
-% would expand to |yes|.
+%  This helper macro checks if the first argument is in the comma separated
+%  list which is offered as second argument. So for example
+%  \begin{quote}
+%    |\caption@ifinlist{frank}{axel,frank,steven}{yes}{no}|
+%  \end{quote}
+%  would expand to |yes|.
 %    \begin{macrocode}
 \def\caption@ifinlist#1#2{%
   \let\next\@secondoftwo
@@ -1740,12 +2052,14 @@
 %
 % \begin{macro}{\caption@setbool}
 % \begin{macro}{\caption@ifbool}
-% For setting and testing boolean options we offer these two helper macros:
-% \begin{quote}
-% |\caption@setbool|\marg{name}\marg{value}\\
-% |                |(with |value = false/true/no/yes/off/on/0/1|)\\
-% |\caption@ifbool|\marg{name}\marg{if-clause}\marg{else-clause}\\
-% \end{quote}
+% \begin{macro}{\caption@undefbool}
+%  For setting and testing boolean options we offer these three helper macros:
+%  \begin{quote}
+%  |\caption@setbool|\marg{name}\marg{value}\\
+%  |                |(with |value = false/true/no/yes/off/on/0/1|)\\
+%  |\caption@ifbool|\marg{name}\marg{if-clause}\marg{else-clause}\\
+%  |\caption@undefbool|\marg{name}
+%  \end{quote}
 %    \begin{macrocode}
 \def\caption@setbool#1#2{%
   \caption@ifinlist{#2}{1,true,yes,on}{%
@@ -1755,8 +2069,14 @@
   }{%
     \PackageError{caption}{Undefined boolean value `#2'}{\caption@eh}%
   }}}
+%    \end{macrocode}
+%    \begin{macrocode}
 \def\caption@ifbool#1{\@nameuse{caption@if#1}}
 %    \end{macrocode}
+%    \begin{macrocode}
+\def\caption@undefbool#1{\@nameundef{caption@if#1}}
+%    \end{macrocode}
+% \end{macro}
 % \end{macro}
 % \end{macro}
 %
@@ -1777,11 +2097,13 @@
 % \end{macro}
 %
 % \begin{macro}{\DeclareCaptionOption}
-% |\DeclareCaptionOption|\marg{option}\marg{code}\\
-% |\DeclareCaptionOption*|\marg{option}\marg{code}\par
-% The starred form makes the option only available during the lifetime
-% of the current package, so they are only avail at |\usepackage|, but
-% can't be used with |\captionsetup| later on.
+%  |\DeclareCaptionOption|\marg{option}\marg{code}\\
+%  |\DeclareCaptionOption*|\marg{option}\marg{code}\par
+%  We declare our options using these commands (instead of using
+%  |\DeclareOption| offered by \LaTeXe), so the keyval package is used.
+%  The starred form makes the option available during the lifetime of the
+%  current package only, so they can be used with |\usepackage|, but
+%  \emph{not} with |\captionsetup| later on.
 %    \begin{macrocode}
 \newcommand\DeclareCaptionOption{%
   \@ifstar{\caption@declareoption\AtEndOfPackage}%
@@ -1794,64 +2116,90 @@
 % \end{macro}
 %
 % \begin{macro}{\captionsetup}
-% |\captionsetup|\oarg{type}\marg{keyval-list of options}\par
-% If `type' is set, we simply save or append the option list,
-% otherwise we `execute' it with |\setkeys|.
-% \changes{v3.0a}{17 Jan 04}{Missing percent added}
+% \changes{v3.0a}{2004/01/17}{Bugfix: Missing \% added}
+%  |\captionsetup|\oarg{type}\marg{keyval-list of options}\par
+%  If the optional argument `type' is specified, we simply save or append
+%  the option list, otherwise we `execute' it with |\setkeys|.
 %    \begin{macrocode}
-\def\captionsetup{\@ifnextchar[\caption@setuptype\caption@setup}
+\newcommand\captionsetup{\@ifnextchar[\caption@setuptype\caption@setup}
+\newcommand\caption@typ@{caption@typ@} % This saves 74 words of TeX memory
 \def\caption@setuptype[#1]#2{%
-  \@ifundefined{caption@typ@#1}%
-    {\@namedef{caption@typ@#1}{#2}}%
-    {\expandafter\l@addto@macro\csname caption@typ@#1\endcsname{,#2}}}
-\def\caption@setup{\setkeys{caption}}
+  \@ifundefined{\caption@typ@#1}%
+    {\@namedef{\caption@typ@#1}{#2}}%
+    {\expandafter\l@addto@macro\csname\caption@typ@#1\endcsname{,#2}}}
+\newcommand\caption@setup{\caption@setkeys{caption}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@setkeys}
+% \changes{v3.0i}{2006/01/03}{\cs{caption@setkeys} introduced}
+% This one simply calls |\setkeys| but lets error messages refer to
+% the \package{caption} package instead of the \package{keyval} package.
+%    \begin{macrocode}
+\newcommand*\caption@setkeys[2]{%
+  \let\caption@KV@errx\KV@errx
+  \let\caption@KV@err\KV@err
+  \def\KV@errx##1{\PackageError\caption@package{##1}\@ehc}%
+  \let\KV@err\KV@errx
+  \setkeys{#1}{#2}%
+  \let\KV@errx\caption@KV@errx
+  \let\KV@err\caption@KV@err}
+\newcommand\caption@package{caption}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@settype}
-% |\caption@settype|\marg{type}\par
-% Caption options which have been saved with |\captionsetup|\oarg{type} can
-% be executed using this macro. (It simply executes the saved option list,
-% if there is any.)
-%    \begin{macrocode}
-\def\caption@settype#1{%
-  \@ifundefined{caption@typ@#1}{}{%
-    \caption@esetup{\csname caption@typ@#1\endcsname}}}
+% \changes{v3.0i}{2006/01/03}{Optional argument added}
+% \changes{v3.0j}{2006/01/26}{Revised}
+%  |\caption@settype|\oarg{package}\marg{type}\par
+%  Caption options which have been saved with |\captionsetup|\oarg{type} can
+%  be executed using this command.
+%  (It simply executes the saved option list, if there is any.)
+%    \begin{macrocode}
+\newcommand\caption@settype{%
+  \@ifnextchar[\caption@@settype{\caption@@settype[caption]}}
+\def\caption@@settype[#1]#2{%
+  \@ifundefined{\caption@typ@#2}{}{%
+    \def\caption@package{#1}%
+    \caption@esetup{\csname\caption@typ@#2\endcsname}%
+    \def\caption@package{caption}}}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@esetup}
-% To execute a keyval-list of options saved within a macro we
-% need this special version of |\caption@setup| which expands the
-% argument first.
+%  |\caption@esetup|\marg{keyval-list of options}\par
+%  To execute a keyval-list of options saved within a macro we
+%  need this special version of |\caption@setup| which expands the
+%  argument first.
 %    \begin{macrocode}
-\def\caption@esetup#1{%
+\newcommand*\caption@esetup[1]{%
   \edef\caption@tempa{\noexpand\caption@setup{#1}}%
   \caption@tempa}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\clearcaptionsetup}
-% |\clearcaptionsetup|\marg{type}\par
-% This removes the saved option list associated with \meta{type}.
+%  |\clearcaptionsetup|\marg{type}\par
+%  This removes the saved option list associated with \meta{type}.
 %    \begin{macrocode}
-\newcommand*\clearcaptionsetup[1]{\@nameundef{caption@typ@#1}}
+\newcommand*\clearcaptionsetup[1]{\@nameundef{\caption@typ@#1}}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\showcaptionsetup}
-% |\showcaptionsetup|\oarg{package}\marg{type}\par
-% This command is for debugging issues: It shows the saved option list which
-% is associated with \meta{type}.
+% \changes{v3.0e}{2005/05/03}{Optimized for memory usage}
+%  |\showcaptionsetup|\oarg{package}\marg{type}\par
+%  This comes for debugging issues: It shows the saved option list which
+%  is associated with \meta{type}.
 %    \begin{macrocode}
 \newcommand*\showcaptionsetup[2][\@firstofone]{%
   \GenericWarning{}{%
     #1 Caption Info: KV list on `#2'\MessageBreak
     #1 Caption Data: (%
-    \@ifundefined{caption@typ@#2}{%
-      % Empty -- print nothing.
+    \@ifundefined{\caption@typ@#2}{%
+      % empty -- print nothing
     }{%
-      \@nameuse{caption@typ@#2}%
+      \@nameuse{\caption@typ@#2}%
     }%
     )}}
 %    \end{macrocode}
@@ -1860,7 +2208,8 @@
 % \subsubsection*{Errors}
 %
 % \begin{macro}{\caption@eh}
-% We only provide this simple error message as helper for the user.
+%  At the moment we only offer this simple error message as generic helper
+%  for the user.
 %    \begin{macrocode}
 \newcommand\caption@eh{%
   If you do not understand this error, please take a closer look\MessageBreak
@@ -1872,46 +2221,64 @@
 % \subsubsection*{Margin resp. width}
 %
 % \begin{macro}{\captionmargin}
+% \begin{macro}{\captionmarginx}
 % \begin{macro}{\captionwidth}
-% \begin{macro}{\ifcaption@width}
-% |\captionmargin| and |\captionwidth| contains the extra margin
-% resp. the total width used for captions. Never set these values in a
-% direct way, they are just accessible in user documents to provide
-% compatibility to |caption.sty| v$1.x$.
+%  |\captionmargin| and |\captionwidth| contain the extra margin
+%  resp. the total width used for captions. Please never set these values in
+%  a direct way, they are just accessible in user documents to provide
+%  compatibility to |caption.sty| \version{1.x}.\par
+%  Note that we can only set one value at a time, `margin' \emph{or} `width'.
+%  If |\captionwidth| is not zero we will take this value afterwards,
+%  otherwise |\captionmargin| and |\captionmarginx|.
 %    \begin{macrocode}
 \newdimen\captionmargin
+\newdimen\captionmarginx
 \newdimen\captionwidth
-\newif\ifcaption@width
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 %
 %    \begin{macrocode}
-\DeclareCaptionOption{margin}{\caption@setmargin{#1}}
-\DeclareCaptionOption{width}{\caption@setwidth{#1}}
+\DeclareCaptionOption{margin}{\setcaptionmargin{#1}}
+\DeclareCaptionOption{width}{\setcaptionwidth{#1}}
 %    \end{macrocode}
 %
-% \begin{macro}{\caption@setmargin}
-% \begin{macro}{\caption@setwidth}
-% Note that we can only set one at a time, `margin' \emph{or} `width'.
-% Which dimension is actually set will be recognized by |\ifcaption@width|.
+% \begin{macro}{\setcaptionmargin}
+%  |\setcaptionmargin|\marg{amount}
+% \changes{v3.0h}{2005/10/24}{Renamed from \cs{caption@setmargin} to \cs{setcaptionmargin}}
+% \changes{v3.0h}{2005/10/24}{\cs{setcaptionmargin} enhanced so it can take left+right margin}
+%  |\setcaptionmargin|\marg{amount}\par
+%  Please never use this in user documents, it's just there to
+%  provide compatibility to |caption2.sty| \version{2.x}.
 %    \begin{macrocode}
-\newcommand\caption@setmargin{%
-  \caption@widthfalse
-  \setlength\captionmargin}
-\newcommand\caption@setwidth{%
-  \caption@widthtrue
-  \setlength\captionwidth}
+\newcommand*\setcaptionmargin[1]{%
+  \captionwidth\z@
+  \caption@@setmargin#1,#1,\@nil\@@}
+\def\caption@@setmargin#1,#2,#3\@@{%
+  \setlength\captionmargin{#1}%
+  \setlength\captionmarginx{#2}%
+  \advance\captionmarginx by -\captionmargin}
 %    \end{macrocode}
 % \end{macro}
+%
+% \begin{macro}{\setcaptionwidth}
+%  |\setcaptionwidth|\marg{amount}
+% \changes{v3.0h}{2005/10/24}{Renamed from \cs{caption@setwidth} to \cs{setcaptionwidth}}
+%  |\setcaptionwidth|\marg{amount}\par
+%  Please never use this in user documents, it's just there to
+%  provide compatibility to |caption2.sty| \version{2.x}.
+%    \begin{macrocode}
+\newcommand\setcaptionwidth{%
+  \setlength\captionwidth}
+%    \end{macrocode}
 % \end{macro}
 %
 % \subsubsection*{Indentions}
 % \begin{macro}{\captionindent}
 % \begin{macro}{\captionparindent}
 % \begin{macro}{\captionhangindent}
-% These are the indentions we support.
+%  These are the indentions we support.
 %    \begin{macrocode}
 \newdimen\captionindent
 \newdimen\captionparindent
@@ -1921,18 +2288,23 @@
 % \end{macro}
 % \end{macro}
 %
+% \changes{v3.0b}{2004/05/16}{Defaults added for options \opt{parindent=} and \opt{hangindent=}}
+% \changes{v3.0h}{2005/08/22}{Option \opt{parskip=}: \cs{AtBeginCaption} replaced by \cs{caption@@par}}
+% \changes{v3.0h}{2005/08/22}{Undocumented defaults for \opt{parindent=}, \opt{hangindent=},
+%                             and \opt{parskip=} removed}
 %    \begin{macrocode}
 \DeclareCaptionOption{indent}[\leftmargini]{\setlength\captionindent{#1}}% obsolete!
 \DeclareCaptionOption{indention}[\leftmargini]{\setlength\captionindent{#1}}
-\DeclareCaptionOption{parindent}[\parindent]{\setlength\captionparindent{#1}}% changed v3.0b
-\DeclareCaptionOption{hangindent}[0pt]{\setlength\captionhangindent{#1}}% changed v3.0b
+\DeclareCaptionOption{hangindent}{\setlength\captionhangindent{#1}}
+\DeclareCaptionOption{parindent}{\setlength\captionparindent{#1}}
+\DeclareCaptionOption{parskip}{\l@addto@macro\caption@@par{\setlength\parskip{#1}}}
 %    \end{macrocode}
 %
 % \subsubsection*{Styles}
 %
 % \begin{macro}{\DeclareCaptionStyle}
-% |\DeclareCaptionStyle|\marg{name}\oarg{single-line-list-of-KV}\marg{list-of-KV}
-% \changes{v3.0a}{17 Jan 04}{We pass through argument no.3 so extra spaces between the arguments do make any harm}
+% \changes{v3.0a}{2004/01/17}{Pass through argument \#3 so extra spaces between arguments do make any harm}
+%  |\DeclareCaptionStyle|\marg{name}\oarg{single-line-list-of-KV}\marg{list-of-KV}
 %    \begin{macrocode}
 \newcommand*\DeclareCaptionStyle[1]{%
   \@ifnextchar[{\caption@declarestyle{#1}}{\caption@declarestyle{#1}[]}}
@@ -1949,40 +2321,44 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@setstyle}
-% |\caption@setstyle|\marg{name}\\
-% |\caption@setstyle*|\marg{name}\par
-% Selecting a caption style means saving the additional
-% \meta{single-line-list-of-KV} (this will be done by |\caption@sls|),
-% resetting the caption options to the default ones (this will be done using
-% |\caption@setdefault|) and executing the \meta{list-of-KV} options
-% (this will be done using |\caption@esetup|).\par
-% The starred version will give no error message if the given style is not
-% defined.
+% \changes{v3.0f}{2005/06/01}{Starred variant added}
+%  |\caption@setstyle|\marg{name}\\
+%  |\caption@setstyle*|\marg{name}\par
+%  Selecting a caption style means saving the additional
+%  \meta{single-line-list-of-KV} (this will be done by |\caption@sls|),
+%  resetting the caption options to the default ones (this will be done using
+%  |\caption@setdefault|) and executing the \meta{list-of-KV} options
+%  (this will be done using |\caption@esetup|).\par
+%  The starred version will give no error message if the given style is not
+%  defined.
 %    \begin{macrocode}
 \newcommand\caption@setstyle{%
   \@ifstar{\caption@@setstyle\@gobble}{\caption@@setstyle\@firstofone}}
 \newcommand*\caption@@setstyle[2]{%
   \@ifundefined{caption@sty@#2}%
     {#1{\PackageError{caption}{Undefined caption style `#2'}{\caption@eh}}}%
-	{\expandafter\let\expandafter\caption@sls\csname caption@sls@#2\endcsname
+    {\expandafter\let\expandafter\caption@sls\csname caption@sls@#2\endcsname
      \caption@setdefault\caption@esetup{\csname caption@sty@#2\endcsname}}}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@setdefault}
-% This resets (nearly) all caption options to the default ones.
-% (Note that this does not touch the skips and the positioning!)
+%  This resets (nearly) all caption options to the default ones.
+%  \emph{Note that this does not touch the skips and the positioning!}
 %    \begin{macrocode}
 \newcommand\caption@setdefault{\captionsetup{%
-  format=default,labelformat=default,labelsep=default,justification=default,%
-  font=default,labelfont=default,textfont=default,%
-  margin=0pt,indention=0pt,parindent=0pt,hangindent=0pt,singlelinecheck}}
+  format=default,labelformat=default,labelsep=default,%
+  justification=default,font=default,labelfont=default,textfont=default,%
+  margin=0pt,indent=0pt,parindent=0pt,hangindent=0pt,%
+  singlelinecheck=1,strut=1}}
 %    \end{macrocode}
 % \end{macro}
 %
-% There is only one pre-defined style, called `default'. It's a perfect match
-% to the standard \LaTeX\ document classes: If the caption fits in one single
-% line, it is typeset centered.
+% \changes{v3.0d}{2005/02/12}{\opt{indent=0pt} added to caption style \opt{default}}
+% Currently there is only one pre-defined style, called `default'.
+% It's a perfect match to the behaviour of |\@makecaption| offered by the
+% standard \LaTeX\ document classes:
+% If the caption fits in one single line, it is typeset centered.
 %
 %    \begin{macrocode}
 \DeclareCaptionStyle{default}[indent=0pt,justification=centering]{}
@@ -1991,18 +2367,19 @@
 % \subsubsection*{Formats}
 %
 % \begin{macro}{\DeclareCaptionFormat}
-% |\DeclareCaptionFormat|\marg{name}\marg{code with \#1, \#2, and \#3}\\
-% |\DeclareCaptionFormat*|\marg{name}\marg{code with \#1, \#2, and \#3}\par
-% The starred form causes the code being typeset in vertical (instead of
-% horizontal) mode, but does not support the |indention=| option.
-% \changes{v3.0a}{17 Jan 04}{We pass through argument no.3 so extra spaces between the arguments do make any harm}
-% \changes{v3.0d}{9 Feb 05}{Starred form added}
-%    \begin{macrocode}
-\def\DeclareCaptionFormat{%
-  \@ifstar{\caption@declareformat\@gobble}{\caption@declareformat\@firstofone}}
+% \changes{v3.0a}{2004/01/17}{Pass through argument \#3 so extra spaces between arguments do make any harm}
+% \changes{v3.0d}{2005/02/09}{Starred variant added}
+%  |\DeclareCaptionFormat|\marg{name}\marg{code with \#1, \#2, and \#3}\\
+%  |\DeclareCaptionFormat*|\marg{name}\marg{code with \#1, \#2, and \#3}\par
+%  The starred form causes the code being typeset in vertical (instead of
+%  horizontal) mode, but does not support the |indention=| option.
+%    \begin{macrocode}
+\newcommand\DeclareCaptionFormat{%
+  \@ifstar{\caption@declareformat\@gobble}%
+          {\caption@declareformat\@firstofone}}
 \newcommand\caption@declareformat[3]{%
   \global\expandafter\let\csname caption@ifh@#2\endcsname#1%
-  \global\long\expandafter\def\csname caption@fmt@#2\endcsname##1##2##3{#3}}
+  \global\long\@namedef{caption@fmt@#2}##1##2##3{#3}}
 \@onlypreamble\DeclareCaptionFormat
 \@onlypreamble\caption@declareformat
 %    \end{macrocode}
@@ -2013,9 +2390,9 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@setformat}
-% |\caption@setformat|\marg{name}\par
-% Selecting a caption format simply means saving the code (in |\caption@fmt|)
-% and if the code should be used in horizontal or vertical mode (|\caption@ifh|).
+%  |\caption@setformat|\marg{name}\par
+%  Selecting a caption format simply means saving the code (in |\caption@fmt|)
+%  and if the code should be used in horizontal or vertical mode (|\caption@ifh|).
 %    \begin{macrocode}
 \newcommand*\caption@setformat[1]{%
   \@ifundefined{caption@fmt@#1}%
@@ -2025,14 +2402,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% There are two pre-defined formats, called `@normal' and `hang'.
-% \iffalse
-% (Note that `normal' is not documented and this name can be a subject of change
-% in future versions of this package!)
-% \fi
+% \changes{v3.0a}{2004/01/23}{Caption format \opt{default} renamed to \opt{normal}}
+% \changes{v3.0f}{2005/05/12}{Caption format \opt{normal} renamed to \opt{@normal}}
+% \changes{v3.0h}{2005/08/25}{Caption format \opt{@normal} renamed to \opt{plain} and documented}
+% There are two pre-defined formats, called `plain' and `hang'.
 %
 %    \begin{macrocode}
-\DeclareCaptionFormat{@normal}{#1#2#3\par}
+\DeclareCaptionFormat{plain}{#1#2#3\par}
 \DeclareCaptionFormat{hang}{%
   \@hangfrom{#1#2}%
   \advance\captionparindent\hangindent
@@ -2041,21 +2417,23 @@
   #3\par}
 %    \end{macrocode}
 %
-% `default' usually maps to `@normal'.
+% \changes{v3.0a}{2004/01/23}{Caption format \opt{default} linked to \opt{normal}}
+% \changes{v3.0e}{2005/04/28}{Bugfix 05-04-28: Missing \cs{caption@ifh@default} added}
+% `default' usually maps to `plain'.
 %
 %    \begin{macrocode}
-\def\caption@fmt@default{\caption@fmt@@normal}
-\def\caption@ifh@default{\caption@ifh@@normal}% bugfix v3.0e (05-04-28)
+\def\caption@fmt@default{\caption@fmt@plain}
+\def\caption@ifh@default{\caption@ifh@plain}
 %    \end{macrocode}
 %
 % \subsubsection*{Label formats}
 %
 % \begin{macro}{\DeclareCaptionLabelFormat}
-% |\DeclareCaptionLabelFormat|\marg{name}\marg{code with \#1 and \#2}
-% \changes{v3.0a}{17 Jan 04}{We pass through argument no.2 so extra spaces between the arguments do make any harm}
+% \changes{v3.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
+%  |\DeclareCaptionLabelFormat|\marg{name}\marg{code with \#1 and \#2}
 %    \begin{macrocode}
 \newcommand*\DeclareCaptionLabelFormat[2]{%
-  \global\expandafter\def\csname caption@lfmt@#1\endcsname##1##2{#2}}
+  \global\@namedef{caption@lfmt@#1}##1##2{#2}}
 \@onlypreamble\DeclareCaptionLabelFormat
 %    \end{macrocode}
 % \end{macro}
@@ -2065,8 +2443,8 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@setlabelformat}
-% |\caption@setlabelformat|\marg{name}\par
-% Selecting a caption label format simply means saving the code (in |\caption@lfmt|).
+%  |\caption@setlabelformat|\marg{name}\par
+%  Selecting a caption label format simply means saving the code (in |\caption@lfmt|).
 %    \begin{macrocode}
 \newcommand*\caption@setlabelformat[1]{%
   \@ifundefined{caption@lfmt@#1}%
@@ -2092,12 +2470,20 @@
 % \subsubsection*{Label separators}
 %
 % \begin{macro}{\DeclareCaptionLabelSeparator}
-% |\DeclareCaptionLabelSeparator|\marg{name}\marg{code}
-% \changes{v3.0a}{17 Jan 04}{We pass through argument no.2 so extra spaces between the arguments do make any harm}
-%    \begin{macrocode}
-\newcommand\DeclareCaptionLabelSeparator[2]{%
-  \global\long\@namedef{caption@lsep@#1}{#2}}
+% \changes{v3.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
+% \changes{v3.0h}{2005/08/25}{Starred variant added}
+%  |\DeclareCaptionLabelSeparator|\marg{name}\marg{code}\\
+%  |\DeclareCaptionLabelSeparator*|\marg{name}\marg{code}\par
+%  The starred form causes the label separator to be typeset \emph{without} using |\captionlabelfont|.
+%    \begin{macrocode}
+\newcommand\DeclareCaptionLabelSeparator{%
+  \@ifstar{\caption@declarelabelseparator\@gobble}%
+          {\caption@declarelabelseparator\@firstofone}}
+\newcommand\caption@declarelabelseparator[3]{%
+  \global\expandafter\let\csname caption@iflf@#2\endcsname#1%
+  \global\long\@namedef{caption@lsep@#2}{#3}}
 \@onlypreamble\DeclareCaptionLabelSeparator
+\@onlypreamble\caption@declarelabelseparator
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2107,38 +2493,45 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@setlabelseparator}
-% |\caption@setlabelseparator|\marg{name}\par
-% Selecting a caption label separator simply means saving the code (in |\caption@lsep|).
+%  |\caption@setlabelseparator|\marg{name}\par
+%  Selecting a caption label separator simply means saving the code (in |\caption@lsep|).
 %    \begin{macrocode}
 \newcommand*\caption@setlabelseparator[1]{%
   \@ifundefined{caption@lsep@#1}%
     {\PackageError{caption}{Undefined caption label separator `#1'}{\caption@eh}}%
-    {\expandafter\let\expandafter\caption@lsep\csname caption@lsep@#1\endcsname}}
+    {\expandafter\let\expandafter\caption@iflf\csname caption@iflf@#1\endcsname
+     \expandafter\let\expandafter\caption@lsep\csname caption@lsep@#1\endcsname}}
 %    \end{macrocode}
 % \end{macro}
 %
-% There are six pre-defined label separators, called `none', `colon', `period', `space', `quad', and `newline'.
+% \changes{v3.0f}{2005/06/11}{Bugfix 05-03-23: Caption label separator \opt{newline} implementation
+%                             changed from \cs{newline} to \cs{\textbackslash}}
+% \changes{v3.0h}{2005/08/24}{Caption label separator \opt{endash} added}
+% There are seven pre-defined label separators, called `none', `colon', `period', `space',
+% `quad', `newline', and `endash'.
 %
 %    \begin{macrocode}
 \DeclareCaptionLabelSeparator{none}{}
 \DeclareCaptionLabelSeparator{colon}{: }
 \DeclareCaptionLabelSeparator{period}{. }
 \DeclareCaptionLabelSeparator{space}{ }
-\DeclareCaptionLabelSeparator{quad}{\quad}
-\DeclareCaptionLabelSeparator{newline}{\\}% 05-03-23 (v3.0f)
+\DeclareCaptionLabelSeparator*{quad}{\quad}
+\DeclareCaptionLabelSeparator*{newline}{\\}
+\DeclareCaptionLabelSeparator*{endash}{\space\textendash\space}
 %    \end{macrocode}
 %
 % `default' usually maps to `colon'.
 %
 %    \begin{macrocode}
 \def\caption@lsep@default{\caption@lsep@colon}
+\def\caption@iflf@default{\caption@iflf@colon}
 %    \end{macrocode}
 %
 % \subsubsection*{Justifications}
 %
 % \begin{macro}{\DeclareCaptionJustification}
-% |\DeclareCaptionJustification|\marg{name}\marg{code}
-% \changes{v3.0a}{17 Jan 04}{We pass through argument no.2 so extra spaces between the arguments do make any harm}
+% \changes{v3.0a}{2004/01/17}{Pass through argument \#2 so extra spaces between arguments do make any harm}
+%  |\DeclareCaptionJustification|\marg{name}\marg{code}
 %    \begin{macrocode}
 \newcommand*\DeclareCaptionJustification[2]{%
   \global\@namedef{caption@hj@#1}{#2}}
@@ -2152,8 +2545,8 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@setjustification}
-% |\caption@setjustification|\marg{name}\par
-% Selecting a caption justification simply means saving the code (in |\caption@hj|).
+%  |\caption@setjustification|\marg{name}\par
+%  Selecting a caption justification simply means saving the code (in |\caption@hj|).
 %    \begin{macrocode}
 \newcommand*\caption@setjustification[1]{%
   \@ifundefined{caption@hj@#1}%
@@ -2182,8 +2575,8 @@
 %
 % \begin{macro}{\caption@centerfirst}
 % \begin{macro}{\caption@centerlast}
-% Please blame Frank Mittelbach for |\caption@centerfirst| and
-% Anne Br\"uggemann-Klein for |\caption@centerlast| |:-)|
+%  Please blame Frank Mittelbach for |\caption@centerfirst| and
+%  Anne Br\"uggemann-Klein\cite{Anne} for |\caption@centerlast| |:-)|
 %    \begin{macrocode}
 \newcommand\caption@centerfirst{%
   \edef\caption@normaladjust{%
@@ -2203,6 +2596,7 @@
 % \end{macro}
 % \end{macro}
 %
+% \changes{v3.0b}{2004/05/16}{Improved \package{ragged2e} package support}
 % We also support the upper-case commands offered by the \package{ragged2e}
 % package.
 % Note that these just map to their lower-case variants if the
@@ -2217,13 +2611,13 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@ragged}
-% |\caption@ragged| will be basically defined as\par
-% |\AtBeginDocument{\IfFileExists{ragged2e.sty}%|\\
-% |  {\RequirePackage{ragged2e}\let\caption@ragged\@firstoftwo}%|\\
-% |  {\let\caption@ragged\@secondoftwo}}|\par
-% but with a warning if the ragged2e package is not avail.
-% (This warning will by typeout only ones per option, that's why we need the
-% |caption\string#1| stuff.)
+%  |\caption@ragged| will be basically defined as\par
+%  |\AtBeginDocument{\IfFileExists{ragged2e.sty}%|\\
+%  |  {\RequirePackage{ragged2e}\let\caption@ragged\@firstoftwo}%|\\
+%  |  {\let\caption@ragged\@secondoftwo}}|\par
+%  but with an additional warning if the ragged2e package is not avail.
+%  (This warning will be typeout only one time per option, that's why
+%  we need the |caption\string#1| stuff.)
 %    \begin{macrocode}
 \newcommand*\caption@ragged[2]{%
   \@ifundefined{caption\string#1}{%
@@ -2242,8 +2636,8 @@
 % \subsubsection*{Fonts}
 %
 % \begin{macro}{\DeclareCaptionFont}
-% |\DeclareCaptionFont|\marg{name}\marg{code}
-% \changes{v3.0a}{22 Jan 04}{More-than-one token arguments are allowed now}
+% \changes{v3.0a}{2004/01/22}{Bugfix: Multi token arguments are allowed now}
+%  |\DeclareCaptionFont|\marg{name}\marg{code}
 %    \begin{macrocode}
 \newcommand\DeclareCaptionFont[2]{%
   \define@key{caption@fnt}{#1}[]{\g@addto@macro\caption@tempa{#2}}}
@@ -2258,26 +2652,30 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@setfont}
-% |\caption@setfont|\marg{command}\marg{keyval-list of names}\par
-% Selecting a caption font means saving all the code snippets (in |#1|).
-% Because we use |\setkeys| recursive here we need to put this into an extra
-% group and collect all the code snippets in |\caption@tempa| first.
+%  |\caption@setfont|\marg{name}\marg{keyval-list of names}\par
+%  Selecting a caption font means saving all the code snippets
+%  (in |\caption#1|).
+%  Because we use |\setkeys| recursive here we need to do this inside an
+%  extra group and collect all the code snippets in |\caption@tempa| first.
 %    \begin{macrocode}
 \newcommand*\caption@setfont[2]{%
   \let\caption@tempa\@empty
   \begingroup
-    \setkeys{caption@fnt}{#2}%
+%   \define@key{caption@fnt}{default}[]{%
+%     \global\expandafter\let\expandafter\caption@tempa
+%       \csname caption#1@default\endcsname}%
+    \caption@setkeys{caption@fnt}{#2}%
   \endgroup
   \expandafter\let\csname caption#1\endcsname\caption@tempa}
 %    \end{macrocode}
 % \end{macro}
 %
-% These are the pre-defined font code snippets.
-%
 %    \begin{macrocode}
 \DeclareCaptionFont{default}{}
 %    \end{macrocode}
 %
+% These are the pre-defined font code snippets.
+%
 %    \begin{macrocode}
 \DeclareCaptionFont{scriptsize}{\scriptsize}
 \DeclareCaptionFont{footnotesize}{\footnotesize}
@@ -2300,24 +2698,27 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\captionsize}
-% The old versions $1.x$ of the \package{caption} package offered this
-% command to setup the font size used for captions. We still do
-% so old documents will work fine.
-% \changes{v3.0c}{16 Jul 04}{Use \cs{providecommand} instead of \cs{newcommand} in respect of the memoir class}
+% \changes{v3.0a}{2004/01/23}{Implementation changed from \cs{captionfont} to \cs{@empty}}
+% \changes{v3.0c}{2004/07/16}{Use \cs{providecommand} instead of \cs{newcommand} in respect of the memoir class}
+%  The old versions \version{1.x} of the \package{caption} package offered this
+%  command to setup the font size used for captions. We still do
+%  so old documents will work fine.
 %    \begin{macrocode}
 \providecommand\captionsize{}
 %    \end{macrocode}
 % \end{macro}
+%
+% \changes{v3.0a}{2004/01/23}{Option \opt{size=} now sets \cs{captionsize} instead of \cs{captionfont}}
 %    \begin{macrocode}
-\DeclareCaptionOption{size}{\caption@setfont{size}{#1}}% changed v3.0a
+\DeclareCaptionOption{size}{\caption@setfont{size}{#1}}
 %    \end{macrocode}
 %
 % \subsubsection*{Vertical spaces before and after captions}
 %
 % \begin{macro}{\abovecaptionskip}
 % \begin{macro}{\belowcaptionskip}
-% Usually these skips are defined within the document class, but some
-% document classes don't do so.
+%  Usually these skips are defined within the document class, but some
+%  document classes don't do so.
 %    \begin{macrocode}
 \@ifundefined{abovecaptionskip}{%
   \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
@@ -2327,20 +2728,23 @@
 % \end{macro}
 % \end{macro}
 %
+% \changes{v3.0d}{2005/02/12}{Option \opt{skip=} added}
 %    \begin{macrocode}
 \DeclareCaptionOption{aboveskip}{\setlength\abovecaptionskip{#1}}
 \DeclareCaptionOption{belowskip}{\setlength\belowcaptionskip{#1}}
-\DeclareCaptionOption{skip}{\setlength\abovecaptionskip{#1}}% new 3.0d
+\DeclareCaptionOption{skip}{\setlength\abovecaptionskip{#1}}
 %    \end{macrocode}
 %
 % \subsubsection*{Positioning}
 %
 % These macros handle the right position of the caption.
 % Note that the position is actually \emph{not} controlled by the
-% \package{caption} kernel options, but by the user (or the package) instead.
-% The user can put the |\caption| command where ever he likes! So this stuff
-% is only to give us a hint where to put the right skips, the user usually has
-% to take care for himself that this hint actually matches the right position.
+% \package{caption} kernel options, but by the user (or a specific package
+% like the \package{float} package) instead.
+% The user can put the |\caption| command wherever he likes! So this stuff
+% is only to give us a \emph{hint} where to put the right skips, the user
+% usually has to take care for himself that this hint actually matches the
+% right position.
 % The user can also try out the experimental setting |position=auto| which
 % means that the \package{caption} package should try to guess the actual
 % position of the caption for himself. (But in many cases, for example in
@@ -2352,12 +2756,14 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@setposition}
-% Selecting the caption position means that we put |\caption@position| to
-% the right value. Please do \emph{not} use the internal macro
-% |\caption@position| in your own package or document, but use the wrapper
-% macro |\caption@iftop| instead.
-% \changes{v3.0a}{22 Jan 04}{Now `t', `above', `b', `below', and `a' are allowed, too}
-% \changes{v3.0d}{10 Aug 04}{\cs{caption@defaultpos} added}
+% \changes{v3.0a}{2004/01/22}{Now the positions \opt{t}, \opt{above}, \opt{b},
+%                             \opt{below}, and \opt{a} are allowed, too}
+% \changes{v3.0d}{2004/08/10}{Usage of \cs{caption@defaultpos} added}
+%  |\caption@setposition|\marg{position}\par
+%  Selecting the caption position means that we put |\caption@position| to
+%  the right value. \emph{Please do \textbf{not} use the internal macro
+%  \cs{caption@position} in your own package or document, but use the wrapper
+%  macro \cs{caption@iftop} instead.}
 %    \begin{macrocode}
 \newcommand*\caption@setposition[1]{%
   \caption@ifinlist{#1}{d,default}{%
@@ -2375,9 +2781,10 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@defaultpos}
-% The default `position' is `bottom', this means that the (larger) skip will
-% be typeset above the caption. This correspondents to the |\@makecaption|
-% implementation in the standard \LaTeX\ document classes.
+%  The default `position' is usually `bottom', this means that the (larger)
+%  skip will be typeset above the caption.
+%  This correspondents to the |\@makecaption| implementation in the standard
+%  \LaTeX\ document classes.
 %    \begin{macrocode}
 %\caption@setdefaultpos{b}% default = bottom
 \let\caption@defaultpos\@secondoftwo
@@ -2385,10 +2792,12 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@iftop}
-% |\caption@iftop|\marg{true-code}\marg{false-code}\par
-% (If |\caption@position| is set to `auto' we assume a `bottom' position.)
+% \changes{v3.0a}{2004/01/23}{Split into \cs{caption@iftop} \& \cs{caption@fixposition}}
+% \changes{v3.0d}{2005/02/12}{Adapted to \cs{caption@defaultpos}}
+%  |\caption@iftop|\marg{true-code}\marg{false-code}\par
+%  (If the |position=| is set to |auto| we assume a |bottom| position.)
 %    \begin{macrocode}
-\newcommand\caption@iftop{% bugfixed v3.0a, improved v3.0d
+\newcommand\caption@iftop{%
   \ifx\caption@position\@undefined
     \expandafter\@secondoftwo
   \else
@@ -2398,9 +2807,11 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@fixposition}
-% This macro checks if the `position' is set to `auto'.
-% If yes, |\caption@autoposition| will be called to
-% set |\caption@position| to a proper value we can actually use.
+% \changes{v3.0b}{2004/05/16}{Split into \cs{caption@fixposition} & \cs{caption@autoposition}}
+%  |\caption@fixposition|\par
+%  This macro checks if the `position' is set to `auto'.
+%  If yes, |\caption@autoposition| will be called to
+%  set |\caption@position| to a proper value we can actually use.
 %    \begin{macrocode}
 \newcommand\caption@fixposition{%
   \ifx\caption@position\@undefined
@@ -2410,15 +2821,14 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@autoposition}
-% We guess the actual position of the caption by checking |\prevdepth|.
+% \changes{v3.0a}{2004/01/23}{\cs{ifvmode} added}
+%  |\caption@autoposition|\par
+%  We guess the actual position of the caption by checking |\prevdepth|.
 %    \begin{macrocode}
-\newcommand\caption@autoposition{% bugfixed v3.0a
+\newcommand\caption@autoposition{%
   \ifvmode
-    \ifodd\caption@debug\relax
-      \edef\caption@tempa{\the\prevdepth}%
-      \PackageInfo{caption}{\protect\prevdepth=\caption@tempa}%
-    \fi
-%
+%<+debug>    \edef\caption@tempa{\the\prevdepth}%
+%<+debug>    \PackageInfo{caption}{\protect\prevdepth=\caption@tempa}%
 %   \caption@setposition{\ifdim\prevdepth>-\p@ b\else t\fi}%
     \ifdim\prevdepth>-\p@
       \let\caption@position\@secondoftwo
@@ -2426,10 +2836,7 @@
       \let\caption@position\@firstoftwo
     \fi
   \else
-    \ifodd\caption@debug\relax
-      \PackageInfo{caption}{no \protect\prevdepth}%
-    \fi
-%
+%<+debug>    \PackageInfo{caption}{no \protect\prevdepth}%
 %   \caption@setposition{b}%
     \let\caption@position\@secondoftwo
   \fi}
@@ -2440,9 +2847,9 @@
 %
 % \begin{macro}{\AtBeginCaption}
 % \begin{macro}{\AtEndCaption}
-% |\AtBeginDocument| \marg{code}\\
-% |\AtEndDocument| \marg{code}\par
-% These hooks can be used analogous to |\AtBeginDocument| and |\AtEndDocument|.
+%  |\AtBeginCaption| \marg{code}\\
+%  |\AtEndCaption| \marg{code}\par
+%  These hooks can be used analogous to |\AtBeginDocument| and |\AtEndDocument|.
 %    \begin{macrocode}
 \newcommand\caption@beginhook{}
 \newcommand\caption@endhook{}
@@ -2454,31 +2861,31 @@
 %
 % \subsubsection*{Miscellaneous options}
 %
+% \changes{v3.0b}{2004/05/16}{Option \opt{listof=} added}
+% \changes{v3.0d}{2005/02/12}{Option \opt{strut=} added}
 %    \begin{macrocode}
-\DeclareCaptionOption{parskip}[5pt]{\AtBeginCaption{\setlength\parskip{#1}}}
+\DeclareCaptionOption{listof}{\caption@setbool{lof}{#1}}
+\DeclareCaptionOption{singlelinecheck}{\caption@setbool{slc}{#1}}
+\DeclareCaptionOption{strut}{\caption@setbool{strut}{#1}}
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-\DeclareCaptionOption{listof}{\caption@setbool{lof}{#1}}% new v3.0b
-\DeclareCaptionOption{singlelinecheck}[1]{\caption@setbool{slc}{#1}}
-\DeclareCaptionOption{strut}{\caption@setbool{strut}{#1}}% new v3.0d
-%    \end{macrocode}
+% \subsubsection*{Debug options}
+% {\small Please note that these options are usually not available.}
 %
 %    \begin{macrocode}
-\DeclareCaptionOption{debug}{\def\caption@debug{#1}}
+%<+debug>\DeclareCaptionOption{showposition}{\caption@setbool{showpos}{#1}}
+%<+debug>\captionsetup{showposition=0}
 %    \end{macrocode}
 %
 % \subsubsection*{Initialization of parameters}
 %
 %    \begin{macrocode}
-\captionsetup{style=default,position=default,listof=1,strut=1,debug=0}
+\captionsetup{style=default,position=default,listof=1}
 %    \end{macrocode}
 %
 % \begin{macro}{\ifcaption@star}
 % If the starred form of |\caption| is used, this will be set to |true|.
-% (Note: This will be replaced by |\caption@iflabel| in future versions
-% of the caption package, so I can use |\caption@setbool| so set this
-% value.)
+% (It will be reset to |false| at the end of |\caption@@make|.)
 %    \begin{macrocode}
 \newif\ifcaption@star
 %    \end{macrocode}
@@ -2487,7 +2894,7 @@
 % \subsubsection*{Typesetting the caption}
 %
 % \begin{macro}{\caption@make}
-% |\caption@make|\marg{float name}\marg{ref.\ number}\marg{text}
+%  |\caption@make|\marg{float name}\marg{ref.\ number}\marg{text}
 %    \begin{macrocode}
 \newcommand\caption@make[2]{%
   \caption@@make{\caption@lfmt{#1}{#2}}}
@@ -2495,43 +2902,46 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@@make}
-% |\caption@@make|\marg{caption label}\marg{caption text}
+% \changes{v3.0b}{2004/05/16}{Bugfix 04-05-05: \cs{ifdim}\cs{captionindent=}\cs{z@} added}
+% \changes{v3.0d}{2005/02/12}{Bugfix 04-10-26: Use \cs{@tempdima} instead of \cs{captionmargin} resp. \cs{captionwidth};
+%                             check for \cs{z@} added}
+% \changes{v3.0d}{2005/02/12}{Bugfix: \cs{hskip}\cs{captionmargin} to the end of caption added}
+% \changes{v3.0d}{2005/02/12}{Bugfix: \cs{strut} moved from here to \cs{caption@@@make}}
+% \changes{v3.0d}{2005/02/12}{Single-line-check moved up so it can affect margins now}
+% \changes{v3.0d}{2005/02/09}{Improvement: \cs{caption@ifh} added}
+% \changes{v3.0d}{2005/02/09}{Bugfix: \cs{leavevmode} added}
+% \changes{v3.0h}{2005/08/24}{Uses \cs{sbox} instead of \cs{setbox} in single-line-check}
+% \changes{v3.0i}{2005/12/04}{Uses \cs{caption@slc}}
+% \changes{v3.0i}{2006/01/11}{Bugfix: \cs{caption@calcmargin} inside single-line-check replaced by \cs{relax}}
+% \changes{v3.0i}{2006/01/11}{Bugfix: \cs{caption@startbox} will always be typeset in horizontal mode}
+%  |\caption@@make|\marg{caption label}\marg{caption text}
 %    \begin{macrocode}
 \newcommand\caption@@make[2]{%
-% \begingroup
+  \begingroup
   \caption@beginhook
   \caption@calcmargin
 %    \end{macrocode}
 %
-% Special single-line treatment
-% (Improvement v3.0d: moved to here)
+% Special single-line treatment (option |singlelinecheck=|)
 %
 %    \begin{macrocode}
-  \caption@ifslc{%
-    \ifx\caption@sls\@empty\else
-      \caption@startslc
-      \setbox\@tempboxa\hbox{\caption@@@make{#1}{#2}}%
-      \ifdim\wd\@tempboxa >\captionwidth
-        \caption@endslc
-      \else
-        \caption@endslc
-        \caption@esetup\caption@sls
-        \caption@calcmargin
-      \fi
-    \fi}{}%
+  \caption@ifslc{\ifx\caption@sls\@empty\else
+    \caption@slc{#1}{#2}\captionwidth\relax
+  \fi}{}%
 %    \end{macrocode}
 %
-% Bugfix v3.0d: Use |\@tempdima| instead of |\captionmargin|, |\ifdim added| (04-10-26)
+% Typeset the left margin (option |margin=|)
 %
 %    \begin{macrocode}
   \@tempdima\captionmargin
   \caption@ifh{\advance\@tempdima by \captionindent}%
-  \ifdim\@tempdima=\z@\else
-    \hskip\@tempdima
-  \fi
+  \hskip\@tempdima
 %    \end{macrocode}
 %
-% Bugfix v3.0d: Use |\@tempdima| instead of |\captionwidth| (04-10-26)
+% We actually use a |\vbox| of width |\captionwidth - \captionindent|
+% to typeset the caption
+% (Note: |\captionindent| is \emph{not} supported if the caption format
+% was defined with |\DeclareCaptionFormat*|.)
 %
 %    \begin{macrocode}
   \@tempdima\captionwidth
@@ -2539,20 +2949,18 @@
   \caption@startbox\@tempdima
 %    \end{macrocode}
 %
-% Bugfix v3.0b: |\ifdim| added (04-05-05)\\
-% Bugfix v3.0d: |\leavevmode| added (05/02/09)\\
-% Improvement v3.0d: |\caption@ifh| (05/02/09)
+% Typeset the indention (option |indention=|)
 %
 %    \begin{macrocode}
     \caption@ifh{%
-      \ifdim\captionindent=\z@
-        \leavevmode
-      \else
-        \hskip-\captionindent
-      \fi}%
+%     \ifdim\captionindent=\z@
+%       \leavevmode
+%     \else
+        \hskip-\captionindent}%
+%     \fi}%
 %    \end{macrocode}
 %
-% Bugfix v3.0d: |\strut| moved from here to |\caption@@@make|
+% Typeset the caption itself
 %
 %    \begin{macrocode}
     \caption@@@make{#1}{#2}%
@@ -2562,53 +2970,102 @@
   \caption@endbox
 %    \end{macrocode}
 %
-% Bugfix v3.0d: This |\hskip| added
+% Typeset the right margin (option |margin=|)
 %
 %    \begin{macrocode}
-  \ifdim\captionmargin=\z@\else
-    \hskip\captionmargin
-  \fi
+  \@tempdima\captionmargin
+  \advance\@tempdima by \captionmarginx
+  \hskip\@tempdima
 %    \end{macrocode}
 %
 %    \begin{macrocode}
   \caption@endhook
-% \endgroup
+  \endgroup
+%    \end{macrocode}
+%
+%    \begin{macrocode}
   \global\caption@starfalse}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@calcmargin}
-% Calculate |\captionmargin| \& |\captionwidth|, so both contain valid values.
+%  Calculate |\captionmargin| \& |\captionwidth|, so both contain valid
+%  values.
+% \changes{v3.0h}{2005/10/24}{Internal: \cs{ifcaption@width} replaced by \cs{ifdim}\cs{captionwidth=}\cs{z@}}
+% \changes{v3.0i}{2006/01/12}{Improvement: Takes care of list environment now}
 %    \begin{macrocode}
 \newcommand\caption@calcmargin{%
-  \ifcaption@width
-    \captionmargin\hsize
+%    \end{macrocode}
+%  \emph{Note:} Inside a |list| environment |\linewidth| do not contain
+%  the proper value, because |\@caption| calls |\@parboxrestore| which
+%  resets |\linewidth| to |\hsize|. Therefore we have to calculate the
+%  proper line width on our own in this case.
+%    \begin{macrocode}
+  \@tempdima\hsize
+  \ifnum\@listdepth>0\relax
+    \advance\@tempdima by -\leftmargin
+    \advance\@tempdima by -\rightmargin
+  \fi
+%    \end{macrocode}
+%    \begin{macrocode}
+  \ifdim\captionwidth=\z@
+    \captionwidth\@tempdima
+    \advance\captionwidth by -2\captionmargin
+    \advance\captionwidth by -\captionmarginx
+  \else
+    \captionmargin\@tempdima
     \advance\captionmargin by -\captionwidth
     \divide\captionmargin by 2
-  \else
-    \captionwidth\hsize
-    \advance\captionwidth by -2\captionmargin
+    \captionmarginx\z@
   \fi
+%    \end{macrocode}
+%    \begin{macrocode}
+%<+debug>  \PackageInfo{caption}{%
+%<+debug>    \protect\hsize=\the\hsize,
+%<+debug>    \protect\margin=\the\captionmargin,
+%<+debug>    \protect\marginx=\the\captionmarginx,
+%<+debug>    \protect\width=\the\captionwidth}%
+%    \end{macrocode}
+%    \begin{macrocode}
+}
+%    \end{macrocode}
+% \end{macro}
 %
-  \ifodd\caption@debug\relax
-    \PackageInfo{caption}{\protect\hsize=\the\hsize,
-      \protect\margin=\the\captionmargin,
-      \protect\width=\the\captionwidth}%
+% \begin{macro}{\caption@slc}
+%  This one does the single-line-check.
+%    \begin{macrocode}
+\newcommand\caption@slc[4]{%
+  \caption@startslc
+  \sbox\@tempboxa{\caption@@@make{#1}{#2}}%
+  \ifdim\wd\@tempboxa >#3%
+    \caption@endslc
+  \else
+    \caption@endslc
+    \caption@esetup\caption@sls
+    #4%
   \fi}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@startslc}
-% Re-define anything which would disturb the single line check\par
-% Bugfix v3.0b: re-definition of |\label| \& |\@footnotetext| was missing here\\
-% Improvement v3.0b: re-define |\stepcounter| instead of |\footnote(mark)|\\
-% Improvement v3.0d: |\let\caption@hj\relax| added
+% \changes{v3.0b}{2004/05/16}{Bugfix: Redefinition of \cs{label} \& \cs{@footnotetext} added}
+% \changes{v3.0b}{2004/05/16}{Redefine \cs{stepcounter} instead of \cs{footnote(mark)}}
+% \changes{v3.0d}{2005/02/12}{\cs{let}\cs{caption@hj}\cs{relax} added}
+% \changes{v3.0h}{2005/07/09}{Support of \package{endnotes} package added}
+%  Re-define anything which would disturb the single-line-check.
 %    \begin{macrocode}
 \newcommand\caption@startslc{%
   \begingroup
-  \let\label\@gobble\let\@footnotetext\@gobble
+  \let\label\@gobble
+  \let\@footnotetext\@gobble\let\@endnotetext\@gobble
   \def\stepcounter##1{\advance\csname c@##1\endcsname\@ne\relax}%
   \let\caption@hj\relax}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@endslc}
+% This ends the single-line-check.
+%    \begin{macrocode}
 \newcommand\caption@endslc{%
   \endgroup}
 %    \end{macrocode}
@@ -2616,7 +3073,7 @@
 %
 % \begin{macro}{\caption@startbox}
 % \begin{macro}{\caption@endbox}
-% These macros start and end the box which surrounds the caption paragraph.
+%  These macros start and end the box which surrounds the caption paragraph.
 %    \begin{macrocode}
 \newcommand*\caption@startbox[1]{\vbox\bgroup\hsize#1}%
 %\newcommand*\caption@startbox[1]{\vbox\bgroup\setlength\hsize{#1}\@parboxrestore}%
@@ -2627,18 +3084,37 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@@@make}
-% |\caption@@@make|\marg{caption label}\marg{caption text}\par
-% This one finally typesets the caption paragraph, without margin and indention.
+% \changes{v3.0b}{2004/05/16}{Bugfix 04-05-06: \cs{allowhyphens} added}
+% \changes{v3.0d}{2005/02/12}{Bugfix 04-12-16: Use some kind of \cs{@startstrut}\cs{strutbox} instead of \cs{strut}}
+% \changes{v3.0d}{2005/02/12}{Bugfix 05-01-23: \cs{@finalstrut}\cs{strutbox} added}
+% \changes{v3.0e}{2005/05/05}{Use \cs{caption@ifempty}; \cs{let}\cs{caption@ifstrut}\cs{@secondoftwo} added}
+% \changes{v3.0e}{2005/05/05}{Bugfix: Handling of \cs{ifcaption@star} changed}
+% \changes{v3.0h}{2005/08/24}{Check for empty label added}
+% \changes{v3.0h}{2005/08/25}{\cs{caption@iflf} added}
+%  |\caption@@@make|\marg{caption label}\marg{caption text}\par
+%  This one finally typesets the caption paragraph, without margin and indention.
 %    \begin{macrocode}
 \newcommand\caption@@@make[2]{%
 %    \end{macrocode}
 %
-% Empty text? Then use no caption label separator.
+% If the label is empty, we use no caption label separator.
+%
+%    \begin{macrocode}
+  \sbox\@tempboxa{#1}%
+  \ifdim\wd\@tempboxa=\z@
+    \let\caption@lsep\relax
+  \fi
+%    \end{macrocode}
+%
+% If the text is empty, we use no caption label separator, too.\par
+% \emph{Note:} Unfortunately this only works under certain circumstances.
+% Therefore an additional check inside |\@caption| will be introduced
+% in the upcoming version \version{3.1} of the caption package.
 %
 %    \begin{macrocode}
-  \caption@ifempty{#2}{% changed v3.0e
+  \caption@ifempty{#2}{%
     \let\caption@lsep\relax
-    \let\caption@ifstrut\@secondoftwo % added v3.0e
+%   \let\caption@ifstrut\@secondoftwo
   }%
 %    \end{macrocode}
 %
@@ -2646,42 +3122,31 @@
 % to typeset the paragraph.
 %
 %    \begin{macrocode}
-  \def\caption@@par{%
-    \parindent\captionparindent\hangindent\captionhangindent}%
   \@setpar{\@@par\caption@@par}\caption@@par
 %    \end{macrocode}
 %
 % Finally the caption will be typeset.
 %
 %    \begin{macrocode}
-  \caption@hj\captionsize\captionfont
-%    \end{macrocode}
-% Bugfix v3.0e: Handling of |\ifcaption@star| changed
-%    \begin{macrocode}
-  \caption@fmt{\ifcaption@star\else{\captionlabelfont#1}\fi}%
-              {\ifcaption@star\else{\captionlabelfont\caption@lsep}\fi}%
-              {{\captiontextfont
-%    \end{macrocode}
-% Bugfix v3.0d: Use some kind of |\@startstrut\strutbox| instead of |\strut| (04-12-16)
-%    \begin{macrocode}
-                \caption@ifstrut{\vrule\@height\ht\strutbox\@width\z@}{}%
-%    \end{macrocode}
-% Bugfix v3.0b: |\allowhyphens| added (04-05-06)
-%    \begin{macrocode}
-                \nobreak\hskip\z@skip
-                #2%
-%    \end{macrocode}
-% Bugfix v3.0d: |\@finalstrut\strutbox| added (05-01-23)
-%    \begin{macrocode}
-%               \caption@ifstrut{\vrule\@height\z@\@depth\dp\strutbox\@width\z@}{}%
-                \caption@ifstrut{\@finalstrut\strutbox}{}%
-                \par}}}
+  \caption@hj\captionsize\captionfont\caption@fmt
+    {\ifcaption@star\else{\captionlabelfont#1}\fi}%
+    {\ifcaption@star\else{\caption@iflf\captionlabelfont\caption@lsep}\fi}%
+    {{\captiontextfont
+      \caption@ifstrut{\vrule\@height\ht\strutbox\@width\z@}{}%
+      \nobreak\hskip\z@skip
+      #2%
+%     \caption@ifstrut{\vrule\@height\z@\@depth\dp\strutbox\@width\z@}{}%
+      \caption@ifstrut{\@finalstrut\strutbox}{}%
+      \par}}}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@ifempty}
-% |\caption@ifempty|\marg{text}\marg{if-clause}\\
-% (new v3.0e, 05/05/05)
+% \changes{v3.0e}{2005/05/05}{This macro added}
+%  |\caption@ifempty|\marg{text}\marg{if-clause}\par
+%  This one tests if the \meta{text} is actually empty.\par
+%  \emph{Note:} This will be done without expanding the text, therefore this
+%  is far away from being bullet-proof.
 %    \begin{macrocode}
 \newcommand\caption@ifempty[1]{%
   \def\caption@tempa{#1}%
@@ -2697,10 +3162,23 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\caption@@par}
+% \changes{v3.0h}{2005/08/22}{Made this definition global}
+%  |\caption@@par|\par
+%  This command will be executed with every |\par| inside the caption.
+%    \begin{macrocode}
+\newcommand*\caption@@par{%
+  \parindent\captionparindent\hangindent\captionhangindent}%
+%    \end{macrocode}
+% \end{macro}
+%
 % \iffalse
 %</kernel>
 % \fi
 %
+% \iffalse
+% --------------------------------------------------------------------------- %
+% \fi
 %
 % \subsection{Main package}
 % \iffalse
@@ -2711,41 +3189,17 @@
 %
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
-\ProvidesPackage{caption}[2005/06/28 v3.0g Customising captions (AS)]
+\ProvidesPackage{caption}[2006/03/21 v3.0j Customising captions (AR)]
+%<+debug>\PackageWarning{caption}{DEBUG VERSION}
 %    \end{macrocode}
 %
 % \subsubsection*{Loading the caption kernel}
 %
 %    \begin{macrocode}
-\RequirePackage{caption3}
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-\DeclareCaptionOption{type}{\def\@captype{#1}}% new v3.0d
-%    \end{macrocode}
-%
-% \subsubsection*{Float names}
-%
-% \begin{macro}{\caption@floatname}
-% |\caption@floatname|\marg{type}\par
-% Usually all float names (which partly build the caption label)
-% follow the same naming convention. But some packages (for example
-% the \package{float} package) do not, so we use this wrapper macro which
-% can be extended later on.
-%    \begin{macrocode}
-\newcommand*\caption@floatname[1]{\@nameuse{#1name}}
-%    \end{macrocode}
-% \end{macro}
-%
-% \subsubsection*{Support for |figure| and |table|}
-%
-% \changes{v3.0a}{9 Jan 04}{Options `figureposition' and `tableposition' added}
-%    \begin{macrocode}
-\DeclareCaptionOption*{figureposition}{\captionsetup[figure]{position=#1}}%  new v3.0a
-\DeclareCaptionOption*{tableposition}{\captionsetup[table]{position=#1}}%    new v3.0a
+\RequirePackage{caption3}[2006/01/12] % needs v3.0i or newer
 %    \end{macrocode}
 %
-% \subsubsection*{Configuration files}
+% \subsubsection*{Option for configuration files}
 %
 %    \begin{macrocode}
 \DeclareCaptionOption{config}[caption]{%
@@ -2755,7 +3209,15 @@
                                file #1.cfg not found}}}
 %    \end{macrocode}
 %
-% \subsubsection*{Compatibility options (caption v$1.x$)}
+% \subsubsection*{Options for |figure| and |table|}
+%
+% \changes{v3.0a}{2004/01/09}{Options \opt{figureposition} and \opt{tableposition} added}
+%    \begin{macrocode}
+\DeclareCaptionOption*{figureposition}{\captionsetup[figure]{position=#1}}
+\DeclareCaptionOption*{tableposition}{\captionsetup[table]{position=#1}}
+%    \end{macrocode}
+%
+% \subsubsection*{caption \version{1.x} compatibility options}
 %
 %    \begin{macrocode}
 \DeclareCaptionOption*{normal}[]{\caption@setformat{normal}}
@@ -2796,92 +3258,218 @@
 \DeclareCaptionOption*{ruled}[]{\caption@setbool{ruled}{1}}
 %    \end{macrocode}
 %
-% \subsubsection*{Generic package support}
+% \subsubsection*{Some caption2 \version{2.x} compatibility options}
+% \changes{v3.0h}{2005/07/08}{caption2 \version{2.x} compatibility options added}
 %
-% \begin{macro}{\DeclareCaptionPackage}
-% Each single package support can be switched on or off by using the
-% appropriate option. By default all of them are enabled.
 %    \begin{macrocode}
-\newcommand*\DeclareCaptionPackage[1]{%
-  \caption@setbool{pkt@#1}{1}%
-  \DeclareCaptionOption*{#1}{\caption@setbool{pkt@#1}{##1}}}
-\AtEndOfPackage{\let\DeclareCaptionPackage\@undefined}
+\DeclareCaptionOption*{flushleft}[]{\caption@setjustification{raggedright}}
+\DeclareCaptionOption*{flushright}[]{\caption@setjustification{raggedleft}}
+\DeclareCaptionOption*{oneline}[]{\caption@setbool{slc}{1}}
+\DeclareCaptionOption*{ignoreLTcapwidth}[]{}
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\caption@ifpackage}
-% |\caption@ifpackage|\marg{package name}\marg{package macro}\marg{package code}
+% \subsubsection*{Some \KOMAScript\ compatibility stuff}
+% \changes{v3.0h}{2005/08/22}{\KOMAScript\ compatibility options added}
+% \changes{v3.0i}{2005/11/17}{\KOMAScript\ compatibility commands added}
+%
 %    \begin{macrocode}
-\newcommand\caption@ifpackage[3]{%
-  \caption@ifbool{pkt@#1}{%
-    \@ifundefined{#2}%
-      {\let\next\AtBeginDocument}%
-      {\let\next\@firstofone}%
-  }{%
-    \let\next\@gobble
-  }%
+\@ifundefined{scr@caption}{}{%
+%    \end{macrocode}
 %
-  \ifodd\caption@debug\relax
-    \edef\caption@tempa{%
-      \caption@ifbool{pkt@#1}{%
-        \@ifundefined{#2}{AtBeginDocument}{firstofone}%
-      }{gobble}}%
-    \PackageInfo{caption}{#1 = \caption@ifbool{pkt@#1}{1}{0} %
-         (\@ifundefined{#2}{not }{}loaded -> \caption@tempa)}%
-  \fi
+%    \begin{macrocode}
+  \DeclareCaptionOption*{onelinecaption}[]{\onelinecaptionstrue}
+  \DeclareCaptionOption*{noonelinecaption}[]{\onelinecaptionsfalse}
+  \DeclareCaptionOption*{tablecaptionabove}[]{\captionsetup[table]{position=t}}
+  \DeclareCaptionOption*{tablecaptionbelow}[]{\captionsetup[table]{position=b}}
+%    \end{macrocode}
 %
-  \@nameundef{caption@ifpkt@#1}%  bugfixed v3.0a
+% \begin{macro}{\onelinecaptionsfalse}
+% \begin{macro}{\onelinecaptionstrue}
+%    \begin{macrocode}
+  \def\onelinecaptionstrue{\caption@setbool{slc}{1}}
+  \def\onelinecaptionsfalse{\caption@setbool{slc}{0}}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
 %
-  \next{%
-    \expandafter\ifx\csname #2\endcsname\relax
-    \else
-      #3
-    \fi}}
+% \begin{macro}{\captionabove}
+% \begin{macro}{\captionbelow}
+% \changes{v3.0j}{2006/03/21}{Bugfix 06-03-21: \cs{let}\cs{caption@setposition}\cs{@gobble} added}
+%  Original code:
+%  \begin{verbatim}
+%  \newcommand{\captionabove}{\@captionabovetrue\scr@caption}
+%  \newcommand{\captionbelow}{\@captionabovefalse\scr@caption}
+%  \end{verbatim}
+%    \begin{macrocode}
+  \def\captionabove{%
+    \caption@setposition{t}\let\caption@setposition\@gobble
+    \scr@caption}
+  \def\captionbelow{%
+    \caption@setposition{b}\let\caption@setposition\@gobble
+	\scr@caption}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \iffalse % Not very useful...
+% \begin{macro}{\setcapindent}
+%    \begin{macrocode}
+%  \def\setcapindent{\@ifstar{\@@setcapindent}{\@setcapindent}}
+%  \def\@setcapindent#1{%
+%    \caption@setformat{plain}\setlength\captionindent{#1}}
+%  \def\@@setcapindent#1{%
+%    \PackageError{caption}{\string\setcapindent* is not supported yet}{\caption@eh}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setcaphanging}
+%    \begin{macrocode}
+%  \def\setcaphanging{%
+%    \caption@setformat{hang}\setlength\captionindent\@z}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setcapwidth}
+%    \begin{macrocode}
+%  \renewcommand*\setcapwidth[2][]{%
+%    \PackageWarning{caption}{%
+%      Ignoring optional argument of \string\setcapwidth!\MessageBreak
+%      You're using package caption.\MessageBreak}%
+%    \setcaptionwidth{#2}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setcapmargin}
+%    \begin{macrocode}
+%  \renewcommand*\setcapmargin{\@ifstar\@setcapmargin\@@setcapmargin}
+%  \renewcommand*\@setcapmargin[2][\@tempdimb]{%
+%    \setlength\@tempdimb{#2}%
+%    \setlength\@tempdima{#1}%
+%    \setcaptionmargin{\@tempdima,\@tempdimb}}
+%  \renewcommand*\@@setcapmargin[2][\@tempdimb]{%
+%    \PackageError{caption}{\string\setcapmargin* is not supported yet}{\caption@eh}}
+%    \end{macrocode}
+% \end{macro}
+% \fi
+%
+%    \begin{macrocode}
+}
+%    \end{macrocode}
+%
+% \subsubsection*{Generic package support}
+%
+% \begin{macro}{\caption@declarepackage}
+%  |\caption@declarepackage|\marg{package name}\par
+%  Each single package support can be switched on or off by using the
+%  appropriate option. By default all of them are enabled.
+%    \begin{macrocode}
+\newcommand*\caption@declarepackage[1]{%
+  \caption@setbool{pkt@#1}{1}%
+  \DeclareCaptionOption*{#1}{\caption@setbool{pkt@#1}{##1}}}
+\AtEndOfPackage{\let\caption@declarepackage\@undefined}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\caption@ifpackage}
+% \changes{v3.0f}{2005/05/29}{3rd argument \meta{code} added, so no extra check is needed}
+%  |\caption@ifpackage|\marg{package name}\marg{package macro}\marg{code}\par
+%  If a certain package support is requested the appropriate code will
+%  be used. `Requested' means that the option belonging to it is set to
+%  |true| and the macro called \meta{package macro} is defined.
+%  (If \meta{package macro} is not yet defined we use |\AtBeginDocument|
+%  here, so the package could be loaded after this package, too.)
+%    \begin{macrocode}
+\newcommand\caption@ifpackage[3]{%
+%    \end{macrocode}
+%    \begin{macrocode}
+%<+debug>  \edef\caption@tempa{%
+%<+debug>    \caption@ifbool{pkt@#1}%
+%<+debug>      {\@ifundefined{#2}{AtBeginDocument}{firstofone}}%
+%<+debug>      {gobble}}%
+%<+debug>  \PackageInfo{caption}{#1 = \caption@ifbool{pkt@#1}{1}{0} %
+%<+debug>       (\@ifundefined{#2}{not }{}loaded -> \caption@tempa)}%
+%    \end{macrocode}
+%    \begin{macrocode}
+  \caption@ifbool{pkt@#1}{%
+    \@ifundefined{#2}%
+      {\let\caption@tempa\AtBeginDocument}%
+      {\let\caption@tempa\@firstofone}%
+  }{%
+    \let\caption@tempa\@gobble
+  }%
+  \caption@tempa{\@ifundefined{#2}{}{#3}}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+  \caption@undefbool{pkt@#1}}
 \AtEndOfPackage{\let\caption@ifpackage\@undefined}
 %    \end{macrocode}
 % \end{macro}
 %
-% These are the packages we support:
+% You can also switch the caption support off using the package option
+% |caption=false|.
+% This may look strange, but there are certain circumstances where this could
+% be useful.
+% Such a situation might be the usage of the \package{subfig} package without
+% disturbing the main caption code of the document class.\par
+% \emph{Note: This mechanism is obsolete now, it has been superseeded by the
+% \package{subfig} package option {\rm|caption=false|} which causes that only the
+% caption kernel \package{caption3} is loaded.}
 %
 %    \begin{macrocode}
-\DeclareCaptionPackage{caption}
+\caption@declarepackage{caption}
 %    \end{macrocode}
 %
+% These are the packages we support:
+%
 %    \begin{macrocode}
-\DeclareCaptionPackage{float}
-\DeclareCaptionPackage{floatrow}
-\DeclareCaptionPackage{hyperref}
-\DeclareCaptionPackage{hypcap}
-\DeclareCaptionPackage{listings}
-\DeclareCaptionPackage{longtable}
-\DeclareCaptionPackage{rotating}
-\DeclareCaptionPackage{sidecap}
-\DeclareCaptionPackage{supertabular}
+\caption@declarepackage{float}
+\caption@declarepackage{floatrow}
+\caption@declarepackage{hyperref}
+\caption@declarepackage{hypcap}
+\caption@declarepackage{listings}
+\caption@declarepackage{longtable}
+\caption@declarepackage{picins}
+\caption@declarepackage{rotating}
+\caption@declarepackage{sidecap}
+\caption@declarepackage{supertabular}
 %    \end{macrocode}
 %
 % \begin{macro}{\ProcessOptionsWithKV}
-% We process our options using the keyval package.
-%    \begin{macrocode}
-\def\ProcessOptionsWithKV#1{% bugfixed v3.0a
+% \changes{v3.0a}{2004/01/23}{Bugfix, see \purett{news:400D360C.9678329F@gmx.net} for details}
+% \changes{v3.0i}{2006/01/03}{Improvement, uses \cs{caption@setkeys} instead of \cs{setkeys}}
+% \changes{v3.0j}{2006/02/23}{Bugfix, now processes only those global options which have a default value}
+%  We process our options using the keyval package, so we use this one
+%  instead of |\ProcessOptions| offered by \LaTeXe.
+%  (This code was taken from the \package{hyperref} package.)
+%    \begin{macrocode}
+\def\ProcessOptionsWithKV#1{%
   \let\@tempc\relax
+%    \end{macrocode}
+%
+%    \begin{macrocode}
   \let\caption@tempa\@empty
   \@for\CurrentOption:=\@classoptionslist\do{%
-    \@ifundefined{KV@#1@\CurrentOption}%
-    {}%
-    {%
-      \edef\caption@tempa{\caption@tempa,\CurrentOption,}%
-      \@expandtwoargs\@removeelement\CurrentOption
-        \@unusedoptionlist\@unusedoptionlist
+    \@ifundefined{KV@#1@\CurrentOption}{%
+    }{%
+      \@ifundefined{KV@#1@\CurrentOption @default}{%
+        \PackageInfo{#1}{Global option `\CurrentOption' ignored}%
+      }{%
+        \PackageInfo{#1}{Global option `\CurrentOption' processed}%
+        \edef\caption@tempa{\caption@tempa,\CurrentOption,}%
+        \@expandtwoargs\@removeelement\CurrentOption
+          \@unusedoptionlist\@unusedoptionlist
+      }%
     }%
   }%
   \edef\caption@tempa{%
-    \noexpand\setkeys{#1}{%
+    \noexpand\caption@setkeys{#1}{%
       \caption@tempa\@ptionlist{\@currname.\@currext}%
     }%
   }%
   \caption@tempa
 %    \end{macrocode}
-% Bugfix, see |<400D360C.9678329F@gmx.net>| for details
+%
 %    \begin{macrocode}
   \let\CurrentOption\@empty
   \AtEndOfPackage{\let\@unprocessedoptions\relax}}
@@ -2890,39 +3478,63 @@
 %
 %    \begin{macrocode}
 \ProcessOptionsWithKV{caption}
-\let\ProcessOptionsWithKV\@undefined
 %    \end{macrocode}
 %
+% If the option |caption=false| was given we stop processing this file
+% immediately.
 %    \begin{macrocode}
 \caption@ifbool{pkt@caption}{}{\endinput}
-\@nameundef{caption@ifpkt@caption}
+\caption@undefbool{pkt@caption}
 %    \end{macrocode}
 %
-% \subsubsection*{Usefull stuff}
+% \subsubsection*{Useful stuff}
 %
 % \begin{macro}{\captionof}
-% |\captionof|(|*|)\marg{type}\oarg{lst\_entry}\marg{heading}
+%  |\captionof|(|*|)\marg{type}\oarg{lst\_entry}\marg{heading}
 %    \begin{macrocode}
 \def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}
 \newcommand*\caption@of[2]{\def\@captype{#2}#1}
 %    \end{macrocode}
 % \end{macro}
 %
+% Note: Like |\captionof| the option |type=| should only be used inside a
+% group or environment and does not check if the argument is a valid
+% floating environment or not.
+%
+% \changes{v3.0d}{2005/11/28}{Option \opt{type=} added}
+%    \begin{macrocode}
+\DeclareCaptionOption{type}{\def\@captype{#1}}
+%    \end{macrocode}
+%
 % \begin{macro}{\ContinuedFloat}
-% |\ContinuedFloat|
+% \changes{v3.0f}{2005/06/11}{Call of \cs{caption@ContinuedFloat} added}
+% \changes{v3.0i}{2005/11/12}{Optional argument and call of \cs{caption@@ContinuedFloat} added}
+%  |\ContinuedFloat|\oarg{type}\par
+%  This mainly decreases the appropriate counter by $-1$.
 %    \begin{macrocode}
 \providecommand\ContinuedFloat{%
-  \ifx\@captype\@undefined
-    \@latex@error{\noexpand\ContinuedFloat outside float}\@ehd
-  \else
-    \addtocounter\@captype\m@ne
-    \caption@ContinuedFloat\@captype
-  \fi}%
+  \@ifnextchar[%]
+    \@ContinuedFloat
+    {\ifx\@captype\@undefined
+       \@latex@error{\noexpand\ContinuedFloat outside float}\@ehd
+     \else
+       \@ContinuedFloat[\@captype]%
+     \fi}}
+\def\@ContinuedFloat[#1]{%
+  \addtocounter{#1}\m@ne
+  \caption@ContinuedFloat{#1}%
+  \caption@@ContinuedFloat{#1}}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@ContinuedFloat}
 % \begin{macro}{\caption@resetContinuedFloat}
+%  |\caption@ContinuedFloat|\marg{type}\par
+%  |\caption@resetContinuedFloat|\marg{type}\par
+%  The first one will be called inside |\ContinuedFloat|, the second one
+%  inside |\caption|. Usually they do nothing but this changes if the
+%  \package{hyperref} package is loaded. (See \package{hyperref} package
+%  support for details.)
 %    \begin{macrocode}
 \let\caption@ContinuedFloat\@gobble
 \let\caption@resetContinuedFloat\@gobble
@@ -2930,20 +3542,42 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\caption@@ContinuedFloat}
+% This hook is for foreign packages which link themself into |\ContinuedFloat|,
+% for example the \package{subfig} package\cite{subfig}.
+%    \begin{macrocode}
+\providecommand*\caption@@ContinuedFloat[1]{}
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection*{Internal helpers}
 %
 % \begin{macro}{\caption@begin}
-% |\caption@begin|\marg{type} (changed in v3.0b+v3.0e)
+% \changes{v3.0a}{2004/01/23}{\cs{caption@settype} changed by \cs{caption@setfloattype}}
+% \changes{v3.0e}{2005/04/12}{Check for default label format added}
+% \changes{v3.0f}{2005/06/11}{Call of \cs{caption@resetContinuedFloat} added}
+%  Our handling of |\caption| will always be surrounded by
+%  |\caption@begin| (or |\caption@beginex|) and |\caption@end|.\par
+%  |\caption@begin|\marg{type} performs these tasks:
+%  \begin{itemize}
+%  \item Call |\caption@resetContinuedFloat| (see above)
+%        and start a new group
+%  \item Execute the options set with |\captionsetup|\oarg{type}
+%  \item Define |\fnum@|\meta{type} if the caption label format is set
+%        to non-default
+%  \item Override the |position=| setting, if necessary
+%        (for example if set to |auto| or used inside a |supertabular|)
+%  \end{itemize}
 %    \begin{macrocode}
 \newcommand*\caption@begin[1]{%
   \caption@resetContinuedFloat{#1}%
   \begingroup
+%    \end{macrocode}
+%    \begin{macrocode}
   \caption@setfloattype{#1}%
 %    \end{macrocode}
 %
-% \changes{v3.0e}{12 Apr 05}{Check for default label format added}
 %    \begin{macrocode}
-% \caption@setfnum{#1}%
   \ifx\caption@lfmt\caption@lfmt@default\else
     \@namedef{fnum@#1}{%
       \caption@lfmt{\caption@floatname{#1}}{\@nameuse{the#1}}}%
@@ -2952,28 +3586,37 @@
 %
 %    \begin{macrocode}
   \caption@fixposition
-  \global\let\caption@fixedposition\caption@position
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-  \caption@@begin{#1}}
+  \global\let\caption@fixedposition\caption@position}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@beginex}
-% |\caption@beginex|\marg{type}\marg{list entry}
-%    \begin{macrocode}
-\newcommand*\caption@beginex[1]{%
+% \changes{v3.0b}{2004/05/16}{Support of \opt{listof=} added}
+% \changes{v3.0h}{2005/09/16}{Bugfix: Made this macro and \cs{addcontentsline} \cs{long}}
+%  |\caption@beginex|\marg{type}\marg{list entry}\\
+%  performs the same tasks as |\caption@begin| and additionally:
+%  Redefine |\addcontentsline| if no list-of entry is requested, that
+%  means either the argument \meta{list entry} is empty or |listof=| was
+%  set to |false|.
+%    \begin{macrocode}
+\newcommand\caption@beginex[2]{%
   \caption@begin{#1}%
-  \caption@preparelof}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+  \caption@iflof%
+    {\def\caption@tempa{#2}}%
+    {\let\caption@tempa\@empty}%
+  \ifx\caption@tempa\@empty
+    \long\def\addcontentsline##1##2##3{}%
+  \fi}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@end}
-% |\caption@end|
+%  |\caption@end| closes the group.
 %    \begin{macrocode}
 \newcommand*\caption@end{%
-  \caption@@end
   \endgroup
 %    \end{macrocode}
 %
@@ -2983,17 +3626,31 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@setfloattype}
-% A macro for setting up the right float type within |\@caption|, |\LT@makecaption| etc.
-% Usually this is equivalent to |\caption@settype| but I made it an own macro so
-% I can extend it later on, for example if the \package{float} package is loaded.
+% \changes{v3.0a}{2004/01/23}{This macro added}
+%  |\caption@setfloattype|\marg{type}\\
+%  sets up the right float type within |\@caption|, |\LT@makecaption| etc.
+%  Usually this is equivalent to |\caption@settype| but I made it an own macro so
+%  I can extend it later on, for example if the \package{float} or
+%  \package{sidecap} package is loaded.
 %    \begin{macrocode}
-\let\caption@setfloattype\caption@settype%  new v3.0a
+\let\caption@setfloattype\caption@settype
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@letfloattype}
-% |\caption@letfloattype|\marg{type}\marg{extra code}\\
-% (new in v3.0b, additional argument in v3.0e)
+% \changes{v3.0b}{2004/05/16}{This macro added}
+% \changes{v3.0e}{2005/05/05}{Argument \meta{extra code} added}
+%  |\caption@letfloattype|\marg{type}\marg{extra code}\\
+%  redefines |\caption@setfloattype| so it does not only
+%  |\caption@settype|\marg{type} but two additional tasks:
+%  Executing extra code given as second argument and
+%  execute options with |\caption@settype{#1}| afterwards.\par
+%  You can find an example of its usage in the \package{longtable}
+%  support, where this macro is called so
+%  |\captionsetup[longtable]{|\ldots|}| can be used to setup options
+%  for longtables which have a higher priority than the options which
+%  have been setup with |\captionsetup[table]{|\ldots|}| or
+%  |\setlength\LTcapwidth{|\ldots|}|.
 %    \begin{macrocode}
 \newcommand*\caption@letfloattype[2]{%
   \def\caption@setfloattype##1{%
@@ -3001,61 +3658,70 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\caption@preparelof}
-% |\caption@preparelof|\marg{list entry}
-%    \begin{macrocode}
-\newcommand*\caption@preparelof[1]{%  changed v3.0b
-  \caption@iflof%
-    {\def\caption@tempa{#1}}%
-    {\let\caption@tempa\@empty}%
-  \ifx\caption@tempa\@empty
-    \def\addcontentsline##1##2##3{}%
-  \fi}
-%    \end{macrocode}
-% \end{macro}
+% \changes{v3.0a}{2004/01/23}{Internal hooks \cs{caption@@begin} \& \cs{caption@@end} added}
+% \changes{v3.0h}{2005/10/06}{Internal hooks \cs{caption@@begin} \& \cs{caption@@end} removed}
 %
-% \begin{macro}{\caption@@begin}
-% \begin{macro}{\caption@@end}
-% |\caption@@begin|\marg{type}\\
-% |\caption@@end|
+% \begin{macro}{\caption@floatname}
+%  |\caption@floatname|\marg{type}\par
+%  Usually all float names (which partly build the caption label)
+%  follow the same naming convention. But some packages (for example
+%  the \package{float} package) do not, so we use this wrapper macro which
+%  can be changed later on.
 %    \begin{macrocode}
-\let\caption@@begin\@gobble % new v3.0a
-\let\caption@@end\@empty %    new v3.0a
+\newcommand*\caption@floatname[1]{\@nameuse{#1name}}
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
 %
 % \subsubsection*{Caption support}
 %
+% \iffalse\begin{quote}
+% \small\emph{Note:}
+% Our aim is patching the existing |\caption| code so changes done by other
+% packages will not get lost. We do similar in our \package{float},
+% \package{hyperref}, and \package{hypcap} support so get the disadvantage
+% of having ugly code with some negative side-effects, like the non-working
+% |\caption{}| feature when the \package{french(le)} or \package{hyperref}
+% package is loaded.
+% \end{quote}\fi
+%
 % Some packages (like the \package{hyperref} package for example) redefines
-% |\caption| and |\@caption|, too, but without chaining to the previous
-% definition. So we have to use |\AtBeginDocument| here, so we can make sure
+% |\caption| and |\@caption|, too, but without chaining to their previous
+% definitions. So we have to use |\AtBeginDocument| here, so we can make sure
 % our definition don't get lost.
 %
 %    \begin{macrocode}
 \AtBeginDocument{%
-  \let\caption@old\caption
-  \let\caption@@old\@caption
 %    \end{macrocode}
 %
+% We only patch |\caption| and |\@caption| if the \package{captcont} package
+% (which brings it's own definition of |\caption*|) is not used.
+% It does not make much sense using the actual version of the \package{caption}
+% package with the \package{captcont} package, but this was different in the
+% old (\version{1.x}) days so we take care to be backward compatible.
+%
 %    \begin{macrocode}
   \@ifundefined{cc@caption}{%
 %    \end{macrocode}
 %
 % \begin{macro}{\caption}
-%   Define |\caption*| \ldots\\
-%   (07/18/03: |\global| added, so this works with sidecap)
-%   (05/22/05: |\ContinuedFloat| added)
+% \iffalse\changes{v3.0}{2003/07/18}{Bugfix: \cs{global} added, so this works with sidecap}\fi
+% \changes{v3.0f}{2005/05/22}{Bugfix: \cs{ContinuedFloat} added}
+% \changes{v3.0f}{2005/06/13}{Support of \cs{caption*[]} removed}
+%  Here comes our definition of |\caption| and |\caption*|.
+%  (We set |\caption@startrue| globally so it works with the \package{sidecap} package, too.)
 %    \begin{macrocode}
+    \let\caption@old\caption
     \def\caption{\caption@caption\caption@old}%
     \def\caption@caption#1{%
-      \@ifstar{\ContinuedFloat\global\caption@startrue #1[]}{#1}}%
+      \@ifstar{\ContinuedFloat\global\caption@startrue#1[]}{#1}}%
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\@caption}
-%   Define |\caption[]{|\ldots|}| \ldots
+%  Our definition of |\@caption| simply calls the old definition,
+%  nested by |\caption@beginex| and |\caption@end|.
 %    \begin{macrocode}
+    \let\caption@@old\@caption
     \long\def\@caption#1[#2]#3{%
       \caption@beginex{#1}{#2}%
         \caption@@old{#1}[{#2}]{#3}%
@@ -3067,57 +3733,147 @@
   }{%
 %    \end{macrocode}
 %
-%   Minimum captcont package support (bugfixed v3.0c, 04-07-15)
+% \changes{v3.0c}{2004/07/16}{Bugfix 04-07-15: \package{captcont} support fixed}
+% Minimum \package{captcont} package support:\\
+% We define |\caption@caption| here so it's there but does not make any harm.
 %
 %    \begin{macrocode}
     \PackageInfo{caption}{captcont package v2.0 detected}%
-    \def\caption@caption#1{#1}%  added v3.0c
+    \def\caption@caption#1{#1}%
   }%
 }
 %    \end{macrocode}
 %
 % \begin{macro}{\@makecaption}
-% |\@makecaption|\marg{label}\marg{text}\par\bigskip
-% Original code (from |latex/base/classes.dtx|):
-% \begin{verbatim}
-% \long\def\@makecaption#1#2{%
-%   \vskip\abovecaptionskip
-%   \sbox\@tempboxa{#1: #2}%
-%   \ifdim \wd\@tempboxa >\hsize
-%     #1: #2\par
-%   \else
-%     \global \@minipagefalse
-%     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
-%   \fi
-%   \vskip\belowcaptionskip}
-% \end{verbatim}
+%  |\@makecaption|\marg{label}\marg{text}\par
+%  The original code (from |latex/base/classes.dtx|):
+%  \begin{verbatim}
+%  \long\def\@makecaption#1#2{%
+%    \vskip\abovecaptionskip
+%    \sbox\@tempboxa{#1: #2}%
+%    \ifdim \wd\@tempboxa >\hsize
+%      #1: #2\par
+%    \else
+%      \global \@minipagefalse
+%      \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
+%    \fi
+%    \vskip\belowcaptionskip}
+%  \end{verbatim}
+%  We do basically the same, but take care of the |position=| setting
+%  and use |\caption@@make| from the \package{caption} kernel to actually
+%  typeset the caption.
 %    \begin{macrocode}
 \renewcommand\@makecaption[2]{%
   \caption@iftop{\vskip\belowcaptionskip}{\vskip\abovecaptionskip}%
-  \ifnum\caption@debug>1 %
-    \llap{$\caption@iftop\downarrow\uparrow$ }%
-  \fi
+%    \end{macrocode}
+%    \begin{macrocode}
+%<+debug>  \caption@ifbool{showpos}{%
+%<+debug>    \llap{$\caption@iftop\downarrow\uparrow$ }}{}%
+%    \end{macrocode}
+%    \begin{macrocode}
   \caption@@make{#1}{#2}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
   \caption@iftop{\vskip\abovecaptionskip}{\vskip\belowcaptionskip}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \subsubsection*{KOMA-script classes support}
-% (new in 3.0a)
+% \subsubsection*{\package{\KOMAScript} classes support}
+% \changes{v3.0a}{2004/01/18}{Minimum adaptation to \KOMAScript\ added}
+% \changes{v3.0h}{2005/08/22}{\cs{PackageInfo} added to \KOMAScript\ support}
 %
-% \changes{v3.0a}{18 Jan 04}{Minimum adaption to KOMA-Script added}
 %    \begin{macrocode}
-\AtBeginDocument{\let\scr@caption\caption}
+\AtBeginDocument{\@ifundefined{scr@caption}{}{%
+  \PackageInfo{caption}{KOMA-Script class detected}%
 %    \end{macrocode}
 %
-% \subsubsection*{float package support}
+% \begin{macro}{\scr@caption}
+%  We update the definition of |\scr@caption| so it actually reflects
+%  our definition of |\caption|.
+%    \begin{macrocode}
+  \let\scr@caption\caption
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
+}}
+%    \end{macrocode}
+%
+% \subsubsection*{french(le) package support}
+% \changes{v3.0h}{2005/10/03}{Minimum adaptation to \package{french(le)} added}
 %
+%    \begin{macrocode}
+\AtBeginDocument{\@ifundefined{f@ffrench}{}{%
+  \PackageInfo{caption}{french(le) package detected}%
+%    \end{macrocode}
+%
+% If |\GOfrench| is defined as |\relax| all the re-definitions regarding
+% captions have already been done, so we can do our patches immediately.
+% Otherwise we must add our stuff to |\GOfrench|.
+%
+%    \begin{macrocode}
+  \@ifundefined{GOfrench}%
+    {\let\caption@tempa\@firstofone}%
+    {\def\caption@tempa{\g@addto@macro\GOfrench}}%
+  \caption@tempa{%
+%    \end{macrocode}
+%
+% \begin{macro}{\@cnORI}
+%  We update the definition of |\@cnORI| so it actually reflects
+%  our definition of |\caption|.
+%    \begin{macrocode}
+    \let\@cnORI\caption
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@tablescaption}
+%  The \package{french(le)} package sets |\caption| to |\@tablescaption| at
+%  |\begin{table}| for special a treatment of footnotes.
+%  Therefore we have to patch |\@tablescaption| so |\caption*| will work
+%  inside the |table| environment.
+%    \begin{macrocode}
+    \let\caption@tablescaption\@tablescaption
+    \def\@tablescaption{\caption@caption\caption@tablescaption}%
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\f@ffrench}
+% \begin{macro}{\f@tfrench}
+%  |\f@ffrench| and |\f@tfrench| reflect |\fnum@figure| and |\fnum@table|
+%  when used in french mode. These contain additional code which typesets
+%  the caption separator |\captionseparator| instead of the usual colon.
+%  Because this breaks with our |\@makecaption| code we have to remove
+%  this additional code here.
+%    \begin{macrocode}
+    \let\@eatDP\@undefined
+    \let\caption@tempa\@empty
+    \ifx\f@ffrench\fnum@figure
+      \l@addto@macro\caption@tempa{\let\fnum@figure\f@ffrench}%
+    \fi
+    \ifx\f@tfrench\fnum@table
+      \l@addto@macro\caption@tempa{\let\fnum@table\f@tfrench}%
+    \fi
+    \def\f@ffrench{\ifx\listoffigures\relax\else\figurename~\thefigure\fi}%
+    \def\f@tfrench{\ifx\listoftables\relax\else\tablename~\thetable\fi}%
+    \caption@tempa
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%    \begin{macrocode}
+}}}
+%    \end{macrocode}
+%
+% \subsubsection*{\package{float} package support}
+% \changes{v3.0f}{2005/05/31}{\package{float} package support rewritten and improved}
 % \iffalse
-% Rewritten v0.3f: more straight-ahead implementation, but only works with v1.3 now
-% (the old code incl. documentation can be found in caption-30f-050530.zip)
+% (This is a more straight-ahead implementation, but it only works with v1.3
+%  now, so v1.2 is no longer supported. The old code including documentation
+%  can be found in caption-30f-050530.zip)
 % \fi
 %
-% The \package{float} package usually do not use the LaTeX kernel command
+% The \package{float} package usually do not use the \LaTeX\ kernel command
 % |\@caption| to typeset the caption but |\float@caption| instead.
 % (|\@caption| will only be used if the float is re-styled with
 % |\restylefloat*|.)
@@ -3138,20 +3894,20 @@
 % |\caption@@make| will be used instead of |\@fs@capt|.
 %
 % To allow different caption styles for different float styles we will also
-% determine the current float style (e.g. `ruled') at run time and setup
+% determine the current float style (e.g. `ruled') at run time and select
 % a caption style (and additional settings) with the same name, if defined.
 %
 % \begin{macro}{\caption@setfloatposition}
-% First of all we provide a macro which converts |\@fs@iftopcapt| (which
-% is part of a float style and controls where the caption will be typeset,
-% above or below the float contents) to our |position=| setting. Since the
-% spacing above and below the caption will be done by the float style and
-% \emph{not} by us this sounds quite useless. But in fact it isn't, since some
-% packages based on the \package{caption} package (like the \package{subfig}
-% package) could have an interest for this information and therefore use the
-% |\caption@iftop| macro we provide in our kernel. Furthermore we need this
-% information for ourself in |\captionof| which uses |\@makecaption| to
-% finally typeset the caption.
+%  First of all we provide a macro which converts |\@fs@iftopcapt| (which
+%  is part of a float style and controls where the caption will be typeset,
+%  above or below the float contents) to our |position=| setting. Since the
+%  spacing above and below the caption will be done by the float style and
+%  \emph{not} by us this sounds quite useless. But in fact it isn't, since some
+%  packages based on the \package{caption} package (like the \package{subfig}
+%  package) could have an interest for this information and therefore use the
+%  |\caption@iftop| macro we provide in our kernel. Furthermore we need this
+%  information for ourself in |\captionof| which uses |\@makecaption| to
+%  finally typeset the caption with skips.
 %    \begin{macrocode}
 \def\caption@setfloatposition{%
   \caption@setposition{\@fs@iftopcapt t\else b\fi}}
@@ -3177,19 +3933,19 @@
 % (We don't check for this so you'll get wired errors if you try to do so!)
 %
 % \begin{macro}{\caption@of@float}
-% Usually no special action is necessary, so we define |\caption@of@float|
-% to |\@gobble|. We will redefine it later on to |\@firstofone| to activate
-% the code which `unfolds' the savebox.
+%  Usually no special action is necessary, so we define |\caption@of@float|
+%  to |\@gobble|. We will redefine it later on to |\@firstofone| to activate
+%  the code which `unfolds' the savebox.
 %    \begin{macrocode}
   \let\caption@of@float\@gobble
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@of}
-% If the float is defined by the float package (which means |\fst@|\meta{type}
-% is defined) we activate the special treatment for such captions typeset
-% with |\captionof|. Furthermore we `execute' this float style, so
-% |\@fs@iftopcapt| is set to its proper value.
+%  If the float is defined by the float package (which means |\fst@|\meta{type}
+%  is defined) we activate the special treatment for such captions typeset
+%  with |\captionof|. Furthermore we `execute' this float style, so
+%  |\@fs@iftopcapt| is set to its proper value.
 %    \begin{macrocode}
   \renewcommand*\caption@of[2]{%
     \@ifundefined{fst@#2}{}{%
@@ -3200,117 +3956,137 @@
 % \end{macro}
 %
 % \begin{macro}{\float@caption}
-% Our version of |\float@caption| nearly looks like our version of |\@caption|.
-% The main differences are that |\@fs@capt| will be replaced by our |\caption@@make|
-% and that the savebox called |\@floatcapt| will be unfolded if required. (See above)
+% \changes{v3.0h}{2005/08/23}{Bugfix 05-08-12: \cs{captionof} sets hyperref anchor now}
+%  Our version of |\float@caption| nearly looks like our version of |\@caption|.
+%  The main differences are that |\@fs@capt| will be replaced by our |\caption@@make|
+%  and that the savebox called |\@floatcapt| will be unfolded if requested by
+%  |\captionof|. (see above)
 %    \begin{macrocode}
   \let\caption@@float\float@caption
   \long\def\float@caption#1[#2]#3{%
     \caption@beginex{#1}{#2}%
       \let\@fs@capt\caption@@make
       \caption@@float{#1}[{#2}]{#3}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
       \caption@of@float{%
+%    \end{macrocode}
+%  If the \package{hyperref} package is loaded, we need to set the appropriate
+%  anchor for ourself. To do so without adding extra vertical space we need
+%  to save (and restore) |\prevdepth| and switch off the interline skip.
+%    \begin{macrocode}
+        \@ifundefined{hyper@@anchor}{}{%
+          \begingroup
+            \@tempdima\prevdepth
+            \nointerlineskip
+            \let\leavevmode\relax
+            \hyper@@anchor\@currentHref\relax
+            \prevdepth\@tempdima
+          \endgroup}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
         \def\caption@@make##1##2{\unvbox\@floatcapt}%
         \@makecaption{}{}}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
     \caption@end}%
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\@float@setevery}
-% |\@float@setevery|\marg{float type} is provided by the \package{float} package;
-% it's called every time a floating environment defined with |\newfloat| or
-% |\restylefloat| begins.
-% We use this hook to do some adaptions and to setup the proper caption style
-% (if defined) and additional settings declared with
-% |\captionsetup|\oarg{float style}.
+%  |\@float@setevery|\marg{float type} is provided by the \package{float} package;
+%  it's called every time a floating environment defined with |\newfloat| or
+%  |\restylefloat| begins.
+%  We use this hook to do some adaptations and to setup the proper caption style
+%  (if defined) and additional settings declared with
+%  |\captionsetup|\oarg{float style}.
 %    \begin{macrocode}
   \let\caption@float@setevery\@float@setevery
   \def\@float@setevery#1{%
     \caption@float@setevery{#1}%
 %    \end{macrocode}
 %
-% \LaTeX{} and most packages use |\|\meta{type}|name|
-% to provide a macro for the float name -- for example the command
-% |\figurename| will usually contain the name of the floating environment
-% |figure|:
-% \begin{quote}
-%   |\newcommand\figurename{Figure}|
-% \end{quote}
+%  \LaTeX{} and most packages use |\|\meta{type}|name|
+%  to provide a macro for the float name -- for example the command
+%  |\figurename| will usually contain the name of the floating environment
+%  |figure|:
+%  \begin{quote}
+%    |\newcommand\figurename{Figure}|
+%  \end{quote}
 %
-% But the \package{float} package don't follow this naming convention,
-% it uses |\fname@|\meta{type} instead. So we have to adapt
-% |\caption@floatname| here, so our captions will be still ok.
+%  But the \package{float} package don't follow this naming convention,
+%  it uses |\fname@|\meta{type} instead. So we have to adapt
+%  |\caption@floatname| here, so our captions will be still ok.
 %
 %    \begin{macrocode}
     \def\caption@floatname##1{\@nameuse{fname@#1}}%
 %    \end{macrocode}
 %
-% |\newfloat| and |\restylefloat| saves the \emph{actual} definition of
-% |\@caption| or |\float@caption| in |\@float@c@|\meta{captype} with |\let|
-% (instead of using |\def|), so redefinitions of |\@caption| (and of course
-% our redefinition of |\float@caption|) will never been used if the
-% |\newfloat| or |\restylefloat| command takes place in front of the
-% redefinitions provided by the \package{caption} or other packages like the
-% \package{hyperref} package.
+%  Both |\newfloat| and |\restylefloat| save the \emph{actual} definition of
+%  |\@caption| or |\float@caption| in |\@float@c@|\meta{captype} with |\let|
+%  (instead of using |\def|), so redefinitions of |\@caption| (and of course
+%  our redefinition of |\float@caption|) will never been used if the
+%  |\newfloat| or |\restylefloat| command takes place in front of the
+%  redefinitions provided by the \package{caption} or other packages like the
+%  \package{hyperref} package.
 %
-% So here we determine if the user has used |\restylefloat| or
-% |\restylefloat*| and bring |\@float@c@|\meta{captype} up-to-date.
-% This is quite easy: If |\@float@c@|\meta{captype} is the same as the
-% original or our own definition of |\float@caption|, the user has used
-% |\restylefloat| (and |\float@caption| should be used), otherwise
-% we assume he has used |\restylefloat*| (and |\@caption| should be used).
-% (This test will fail if some other package re-defines |\float@caption|,
-% too, so we have to assume that we are the only one.)
+%  So here we determine if the user has used |\restylefloat| or
+%  |\restylefloat*| and bring |\@float@c@|\meta{captype} up-to-date.
+%  This is quite easy: If |\@float@c@|\meta{captype} is the same as the
+%  original or our own definition of |\float@caption|, the user has used
+%  |\restylefloat| (and |\float@caption| should be used), otherwise
+%  we assume he has used |\restylefloat*| (and |\@caption| should be used).
+%  (This test will fail if some other package re-defines |\float@caption|,
+%  too, so we have to assume that we are the only one.)
 %
 %    \begin{macrocode}
     \expandafter\let\expandafter\caption@tempa\csname @float@c@#1\endcsname
     \ifx\caption@tempa\float@caption
     \else\ifx\caption@tempa\@caption
     \else\ifx\caption@tempa\caption@@float
-%     \ifodd\caption@debug\relax
-%       \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\float@caption}%
-%     \fi
+%<+debug>      \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\float@caption}%
       \expandafter\let\csname @float@c@#1\endcsname\float@caption
     \else
-%     \ifodd\caption@debug\relax
-%       \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\@caption}%
-%     \fi
+%<+debug>      \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\@caption}%
       \expandafter\let\csname @float@c@#1\endcsname\@caption
     \fi\fi\fi
 %    \end{macrocode}
 %
-% If the floating environment is defined with |\newfloat| or |\restylefloat|
-% (and \emph{not} with |\restylefloat*|), |\@float@c@|\meta{type}
-% will now be identical to |\float@caption|.
+%  If the floating environment is defined with |\newfloat| or |\restylefloat|
+%  (and \emph{not} with |\restylefloat*|), |\@float@c@|\meta{type}
+%  will now be identical to |\float@caption|.
 %
 %    \begin{macrocode}
     \expandafter\ifx\csname @float@c@#1\endcsname\float@caption
 %    \end{macrocode}
 %
-% First of all we set the caption position to it's proper value.
-% (See above definition of |\caption@setfloatposition|)
+%  First of all we set the caption position to it's proper value.
+%  (See above definition of |\caption@setfloatposition|)
 %
 %    \begin{macrocode}
-      \caption@setfloatposition%  changed v3.0b+f
+      \caption@setfloatposition
 %    \end{macrocode}
 %
-% Now we'll have to determine the current float style.
-% This is not so easy because the only hint provided by the \package{float}
-% package is the macro |\fst@|\meta{float type} which points to the macro
-% which represents the float style.
-% So for example after
-% \begin{quote}
-%   |\floatstyle{ruled}|\\
-%   |\newfloat{Program}{tbp}{lop}|
-% \end{quote}
-% |\fst@Program| will be defined as
-% \begin{quote}
-%   |\def\fst@Program{\fs@ruled}|\quad.
-% \end{quote}
+%  Now we'll have to determine the current float style.
+%  This is not so easy because the only hint provided by the \package{float}
+%  package is the macro |\fst@|\meta{float type} which points to the macro
+%  which represents the float style.
+%  So for example after
+%  \begin{quote}
+%    |\floatstyle{ruled}|\\
+%    |\newfloat{Program}{tbp}{lop}|
+%  \end{quote}
+%  |\fst@Program| will be defined as
+%  \begin{quote}
+%    |\def\fst@Program{\fs@ruled}|\quad.
+%  \end{quote}
 %
-% So here is what we do: We copy |\fst@|\meta{float type} to |\caption@fst| and
-% make it a string so we can gobble the first four tokens (= |\fs@|), so only the
-% the name of the float style is left.
+%  So here is what we do: We copy |\fst@|\meta{float type} to |\caption@fst| and
+%  make it a string so we can gobble the first four tokens (= |\fs@|), so only the
+%  the name of the float style is left.
 %
 %    \begin{macrocode}
       \expandafter\let\expandafter\caption@fst\csname fst@#1\endcsname
@@ -3319,12 +4095,12 @@
 %     \edef\caption@fst{\caption@fst}%
 %    \end{macrocode}
 %
-% |\caption@fst| now contains the float style (e.g. `ruled')
-% so we can use it to set the corresponding style (if defined) and additional options.
+%  |\caption@fst| now contains the float style (e.g. `ruled')
+%  so we can use it to set the corresponding style (if defined) and additional options.
 %
 %    \begin{macrocode}
       \caption@setstyle*\caption@fst
-      \caption@settype\caption@fst% new v3.0f
+      \caption@settype\caption@fst
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -3332,12 +4108,14 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \changes{v3.0f}{2005/06/26}{Skips of \env{plaintop} and \env{boxed} floats corrected}
+%
 % \begin{macro}{\fs@plaintop}
 % \begin{macro}{\fs@boxed}
-% The float styles |plaintop| and |boxed| don't use our skip which can be set
-% with |skip=| : |plaintop| uses |\belowcaptionskip| instead of
-% |\abovecaptionskip|, and |boxed| uses a fixed space of |2pt|.
-% So we patch the according float style macros here.
+%  The float styles |plaintop| and |boxed| don't use our skip which can be set
+%  with |skip=| : |plaintop| uses |\belowcaptionskip| instead of
+%  |\abovecaptionskip|, and |boxed| uses a fixed space of |2pt|.
+%  So we patch the according float style macros here to change this.
 %    \begin{macrocode}
   \g@addto@macro\fs@plaintop{\def\@fs@mid{\vspace\abovecaptionskip\relax}}%
   \g@addto@macro\fs@boxed{\def\@fs@mid{\kern\abovecaptionskip\relax}}%
@@ -3349,29 +4127,35 @@
 }
 %    \end{macrocode}
 %
+% The skip between `boxed' floats and their caption defaults to |2pt|.
+%
 %    \begin{macrocode}
-\captionsetup[boxed]{skip=2pt}%
+\captionsetup[boxed]{skip=2pt}
 %    \end{macrocode}
 %
+% \changes{v3.0f}{2005/05/26}{\opt{strut=0} added to caption style \opt{ruled}}
+% \changes{v3.0f}{2005/05/27}{Option \opt{ruled} fixed}
 % To emulate the `ruled' definition of |\@fs@capt| we provide a caption style
 % `ruled' with appropriate options. But if the package option |ruled| was
-% specified, we setup additional caption settings to emulate the behaviour
-% of the \package{caption} package v$1.x$ option |ruled| instead:
+% specified, we setup some caption parameters to emulate the behaviour
+% of the \package{caption} package \version{1.x} option |ruled| instead:
 % The current caption settings will be used, but without margin and without
 % `single-line-check'.
 %    \begin{macrocode}
 \caption@ifbool{ruled}{%
-  \captionsetup[ruled]{margin=0pt,singlelinecheck=0}% new v3.0f
-}{% v3.0f: "strut=0" added
-  \DeclareCaptionStyle{ruled}{labelfont=bf,labelsep=space,strut=0}}
-\let\caption@ifruled\@undefined
+  \captionsetup[ruled]{margin=0pt,singlelinecheck=0}%
+}{%
+  \DeclareCaptionStyle{ruled}{labelfont=bf,labelsep=space,strut=0}%
+}
+\caption@undefbool{ruled}
 %    \end{macrocode}
 %
-% \subsubsection*{floatrow package support}
+% \subsubsection*{\package{floatrow} package support}
+% \changes{v3.0f}{2005/06/01}{Support of the \package{floatrow} package added}
 %
 % The \package{floatrow} package is adapted for usage with the
 % \package{caption} package. So the main work has already been done,
-% there are only two little things we have to take care about.
+% there are only two little things we have to take care about:
 %
 %    \begin{macrocode}
 \caption@ifpackage{floatrow}{flrow@setlist}{%
@@ -3379,11 +4163,11 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@of}
-% Captions typeset with |\captionof| should have the correct layout,
-% so we have to `activate' this layout here with |\flrow@setlist|.
-% \par{\small (Please note that this version of |\captionof| has the same
-% restrictions than the |\captionof| offered for floating environments
-% defined with the \package{float} package, see above.)}
+%  Captions typeset with |\captionof| should have the correct layout,
+%  so we have to `activate' this layout here with |\flrow@setlist|.
+%  \par{\small (Please note that this version of |\captionof| has the same
+%  restrictions than the |\captionof| offered for floating environments
+%  defined with the \package{float} package, see above.)}
 %    \begin{macrocode}
   \renewcommand*\caption@of[2]{%
     \def\@captype{#2}\flrow@setlist{{#2}}#1}%
@@ -3391,9 +4175,9 @@
 % \end{macro}
 %
 % \begin{macro}{\caption@floatname}
-% The \package{floatrow} package followes the same naming convention
-% as the \package{float} package; so we have to adapt |\caption@floatname|
-% here, too.
+%  The \package{floatrow} package follows the same naming convention
+%  as the \package{float} package; so we have to adapt |\caption@floatname|
+%  here, too.
 %    \begin{macrocode}
   \renewcommand*\caption@floatname[1]{%
     \@nameuse{\@ifundefined{fname@#1}{#1name}{fname@#1}}}%
@@ -3404,8 +4188,8 @@
 }
 %    \end{macrocode}
 %
-%
-% \subsubsection*{hyperref package support}
+% \subsubsection*{\package{hyperref} package support}
+% \changes{v3.0f}{2005/06/11}{Support of the \package{hyperref} package added}
 %
 % When the \package{hyperref} package is used we have the problem
 % that the usage of |\ContinuedFloat| will create duplicate
@@ -3426,9 +4210,10 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\caption@ContinuedFloat}
-% If |\theH|\meta{type} is defined, we extend it with |.|\meta{continue \#}.
-% Furthermore we set |\caption@resetContinuedFloat| to |\@gobble| so the
-% continuation counter will not be reset to zero inside |\caption|.
+% \changes{v3.0g}{2005/06/28}{Bugfix: \cs{newcounter} replaced by \cs{newcount}}
+%  If |\theH|\meta{type} is defined, we extend it with |.|\meta{continue \#}.
+%  Furthermore we set |\caption@resetContinuedFloat| to |\@gobble| so the
+%  continuation counter will not be reset to zero inside |\caption|.
 %    \begin{macrocode}
   \def\caption@ContinuedFloat#1{%
     \@ifundefined{theH#1}{}{%
@@ -3436,14 +4221,15 @@
         \expandafter\newcount\csname CF@#1\endcsname
         \caption@resetContinuedFloat{#1}}{}%
       \global\advance\csname CF@#1\endcsname\@ne\relax
-      \expandafter\l@addto@macro\csname theH#1\endcsname{.\expandafter\@arabic\csname CF@#1\endcsname}%
+      \expandafter\l@addto@macro\csname theH#1\endcsname{%
+        .\expandafter\@arabic\csname CF@#1\endcsname}%
       \let\caption@resetContinuedFloat\@gobble
     }}%
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\caption@resetContinuedFloat}
-% If a continuation counter is defined, we reset it.
+%  If a continuation counter is defined, we reset it.
 %    \begin{macrocode}
   \def\caption@resetContinuedFloat#1{%
     \@ifundefined{CF@#1}{}{\global\csname CF@#1\endcsname\z@\relax}}%
@@ -3454,8 +4240,8 @@
 }
 %    \end{macrocode}
 %
-%
-% \subsubsection*{hypcap package support}
+% \subsubsection*{\package{hypcap} package support}
+% \changes{v3.0f}{2005/06/22}{Support of the \package{hypcap} package added}
 % 
 % When the \package{hypcap} package is used the following problems occur:
 % \begin{enumerate}
@@ -3487,23 +4273,23 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\capstart}
-% Here comes our version of |\capstart|:
+%  Here comes our version of |\capstart|:
 %    \begin{macrocode}
   \let\caption@capstart\capstart
   \def\capstart{%
 %    \end{macrocode}
-% First of all we update |\hc@org@caption| to correct the problem that the
-% \package{hypcap} package has saved an older definition of |\caption|.
+%  First of all we update |\hc@org@caption| to correct the problem that the
+%  \package{hypcap} package has saved an older definition of |\caption|.
 %    \begin{macrocode}
     \let\hc@org@caption\caption
 %    \end{macrocode}
-% Since we don't know the float counter yet (it could be changed with
-% |\ContinuedFloat| afterwards!) we make sure |\H@refstepcounter| will
-% not be used and |\Hy@hypertexnamesfalse| is set, so unique
-% \package{hyperref} labels will be generated by the original
-% definition of |\capstart|.
-% Afterwards we save the reference which was generated by
-% |\hyper@makecurrent|.
+%  Since we don't know the float counter yet (it could be changed with
+%  |\ContinuedFloat| afterwards!) we make sure |\H@refstepcounter| will
+%  not be used and |\Hy@hypertexnamesfalse| is set, so unique
+%  \package{hyperref} labels will be generated by the original
+%  definition of |\capstart|.
+%  Afterwards we save the reference which was generated by
+%  |\hyper@makecurrent|.
 %    \begin{macrocode}
     \begingroup
       \let\H@refstepcounter\@gobble
@@ -3512,15 +4298,16 @@
       \global\let\caption@currentHref\@currentHref
     \endgroup
 %    \end{macrocode}
-% The \package{hypcap} package restores the previous definition of |\caption|
-% inside |\hc@@caption|. But since we will call this inside a group later on
-% (making this restauration non-working), we have to make this for ourself
-% inside |\caption|.
-% (This would not be necessary if \package{hypcap} would do this inside
-% |\hc@caption| instead of |\hc@@caption|.)\par
-% Additionally we increase the float counter here (since we have suppressed this
-% in |\capstart|) and use |\caption@caption| here, so |\caption*| will work as
-% expected.
+%
+%  The \package{hypcap} package restores the previous definition of |\caption|
+%  inside |\hc@@caption|. But since we will call this inside a group later on
+%  (making this restauration non-working), we have to make this for ourself
+%  inside |\caption|.
+%  (This would not be necessary if \package{hypcap} would do this inside
+%  |\hc@caption| instead of |\hc@@caption|.)\par
+%  Additionally we increase the float counter here (since we have suppressed this
+%  in |\capstart|) and use |\caption@caption| here, so |\caption*| will work as
+%  expected.
 %    \begin{macrocode}
     \def\caption{%
       \let\caption\hc@org@caption
@@ -3530,21 +4317,23 @@
 % \end{macro}
 %
 % \begin{macro}{\hc@@caption}
-% Here comes our version of |\hc@@caption|:
+%  Here comes our version of |\hc@@caption|:
 %    \begin{macrocode}
   \let\caption@hc@@caption\hc@@caption
   \long\def\hc@@caption#1[#2]#3{%
     \caption@beginex{#1}{#2}%
 %    \end{macrocode}
-% Beside the usual |\caption@begin| and |\caption@end| stuff (to support local
-% options etc.) we make sure our saved \package{hyperref} reference will be
-% used.
+%
+%  Beside the usual |\caption@begin| and |\caption@end| stuff (to support local
+%  options etc.) we make sure our saved \package{hyperref} reference will be
+%  used.
 %    \begin{macrocode}
       \let\caption@hyper@makecurrent\hyper@makecurrent
       \def\hyper@makecurrent\@captype{%
         \let\hyper@makecurrent\caption@hyper@makecurrent
         \global\let\@currentHref\caption@currentHref}%
 %    \end{macrocode}
+%
 %    \begin{macrocode}
       \caption@hc@@caption{#1}[{#2}]{#3}%
     \caption@end}%
@@ -3555,214 +4344,432 @@
 }
 %    \end{macrocode}
 %
-%
-% \subsubsection*{listings package support}
+% \subsubsection*{\package{listings} package support}
+% \changes{v3.0b}{2004/05/16}{Support of the \package{listings} package added}
 %
 %    \begin{macrocode}
 \caption@ifpackage{listings}{lst@MakeCaption}{%
   \PackageInfo{caption}{listings package v1.2 (or newer) detected}%
+%    \end{macrocode}
 %
+% \begin{macro}{\lst@MakeCaption}
+%  To support the \package{listings} package we need to redefine
+%  |\lst@MakeCaption| so the original stuff is nested with
+%  |\caption@begin| and |\caption@end|.
+%    \begin{macrocode}
   \let\caption@lst@MakeCaption\lst@MakeCaption
   \def\lst@MakeCaption#1{%
-    \let\caption@setfloattype\caption@settype
+%    \end{macrocode}
+%
+% If the |position=| is set to |auto|, we take over the |captionpos=| setting
+% from the \package{listings} package.
+% Note that we won't do this otherwise, so \package{listings} settings like
+% |abovecaptionskip=0pt,belowcaptionskip=10pt,captionpos=t| will \emph{not}
+% cause different outputs with or without the \package{caption} package loaded.
+%    \begin{macrocode}
     \def\caption@autoposition{\caption@setposition{#1}}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
     \caption@begin{lstlisting}%
       \caption@lst@MakeCaption{#1}%
     \caption@end}%
+%    \end{macrocode}
+% \end{macro}
 %
+%    \begin{macrocode}
 }
 %    \end{macrocode}
 %
-% \subsubsection*{longtable package support}
+% \subsubsection*{\package{longtable} package support}
 %
 %    \begin{macrocode}
 \caption@ifpackage{longtable}{LT@makecaption}{%
   \PackageInfo{caption}{longtable package v3.15 (or newer) detected}%
+%    \end{macrocode}
 %
-% Original code:
-% \def\LT@makecaption#1#2#3{%
-%   \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
-%     % Based on article class "\@makecaption", "#1" is "\@gobble" in star
-%     % form, and "\@firstofone" otherwise.
-%     \sbox\@tempboxa{#1{#2: }#3}%
-%     \ifdim\wd\@tempboxa>\hsize
-%       #1{#2: }#3%
-%     \else
-%       \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
-%     \fi
-%     \endgraf\vskip\baselineskip}%
-%   \hss}}}
+% \begin{macro}{\LT@makecaption}
+% \changes{v3.0d}{2004/08/10}{Bugfix 04-08-04: \cs{abovecaptionskip} \& \cs{belowcaptionskip} will be used now}
+% \changes{v3.0e}{2005/05/05}{Bugfix: \cs{captionsetup[longtable]} overrides \cs{LTcapwidth} now}
+% \changes{v3.0h}{2005/10/07}{\cs{caption@LT@make} introduced}
+%  |\LT@makecaption|\marg{cmd}\marg{label}\marg{text}\par
+%  Original code:
+%  \begin{verbatim}
+%  \def\LT@makecaption#1#2#3{%
+%    \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
+%      % Based on article class "\@makecaption", "#1" is "\@gobble" in star
+%      % form, and "\@firstofone" otherwise.
+%      \sbox\@tempboxa{#1{#2: }#3}%
+%      \ifdim\wd\@tempboxa>\hsize
+%        #1{#2: }#3%
+%      \else
+%        \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
+%      \fi
+%      \endgraf\vskip\baselineskip}%
+%    \hss}}}
+%  \end{verbatim}
 %
+%    \begin{macrocode}
   \def\LT@makecaption#1#2#3{%
-%   \noalign{\vskip...}%
+    \caption@LT@make{%
+%    \end{macrocode}
 %
-    \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\hsize{%
+%  We set |\ifcaption@star| according the 1st argument.
+%    \begin{macrocode}
+      \caption@startrue#1\caption@starfalse
+%    \end{macrocode}
 %
-      \caption@letfloattype{longtable}{% bugfixed v3.0e
+%  If |\LTcapwidth| is not set to its default value |4in| we assume
+%  that it shall overwrite our own setting.
+%  (But |\captionsetup[longtable]{width=|\ldots|}| will overwrite |\LTcapwidth|.)
+%    \begin{macrocode}
+      \caption@letfloattype{longtable}{%
         \ifdim\LTcapwidth=4in \else
-          \caption@setwidth\LTcapwidth
+          \setcaptionwidth\LTcapwidth
         \fi}%
-%     \caption@setdefaultpos{t}% default = top
-      \let\caption@defaultpos\@firstoftwo% default = top
-      \def\caption@autoposition{% does not work within \end(last)foot!
+%    \end{macrocode}
+%
+%  The default |position=| setting for longtables is |top|.
+%  (This emulates the standard behaviour of the \package{longtable} package
+%   which has no skip above the caption but a skip below it.)
+%    \begin{macrocode}
+%     \caption@setdefaultpos{t}%
+      \let\caption@defaultpos\@firstoftwo
+%    \end{macrocode}
+%
+%  |position=auto| is a bad idea for longtables, but we do our very best.
+%  This works quite well for captions inside the longtable contents, but
+%  not for captions inside the longtable (end)foot.
+%    \begin{macrocode}
+      \def\caption@autoposition{%
         \caption@setposition{\ifcase\LT@rows t\else b\fi}}%
+%    \end{macrocode}
 %
+%    \begin{macrocode}
       \caption@begin{table}%
+%    \end{macrocode}
 %
-%       This skip has 2 purposes:
-%       1. Correct the heigth of the \parbox[t]. Usual it's the height of
-%          the very first line, but because of our extra skip it's always 0pt.
-%       2. Correct \arraystretch, which usually also affect the longtable
-%          caption. (If this is not requested, take \strutbox instead.)
-%       NOTE: This is only a quick workaround, it has to be revised later on.
-%
-        \vskip-\ht\@arstrutbox
+%  The following skip has the purpose to correct the height of the
+%  |\parbox[t]|. Usually it's the height of the very first line, but
+%  because of our extra skips (|\abovecaptionskip| and |\belowcaptionskip|)
+%  it's always |0pt|.
+%  (A different idea would be typesetting the first skip outside the longtable
+%   column with |\noalign{\vskip|\ldots|}|, but this means we have to move
+%   |\caption@begin| to some other place because it does not work in tabular
+%   mode\ldots)
+%    \begin{macrocode}
+        \vskip-\ht\strutbox
+%    \end{macrocode}
 %
+%  This should look familiar. We do our skips and use |\caption@@make| to
+%  typeset the caption itself.
+%    \begin{macrocode}
         \caption@iftop{\vskip\belowcaptionskip}{\vskip\abovecaptionskip}%
-%       \let\caption@beginbox\caption@beginLTbox
-        \caption@startrue#1\caption@starfalse
         \caption@@make{#2}{#3}\endgraf
         \caption@iftop{\vskip\abovecaptionskip}{\vskip\belowcaptionskip}%
-      \caption@end}%
+      \caption@end}}%
+%    \end{macrocode}
+% \end{macro}
 %
-    \hss}}}%
+% \begin{macro}{\caption@LT@make}
+%  Typesets the caption as centered |\multicolumn|\ldots
+%    \begin{macrocode}
+  \newcommand\caption@LT@make[1]{%
+    \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\hsize{#1}\hss}}}%
+%    \end{macrocode}
+% \end{macro}
 %
+%    \begin{macrocode}
 }
 %    \end{macrocode}
 %
-% \subsubsection*{rotating package support}
+% \subsubsection*{\package{picins} package support}
+% \changes{v3.0j}{2006/01/26}{Support of the \package{picins} package added}
+%
+%    \begin{macrocode}
+\caption@ifpackage{picins}{piccaption}{%
+  \PackageInfo{caption}{picins package v3.0 (or newer) detected}%
+%    \end{macrocode}
+%
+% \begin{macro}{\piccaption}
+%  Original code:
+%  \begin{verbatim}
+%  \def\piccaption{\@ifnextchar [{\@piccaption}{\@piccaption[]}}
+%  \end{verbatim}
+%    \begin{macrocode}
+  \def\piccaption{\@dblarg\@piccaption}
+% \def\piccaption{\caption@caption{\@dblarg\@piccaption}}
+%    \end{macrocode}
+% \end{macro}
+%
+% {\itshape TODO: Make |\piccaption[]{|\ldots|}| and |\piccaption{}| work}
+%
+%    \begin{macrocode}
+}
+%    \end{macrocode}
+%
+% \subsubsection*{\package{rotating} package support}
 %
 %    \begin{macrocode}
 \caption@ifpackage{rotating}{@rotcaption}{%
   \PackageInfo{caption}{rotating package v2.0 (or newer) detected}%
+%    \end{macrocode}
 %
-  \let\caption@rot\rotcaption
-  \def\rotcaption{\caption@caption\caption@rot}%
-%
-  \let\caption@@rot\@rotcaption
-  \long\def\@rotcaption#1[#2]#3{%
-    \caption@beginex{#1}{#2}%
-      \caption@@rot{#1}[{#2}]{#3}%
-    \caption@end}%
+% \begin{macro}{\rotcaption}
+% \changes{v3.0c}{2004/07/16}{Bugfix: Check for \cs{caption@caption} removed}
+% \changes{v3.0i}{2005/12/07}{Rewritten, works with \package{hyperref} now}
+%  Make |\rotcaption*| work.
+%    \begin{macrocode}
+  \def\rotcaption{\let\@makecaption\@makerotcaption\caption}%
+% \let\@rotcaption\@undefined
+%    \end{macrocode}
+% \end{macro}
 %
-% Original code:
-% \long\def\@makerotcaption#1#2{%
-%   \setbox\@tempboxa\hbox{#1: #2}%
-%   \ifdim \wd\@tempboxa > .8\vsize
-%     \rotatebox{90}{%
-%     \begin{minipage}{.8\textheight}#1: #2\end{minipage}%
-%     }\par
-%   \else%
-%     \rotatebox{90}{\box\@tempboxa}%
-%   \fi
-%   \hspace{12pt}%
-% }
+% \begin{macro}{\rotcaptionof}
+% \changes{v3.0i}{2005/12/07}{New}
+%  Make |\rotcaptionof(*)| work.
+%    \begin{macrocode}
+  \def\rotcaptionof{\@ifstar{\caption@of{\rotcaption*}}{\caption@of\rotcaption}}%
+%    \end{macrocode}
+% \end{macro}
 %
+% \begin{macro}{\@makerotcaption}
+% \changes{v3.0i}{2005/12/06}{Rewritten, should finally work proper now}
+%  Original (bugfixed) code:
+%  \begin{verbatim}
+%  \long\def\@makerotcaption#1#2{%
+%    \setbox\@tempboxa\hbox{#1: #2}%
+%    \ifdim \wd\@tempboxa > .8\vsize
+%      \rotatebox{90}{%
+%      \begin{minipage}{.8\textheight}#1: #2\end{minipage}%
+%      }%\par   % <== \par removed (AR)
+%    \else%
+%      \rotatebox{90}{\box\@tempboxa}%
+%    \fi
+%    \nobreak\hspace{12pt}% <== \nobreak added (AR)
+%  }
+%  \end{verbatim}
+%  Our version emulates this behaviour, but if |width=| is set,
+%  the rotated caption is always typeset as |minipage|.
+%  (Note that |margin=| is not supported here.)
+%    \begin{macrocode}
   \long\def\@makerotcaption#1#2{%
-    \rotatebox{90}{%
-      \begin{minipage}{.8\textheight}%
-        \caption@@make{#1}{#2}%
-      \end{minipage}%
-    }\par
-    \hspace{12pt}}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+    \ifdim\captionwidth=\z@
+      \setcaptionwidth{.8\textheight}%
+      \caption@slc{#1}{#2}{.8\vsize}{%
+        \let\caption@makerot\caption@@make
+        \setcaptionmargin\z@
+%       \setlength\captionindent\z@
+%       \def\caption@startbox##1{\hbox\bgroup\hsize=.8\textheight}%
+%       \def\caption@endbox{\egroup}%
+%         (not needed because \rotatebox uses an \hbox anyway)
+        \let\caption@startbox\@gobble
+        \let\caption@endbox\relax}%
+      \caption@setbool{slc}{0}% been there, done that
+    \fi
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+    \rotatebox{90}{\caption@makerot{#1}{#2}}%
+    \nobreak\hspace{12pt}}%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+  \newcommand\caption@makerot[2]{%
+    \begin{minipage}\captionwidth\caption@@make{#1}{#2}\end{minipage}}%
+%    \end{macrocode}
+% \end{macro}
 %
+%    \begin{macrocode}
 }
 %    \end{macrocode}
 %
-% \subsubsection*{sidecap package support}
+% \subsubsection*{\package{sidecap} package support}
 %
 %    \begin{macrocode}
 \caption@ifpackage{sidecap}{endSC@FLOAT}{%
   \PackageInfo{caption}{sidecap package v1.4d (or newer) detected}%
+%    \end{macrocode}
 %
-% First of all, we let sidecap use an actual definition of \caption:
-% (This is only required for version 1.5d of the sidecap package.)
-%
-  \let\SC@caption=\caption
-%
-% Make \caption* and local settings (\captionsetup) work
+% \begin{macro}{\SC@caption}
+% \changes{v3.0d}{2004/11/28}{Bugfix: Definition of \cs{@captype} added}
+% \changes{v3.0e}{2005/05/05}{Bugfix: Empty captions are handled correctly now}
+% \changes{v3.0e}{2005/05/05}{Priority of options fixed}
+% \changes{v3.0h}{2005/10/03}{Bugfix: Always use \cs{AtBeginDocument} to set \cs{SC@caption}}
+%  First of all, we let sidecap use an actual definition of |\caption|.\\
+%  (This is only required for version 1.5d of the sidecap package.)
+%    \begin{macrocode}
+  \@ifundefined{caption@caption}%
+    {\let\caption@tempa\AtBeginDocument}%
+    {\let\caption@tempa\@firstofone}%
+  \caption@tempa{\let\SC@caption=\caption}%
+%    \end{macrocode}
+% \end{macro}
 %
+% \begin{macro}{\SC@zfloat}
+% \changes{v3.0b}{2004/05/16}{Local definition of \cs{captionsetup} added}
+% \changes{v3.0c}{2004/07/16}{Bugfix 04-07-15: Check for \cs{caption@caption} removed}
+%  This macro will be called at the start of the environment, here is a good
+%  opportunity to do some adaptations to |\caption| and |\captionsetup|.
+%    \begin{macrocode}
   \let\caption@SC@zfloat\SC@zfloat
   \def\SC@zfloat#1#2#3[#4]{%
-% #2 = `figure' or `table' => \SC@captype
+%    \end{macrocode}
+%
+%  Note: |#2| is either |figure| or |table| and will be stored to |\SC@captype|
+%  by the original version of |\SC@zfloat|.
+%    \begin{macrocode}
     \caption@SC@zfloat{#1}{#2}{#3}[#4]%
+%    \end{macrocode}
 %
+%  Since the sidecap package uses our |\caption| code outside the
+%  floating environment the regular |\captionsetup| will not work.
+%  So we need a special version here which saves the given argument list
+%  which will be executed later on.
+%    \begin{macrocode}
     \global\let\SC@CAPsetup\@empty
     \def\captionsetup##1{\g@addto@macro\SC@CAPsetup{,##1}}%
+%    \end{macrocode}
 %
+%  Make |\caption*| work.
+%    \begin{macrocode}
     \let\caption@old\caption
 %   \def\caption{\renewcommand\captionsetup[1]{}\caption@caption\caption@old}%
     \def\caption{\caption@caption\caption@old}%
   }%
+%    \end{macrocode}
+% \end{macro}
 %
-% Before typesetting the caption, we set the captionmargin to zero
-% because the extra margin is only disturbing here.
-% (We don't need to take care about the caption position because
-%  the sidecap package set both \abovecaptionskip and \belowcaptionskip
-%  to a skip of zero anyway.)
-% Furthermore \SC@justify will override the caption justification, if set.
-%
-% Very old version (1.4): \SC@justify is not defined
-% Older versions (1.5): \SC@justify is \relax when not set
-% Newer versions (1.6): \SC@justify is \@empty when not set
-%
+% \begin{macro}{\endSC@FLOAT}
+% \changes{v3.0i}{2006/01/12}{\cs{@listdepth}\cs{z@} added}
+%  This macro will be called at the end of the environment, here we need to
+%  setup our stuff before the \package{sidecap} package actually typesets
+%  its caption.
+%    \begin{macrocode}
   \let\caption@endSC@FLOAT\endSC@FLOAT
   \def\endSC@FLOAT{%
-%   (Note that \@captype isn't defined so far, this will be done inside
-%    the original definition of \endSC@FLOAT.)
-%   We set \@captype already here, so \captionsetup will
-%   work with \@captype-based options, too. (new v3.0d)
+%    \end{macrocode}
+%
+%  Note that |\@captype| isn't defined so far, this will be done inside
+%  the original definition of |\endSC@FLOAT|.
+%  But we define |\@captype| already here to make |\captionsetup| work
+%  with |\@captype|-based options (like |type=|).
+%    \begin{macrocode}
     \let\@captype\SC@captype
+%    \end{macrocode}
+%
+%  Here we execute the options set with |\captionsetup| inside this environment.
+%    \begin{macrocode}
     \caption@esetup\SC@CAPsetup
+%    \end{macrocode}
 %
-    \caption@letfloattype{SC\@captype}{% bugfixed v3.0e
-      \caption@setmargin\z@
+%  Before we can typeset the caption we need to set the margin to zero
+%  because any extra margin would only be disturbing here.\par
+%  (We don't need to take care about the caption position because
+%   the sidecap package set both |\abovecaptionskip| and |\belowcaptionskip|
+%   to a skip of zero anyway.)\par
+%  Furthermore |\SC@justify| will override the caption justification, if set.
+%  The usage of |\SC@justify| differs from version to version of the
+%  \package{sidecap} package:\par
+%  \begin{tabular}{ll}
+%    Version 1.4: & |\SC@justify| is not defined\\
+%    Version 1.5: & |\SC@justify| is |\relax| when not set\\
+%    Version 1.6: & |\SC@justify| is |\@empty| when not set\\
+%  \end{tabular}
+%    \begin{macrocode}
+    \caption@letfloattype{SC\@captype}{%
+      \@listdepth\z@
+      \setcaptionmargin\z@
       \@ifundefined{SC@justify}{}{%
         \ifx\SC@justify\@empty\else
           \let\caption@hj\SC@justify
           \let\SC@justify\@empty
         \fi}}%
+%    \end{macrocode}
 %
-    \long\def\caption@ifempty##1{% bugfix v3.0e
+%  We adapt |\caption@ifempty| so |\caption{}| will work within these
+%  environments, too.
+%    \begin{macrocode}
+    \long\def\caption@ifempty##1{%
       \ifx\SC@CAPtext\@empty
         \expandafter\@firstofone
       \else
         \expandafter\@gobble
       \fi}%
+%    \end{macrocode}
+%
+% \iffalse % Does not work anyway...
+%  Furthermore we adapt |\caption@ifnocontentsline| so |\caption[]{|\ldots|}|
+%  will work within these environments, too.
+%    \begin{macrocode}
+%   \long\def\caption@ifnocontentsline##1{%
+%     \ifx\SC@OPTCAPtext\@empty
+%       \expandafter\@firstofone
+%     \else
+%       \expandafter\@gobble
+%     \fi}%
+%    \end{macrocode}
+% \fi
 %
+%  Finally we call the original definition of |\endSC@FLOAT| which will
+%  call our version of |\caption| to typeset the caption.
+%    \begin{macrocode}
     \caption@endSC@FLOAT}%
+%    \end{macrocode}
+% \end{macro}
 %
+%    \begin{macrocode}
 }
 %    \end{macrocode}
 %
-% \subsubsection*{supertabular package support}
+% \subsubsection*{\package{supertabular} package support}
 %
+% \begin{macro}{\caption@setSTposition}
+%  The |position=| setting will be overwritten by the
+%  \package{supertabular} package: If |\topcaption| is used,
+%  the position will be |top| automatically, |bottom| otherwise.
 %    \begin{macrocode}
 \def\caption@setSTposition{%
   \caption@setposition{\if@topcaption t\else b\fi}}
+%    \end{macrocode}
+% \end{macro}
 %
+%    \begin{macrocode}
 \caption@ifpackage{supertabular}{ST@caption}{%
   \PackageInfo{caption}{supertabular package detected}%
+%    \end{macrocode}
 %
-% Improvement v3.0e: \topcaption* and \bottomcaption*
+% \begin{macro}{\tablecaption}
+% \changes{v3.0e}{2005/05/05}{Made \cs{topcaption*} and \cs{bottomcaption*} work}
+%  Make |\topcaption*| and |\bottomcaption*| work.
+%    \begin{macrocode}
   \let\caption@tablecaption\tablecaption
   \def\tablecaption{\caption@caption\caption@tablecaption}%
+%    \end{macrocode}
+% \end{macro}
 %
-% Original code:
-% \long\def\ST@caption#1[#2]#3{\par%
-%   \addcontentsline{\csname ext@#1\endcsname}{#1}%
-%                   {\protect\numberline{%
-%                       \csname the#1\endcsname}{\ignorespaces #2}}
-%   \begingroup
-%     \@parboxrestore
-%     \normalsize
-%     \if@topcaption \vskip -10\p@ \fi
-%     \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
-%     \if@topcaption \vskip 10\p@ \fi
-%   \endgroup}
-%
+% \begin{macro}{\ST@caption}
+% \changes{v3.0a}{2004/01/23}{Bugfix: Missing \cs{par} added}
+%  Original code:
+%  \begin{verbatim}
+%  \long\def\ST@caption#1[#2]#3{\par%
+%    \addcontentsline{\csname ext@#1\endcsname}{#1}%
+%                    {\protect\numberline{%
+%                        \csname the#1\endcsname}{\ignorespaces #2}}
+%    \begingroup
+%      \@parboxrestore
+%      \normalsize
+%      \if@topcaption \vskip -10\p@ \fi
+%      \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
+%      \if@topcaption \vskip 10\p@ \fi
+%    \endgroup}
+%  \end{verbatim}
+%    \begin{macrocode}
   \let\caption@ST\ST@caption
-  \long\def\ST@caption#1[#2]#3{\par%  bugfixed v3.0a
+  \long\def\ST@caption#1[#2]#3{\par%
     \caption@letfloattype{supertabular}{}%
     \let\caption@fixposition\caption@setSTposition
     \caption@beginex{#1}{#2}%
@@ -3773,7 +4780,10 @@
       \normalsize
       \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
     \caption@end}%
+%    \end{macrocode}
+% \end{macro}
 %
+%    \begin{macrocode}
 }
 %    \end{macrocode}
 %
-- 
cgit v1.2.3

