% \iffalse meta-comment
% 
% This is file `caption2.dtx'.
% 
% Copyright (C) 1994-2008 Axel Sommerfeldt (caption@sommerfee.de)
% 
% --------------------------------------------------------------------------
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% This Current Maintainer of this work is Axel Sommerfeldt.
% 
% This work consists of the files caption.ins, caption.dtx, caption2.dtx,
% ltcaption.dtx, and subcaption.dtx, the derived files caption.sty,
% caption2.sty, caption3.sty, ltcaption.sty, and subcaption.sty, and the
% user manuals caption-deu.tex, caption-eng.tex, and caption-rus.tex.
% 
% \fi
% \CheckSum{848}
%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesFile{caption2.drv}%
  [2007/11/28 v2.2 Documentated code of the (obsolete) caption2 package]
\hbadness=9999 \newcount\hbadness \hfuzz=100pt % Make TeX shut up.
%\errorcontextlines=3
%
\documentclass{ltxdoc}
\setlength\parindent{0pt}
\setlength\parskip{\smallskipamount}
%
\usepackage{ifpdf}
\ifpdf
  \usepackage{mathptmx,courier}
  \usepackage[scaled=0.90]{helvet}
% \addtolength\marginparwidth{15pt}
\fi
%
\usepackage{hypdoc}
\ifpdf\usepackage{hypdestopt}\fi
\hypersetup{pdfkeywords={LaTeX, package, caption2},pdfstartpage={},pdfstartview={}}
%
\usepackage{caption2}[2008/07/01]
%
%<+driver>\OnlyDescription
%
\begin{document}
  \DocInput{caption2.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}}
% \let\package\puresf\def\thispackage{\package{caption2}}
% \let\env\purett \let\opt\purett
%
% \GetFileInfo{caption2.drv}
% \let\docdate\filedate
% \GetFileInfo{caption2.sty}
%
% \title{The (obsolete) \texorpdfstring{\package{caption2} package\thanks{%^^A
%          This package has version number \fileversion, last revised \filedate.}}%^^A
%        {caption2 package}}
% \author{Axel Sommerfeldt\\
%         \href{mailto:caption@sommerfee.de}{\texttt{caption@sommerfee.de}}}
% \date{\docdate}
% \maketitle
%
% \changes{v2.0}{1995/10/09}{New experimental version: Many new commands and features}
% \changes{v2.0}{1995/10/09}{Support of the longtable package added}
% \changes{v2.1}{2002/02/20}{Revised: New commands and options}
% \changes{v2.1}{2002/02/26}{Adapted to version 2.1 of the subfigure package}
% \changes{v2.1a}{2003/11/12}{Some minor bug fixes and improved compatibility to v2.0}
% \changes{v2.1b}{2004/04/16}{Some minor bug fixes and improved compatibility to v2.0}
% \changes{v2.1c}{2004/05/10}{Some minor bug fixes and improved compatibility to v2.0}
% \changes{v2.1d}{2005/10/03}{Some superfluous brackets removed; warning added}
% \changes{v2.2}{2007/04/06}{Uses the caption3 kernel now}
%
% \providecommand\LaTeXcomp{The \LaTeX{} Companion}
%
% \section*{THIS PACKAGE IS OBSOLETE!}
%
% The \package{caption2} package used to be an experimental side-version of
% the regular \package{caption} package. It was made public as beta test version
% without documentation in 1995 because of the strong demand for new features and
% adaptations to other packages like the \package{longtable} and
% \package{subfigure} package.
%
% But within the next years I found no time to reintegrate some of the
% well-tried features into the regular \package{caption} package. So I
% decided to release a version $2.1$ of the \package{caption2} package in 2002
% instead, which included some minor bug fixes and adaptations to the new
% version $2.1$ of the \package{subfigure} package. Furthermore I started
% to write a documentation for this package, but unfortunately did not get
% very far with this\ldots
%
% In 2003 I finally found some (more) time, so a new regular release $3.0$
% of the \package{caption} package could be build in cooperation with
% Frank Mittelbach and Steven Cochran.
% It was released in December 2003 and superseded the neglected
% \package{caption2} package.
%
% {\small (In parallel, Steven Cochran released the \package{subfig} package which
% superseded the \package{subfigure} package.)}
%
% So please don't use this package for new documents. It's old, it's obsolete
% and it starts to begin smell bad!
% Please ignore all hints in books or other documents which try to tell you
% that the \package{caption2} package should be used instead of the
% \package{caption} package -- these hints are outdated since December 2003.
%
% \vfill
% \bigskip
% \pagebreak[4]
%
% \section*{How to migrate to the regular \package{caption} package?}
%
% Usually replacing \package{caption2} by \package{caption} is sufficient
% because the \package{caption} package emulates most of the options and
% commands offered by the \package{caption2} package.
% If you get some errors or wired results afterwards, please take a closer
% look at the \package{caption} package documentation which will hopefully
% help you clearing these problems. You will also find a section called
% `Compatibility to older versions' there which should help you with the
% migration process.
% If all this should fail you can write me an e-mail asking for help.
%
% \section*{What will happen to this package?}
%
% The \package{caption2} package is still some kind of supported, that means
% it will be part of future releases of the \package{caption} package bundle,
% and bugs will still be fixed so existing documents using this package will
% still compile.
% But it will \emph{not} be enhanced in the future.
%
% This means migrating to the actual \package{caption} package should not be
% necessary for old documents -- they should still compile fine as they are.
% If not, please don't hesitate to write me an e-mail asking for
% maintainance.
%
% \StopEventually{}
%
% \DoNotIndex{\\,\_,\ ,\@@par}
% \DoNotIndex{\@bsphack}
% \DoNotIndex{\@car,\@cdr,\@classoptionslist,\@cons,\@currext,\@currname}
% \DoNotIndex{\@ehc,\@ehd,\@empty,\@esphack,\@expandtwoargs}
% \DoNotIndex{\@for,\@firstofone,\@firstoftwo}
% \DoNotIndex{\@gobble,\@gobblefour,\@gobbletwo,\@hangfrom}
% \DoNotIndex{\@ifnextchar,\@ifstar,\@ifundefined,\@latex@error}
% \DoNotIndex{\@namedef,\@nameuse}
% \DoNotIndex{\@onlypreamble,\@parboxrestore,\@plus,\@ptionlist}
% \DoNotIndex{\@removeelement,\@restorepar,\@secondoftwo,\@setpar}
% \DoNotIndex{\@tempa,\@tempboxa,\@tempdima,\@tempb,\@tempc}
% \DoNotIndex{\@undefined,\@unprocessedoptions,\@unusedoptionlist}
% \DoNotIndex{\p@,\z@}
% \DoNotIndex{\active,\addtocounter,\addtolength,\advance}
% \DoNotIndex{\baselineskip,\begin,\begingroup,\bfseries,\bgroup,\box}
% \DoNotIndex{\catcode,\centering,\changes,\csname,\def,\divide,\do,\downarrow}
% \DoNotIndex{\edef,\egroup,\else,\empty,\end,\endcsname,\endgraf,\endgroup,\expandafter}
% \DoNotIndex{\fi,\footnotesize,\global}
% \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
% \DoNotIndex{\if,\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
% \DoNotIndex{\ifx,\ignorespaces,\itshape}
% \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
% \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
% \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
% \DoNotIndex{\next,\nobreakspace,\noexpand,\noindent,\numberline}
% \DoNotIndex{\normalsize,\or,\par,\parbox,\parfillskip}
% \DoNotIndex{\parindent,\parskip,\prevdepth,\protect,\protected@edef,\providecommand}
% \DoNotIndex{\quad}
% \DoNotIndex{\raggedleft,\raggedright,\relax,\renewcommand,\RequirePackage}
% \DoNotIndex{\rightskip,\rmfamily}
% \DoNotIndex{\sbox,\scriptsize,\scshape,\setbox,\setlength,\sffamily,\slshape}
% \DoNotIndex{\small,\string,\space,\strut}
% \DoNotIndex{\textheight,\the,\toks@,\typeout,\ttfamily}
% \DoNotIndex{\undefined,\unvbox,\uparrow,\upshape,\usebox,\usepackage}
% \DoNotIndex{\vbox,\vsize,\vskip,\wd,\width,\z@skip}
% \DoNotIndex{\AtBeginDocument,\AtEndOfPackage,\CurrentOption,\DeclareOption}
% \DoNotIndex{\ExecuteOptions,\GenericWarning,\IfFileExists,\InputIfFileExists}
% \DoNotIndex{\NeedsTeXFormat,\MessageBreak}
% \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
% \DoNotIndex{\ProcessOptions,\ProvidesPackage}
%
% \clearpage
%
% \section{The Implementation}
% \iffalse
%<*package>
% \fi
%
% \subsection{Identificaton}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{caption2}[2008/07/01 v2.2c Customising captions (AS)]
%    \end{macrocode}
%
% \changes{v2.2b}{2007/06/15}{Made obsolete warning even more annoying}
%    \begin{macrocode}
\PackageWarning{caption2}{%
  ****************************************************\MessageBreak
  THIS PACKAGE IS OBSOLETE:\MessageBreak
  This package attempts to provide an `caption2'\MessageBreak
  package v2.0/2.1 author environment so that OLD\MessageBreak
  documents can be successfully processed. It should\MessageBreak
  NOT be used for NEW documents! New documents should\MessageBreak
  use the regular `caption' package v3.x instead.\MessageBreak
  ****************************************************\@gobbletwo}%
%    \end{macrocode}
%
% \subsection{Loading the caption3 kernel}
%
%    \begin{macrocode}
\RequirePackage{caption3}[2007/09/01] % needs v3.1 or newer
%    \end{macrocode}
%
% \subsection{Check against the regular caption package}
% \changes{v2.2}{2007/04/06}{Check against regular \package{caption} package added}
% \changes{v2.2a}{2007/04/11}{Bugfix: Usage of \cs{caption@error} replaced by \cs{PackageError}}
%
%    \begin{macrocode}
\@ifpackageloaded{caption}{%
  \PackageError{caption2}{%
    You can't use both, the (current) caption *and*\MessageBreak
    the (obsolete) caption2 package}\caption@eh
  \endinput
}{}
%    \end{macrocode}
%
% \subsection{Preliminary declarations}
%
% \begin{macro}{\captionlabeldelim}
% \begin{macro}{\captionlabelsep}
% \cs{captionlabeldelim} \& \cs{captionlabelsep} will hold the iterim
% space between caption label and text.
% (\cs{captionlabeldelim} will be typeset within \cs{captionlabelfont},
%  \cs{captionlabelsep} not.)
%    \begin{macrocode}
\newcommand*\captionlabeldelim{}
\newcommand*\captionlabelsep{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifcaptionwidth}
% Either \cs{captionmargin} (with specifies an extra margin) or \cs{captionwidth}
% (with specifies an explicit width) can be set, therefore we need the flag \cs{ifcaptionwidth}
% to determine with parameter we should pay attention to.
%    \begin{macrocode}
\newcommand*\ifcaptionwidth{\ifdim\captionwidth>\z@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\captionindent}
% \changes{v2.2b}{2007/08/12}{Re-added since the \package{caption3} kernel uses \cs{caption@indent} now}
% \cs{captionindent} will be used in caption style \texttt{indent} and specifies the indention
% after the first line.
%    \begin{macrocode}
\let\captionindent\caption@indent
%    \end{macrocode}
% \end{macro}
%
% \changes{v2.1}{2002/02/20}{New ifs \cs{ifcaptionlabel} and \cs{ifignoreLTcapwidth}}
%
% \begin{macro}{\ifcaptionlabel}
% If \cs{ifcaptionlabel} is not set the caption label should be suppressed;
% we need this flag to support the \cs{caption*} command.
% \changes{v2.2}{2007/04/06}{New definition, based on \cs{ifcaption@star}}
%    \begin{macrocode}
\def\ifcaptionlabel{%
  \ifcaption@star
    \@tempswafalse
  \else
    \@tempswatrue
  \fi
  \if@tempswa}
\def\captionlabeltrue{\caption@starfalse}
\def\captionlabelfalse{\caption@startrue}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifonelinecaptions}
% If \cs{ifonelinecaptions} is set we support the \LaTeX\ base style 'one line captions',
% that means the caption will be typeset centered if it fits to one line.
% \changes{v2.2}{2007/04/06}{New definition, based on \cs{caption@ifslc}}
%    \begin{macrocode}
\def\ifonelinecaptions{%
  \caption@ifslc{\@tempswatrue}{\@tempswafalse}%
  \if@tempswa}
\def\onelinecaptionstrue{\caption@setbool{slc}{1}}
\def\onelinecaptionsfalse{\caption@setbool{slc}{0}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifignoreLTcapwidth}
% If \cs{ifignoreLTcapwidth} is set we ignore the \cs{LTcapwidth} of \textsf{longtable}.
%    \begin{macrocode}
\newif\ifignoreLTcapwidth
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalcaptionparams}
% \cs{normalcaptionparams} resets all caption related parameters to it's normal default values.
% \cs{captionfont} will be set to \cs{captionsize} so setting the obsolete \cs{captionsize} will still work.
% Same story with \cs{captiondelim} and the obsolete \cs{captionlabeldelim}.
% \changes{v2.1}{2002/01/29}{New command \cs{normalcaptionparams}}
%    \begin{macrocode}
\newcommand*\normalcaptionparams{%
  \let\captionsize\@empty
  \renewcommand*\captionfont{\captionsize}%
  \let\captionlabelfont\@empty
  \renewcommand*\captionlabeldelim{:}%
  \renewcommand*\captionlabelsep{\space}%
  \setcaptionmargin\z@
  \setlength\captionindent\z@
  \onelinecaptionstrue}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\defcaptionstyle}
% \begin{macro}{\newcaptionstyle}
% \begin{macro}{\renewcaptionstyle}
% These macros will define a new caption style. \cs{newcaptionstyle} and \cs{renewcaptionstyle}
% will additionally check if the caption style already exists or not.
%    \begin{macrocode}
\newcommand*\defcaptionstyle[1]{%
  \@namedef{caption@@#1}}
%
\newcommand*\newcaptionstyle[1]{%
  \expandafter\ifx\csname caption@@#1\endcsname\relax
    \expandafter\defcaptionstyle
  \else
    \PackageError{caption2}{Caption style `#1' already defined}{\caption@eh}%
    \expandafter\@gobbletwo
  \fi
  {#1}}
%
\newcommand*\renewcaptionstyle[1]{%
  \expandafter\ifx\csname caption@@#1\endcsname\relax
    \PackageError{caption2}{Caption style `#1' undefined}{\caption@eh}%
    \expandafter\@gobbletwo
  \else
    \expandafter\defcaptionstyle
  \fi
  {#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\dummycaptionstyle}
% This macro will also define a new caption style, but a one which is based on the
% actual set caption style. Therefore you can't set a caption style made with this
% command with \cs{captionstyle} -- we check this to avoid an endless recursion.
%    \begin{macrocode}
\newcommand*\dummycaptionstyle[2]{%
  \defcaptionstyle{#1}{%
    \expandafter\ifx\csname caption@@\caption@style\expandafter\endcsname%
                    \csname caption@@#1\endcsname
      \PackageError{caption2}{You can't use the caption style `#1' directy}{%
        The caption style `#1' is only a dummy and does not really exists.%
        \MessageBreak You have to redefine it (with \protect\renewcaptionstyle)
        before you can select\MessageBreak it with \protect\captionstyle.
        \space\caption@eh}%
    \else
      #2\usecaptionstyle\caption@style
    \fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\captionstyle}
% \cs{captionstyle} sets the actual caption style. It includes a check if the given caption
% style is defined or not.
%    \begin{macrocode}
\newcommand*\captionstyle[1]{%
  \expandafter\ifx\csname caption@@#1\endcsname\relax
    \PackageError{caption2}{Undefined caption style `#1'}{\caption@eh}%
  \else
    \def\caption@style{#1}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{style `normal'}
% \begin{macro}{style `center'}
% \begin{macro}{style `centerlast'}
% \begin{macro}{style `flushleft'}
% \begin{macro}{style `flushright'}
% \begin{macro}{style `hang'}
% \begin{macro}{style `indent'}
% The predefined caption styles `normal', `center', `flushleft', `flushright', `centerlast',
% `hang', `hang+X', and `indent'. Because they are quite similar they all are based on the macro
% \cs{caption@make}.
%    \begin{macrocode}
\newcaptionstyle{normal}{\caption@make{normal}}
\newcaptionstyle{center}{\caption@make{center}}
\newcaptionstyle{centerlast}{\caption@make{centerlast}}
\newcaptionstyle{flushleft}{\caption@make{flushleft}}
\newcaptionstyle{flushright}{\caption@make{flushright}}
\newcaptionstyle{hang}{\caption@make{hang}}
\newcaptionstyle{hang+center}{\caption@make{hang@center}}
\newcaptionstyle{hang+centerlast}{\caption@make{hang@centerlast}}
\newcaptionstyle{hang+flushleft}{\caption@make{hang@flushleft}}
\newcaptionstyle{indent}{\caption@make{indent}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\caption@makecaption}
% Our predefined caption styles. \cs{caption@makecaption} takes the style
% name as parameter, it does the common stuff and calls a macro
% (build out of the style name) to do the uncommon stuff if neccessary.
% \changes{v2.1}{2002/02/26}{Renamed from \cs{caption@make} to \cs{caption@makecaption}}
% \changes{v2.1b}{2004/04/16}{We offer and use \cs{caption@make}, again}
% \changes{v2.1c}{2004/05/10}{Bugfix: Extra \cs{par} added}
%    \begin{macrocode}
\newcommand*\caption@makecaption[1]{%
  \usecaptionmargin
%    \end{macrocode}
%    \begin{macrocode}
  \ifcaptionlabel
    \def\caption@label{%
      {\captionlabelfont\captionlabel\captionlabeldelim}\captionlabelsep}%
  \else
    \let\caption@label\@empty
  \fi
%    \end{macrocode}
%    \begin{macrocode}
  \captionfont
  \onelinecaption
    {\caption@label\captiontext}%
    {\parbox[b]\captionlinewidth{\strut\@nameuse{caption@@@#1}\par}\par}}
%    \end{macrocode}
% \end{macro}
%
% \changes{v2.1}{2002/02/26}{Removed all extra parboxes from caption styles}
% \changes{v2.1a}{2003/11/12}{\ldots and put the parbox into \cs{caption@makecaption} instead}
%
% \begin{macro}{\caption@@@normal}
% The `normal' caption style. Just typeset caption (label \& text) as paragraph.
%    \begin{macrocode}
\newcommand*\caption@@@normal{%
  \caption@label\captiontext}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@center}
% The `center' caption style. Typeset the caption centered within a parbox.
%    \begin{macrocode}
\newcommand*\caption@@@center{%
  \centering\caption@label\captiontext}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@centerlast}
% The `centerlast' caption style.
% The idea how to do this was taken from Br\"uggemann-Klein\cite{Anne},
% it is also mentioned in Kopka\cite[p227]{Kopka-E}.
%    \begin{macrocode}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\caption@@@centerlast{%
  \centerlast\caption@label\captiontext}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@flushleft}
% The `flushleft' caption style. Typeset the caption raggedright within a parbox.
%    \begin{macrocode}
\newcommand*\caption@@@flushleft{%
  \raggedright\caption@label\captiontext}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@flushright}
% The `flushright' caption style. Typeset the caption raggedleft within a parbox.
%    \begin{macrocode}
\newcommand*\caption@@@flushright{%
  \raggedleft\caption@label\captiontext}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@hang}
% \begin{macro}{\caption@hangplus}
% The `hang' caption style.
% This code was taken from \LaTeXcomp\cite[p155]{A-W:GMS94} and modified.
%    \begin{macrocode}
\newcommand*\caption@@@hang{%
  \sbox\@tempboxa{\caption@label}%
  \hangindent\wd\@tempboxa\noindent
  \usebox\@tempboxa\caption@hangplus\captiontext}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\caption@hangplus{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\caption@@@hang@center}
% The `hang+flushleft' caption style.
%    \begin{macrocode}
\newcommand*\caption@@@hang@center{%
  \let\caption@hangplus\centering\caption@@@hang}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@hang@centerlast}
% The `hang+flushleft' caption style.
%    \begin{macrocode}
\newcommand*\caption@@@hang@centerlast{%
  \let\caption@hangplus\centerlast\caption@@@hang}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@hang@flushleft}
% The `hang+flushleft' caption style.
%    \begin{macrocode}
\newcommand*\caption@@@hang@flushleft{%
  \let\caption@hangplus\raggedright\caption@@@hang}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@@@indent}
% The `indent' caption style. Is is quite like the `hang' style but the
% indention is given as \cs{captionindent}.
%    \begin{macrocode}
\newcommand*\caption@@@indent{%
  \hangindent\captionindent\noindent
  \caption@label\captiontext}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Declaration of options}
%
% \begin{macro}{normal}
% \begin{macro}{center}
% \begin{macro}{centerlast,anne}
% \begin{macro}{flushleft}
% \begin{macro}{flushright}
% \begin{macro}{hang,isu}
% \begin{macro}{indent}
% These options will set the caption style.
% (`normal' is the default one.)
%
% The options `anne' and `isu' are for
% backward compatibility only.
%    \begin{macrocode}
\DeclareOption{normal}{\captionstyle{normal}}
\DeclareOption{center}{\captionstyle{center}}
\DeclareOption{centerlast}{\captionstyle{centerlast}}
\DeclareOption{flushleft}{\captionstyle{flushleft}}
\DeclareOption{flushright}{\captionstyle{flushright}}
\DeclareOption{anne}{\ExecuteOptions{centerlast}}
\DeclareOption{hang}{\captionstyle{hang}}
\DeclareOption{hang+center}{\captionstyle{hang+center}}
\DeclareOption{hang+centerlast}{\captionstyle{hang+centerlast}}
\DeclareOption{hang+flushleft}{\captionstyle{hang+flushleft}}
\DeclareOption{isu}{\ExecuteOptions{hang}}
\DeclareOption{indent}{\captionstyle{indent}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{scriptsize}
% \begin{macro}{footnotesize}
% \begin{macro}{small}
% \begin{macro}{normalsize}
% \begin{macro}{large,Large}
% These options will set the caption size. We use \cs{g@addto@macro} so more that one
% option can be set.
%    \begin{macrocode}
\DeclareOption{scriptsize}{\g@addto@macro\captionsize\scriptsize}
\DeclareOption{footnotesize}{\g@addto@macro\captionsize\footnotesize}
\DeclareOption{small}{\g@addto@macro\captionsize\small}
\DeclareOption{normalsize}{\g@addto@macro\captionsize\normalsize}
\DeclareOption{large}{\g@addto@macro\captionsize\large}
\DeclareOption{Large}{\g@addto@macro\captionsize\Large}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{up,it,sl,sc}
% \begin{macro}{md,bf}
% \begin{macro}{rm,sf,tt}
% These options will set the caption label.
%    \begin{macrocode}
\DeclareOption{up}{\g@addto@macro\captionlabelfont\upshape}
\DeclareOption{it}{\g@addto@macro\captionlabelfont\itshape}
\DeclareOption{sl}{\g@addto@macro\captionlabelfont\slshape}
\DeclareOption{sc}{\g@addto@macro\captionlabelfont\scshape}
\DeclareOption{md}{\g@addto@macro\captionlabelfont\mdseries}
\DeclareOption{bf}{\g@addto@macro\captionlabelfont\bfseries}
\DeclareOption{rm}{\g@addto@macro\captionlabelfont\rmfamily}
\DeclareOption{sf}{\g@addto@macro\captionlabelfont\sffamily}
\DeclareOption{tt}{\g@addto@macro\captionlabelfont\ttfamily}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{oneline}
% \begin{macro}{nooneline}
% These options will set the `oneline' flag.
% (`oneline' is the default.)
%    \begin{macrocode}
\DeclareOption{oneline}{\onelinecaptionstrue}
\DeclareOption{nooneline}{\onelinecaptionsfalse}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\caption@setpackage}
% A helper macro, a value of 1 within parameter \#2 will activate the support
% of the package given in parameter \#1, a value of 0 will deactivate it.
%    \begin{macrocode}
\newcommand*\caption@setpackage[1]{\@namedef{caption@pkt@#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{float}
% \begin{macro}{longtable}
% \begin{macro}{subfigure}
% \changes{v2.1}{2002/02/19}{New options for interaction with other packages}
% These options will enable or suppress the support of the packages
% \textsf{float}, \textsf{longtable}, and \textsf{subfigure}.
%    \begin{macrocode}
\DeclareOption{float}{%
  \caption@twozerofalse\caption@setpackage{float}{1}}
\DeclareOption{longtable}{%
  \caption@twozerofalse\caption@setpackage{longtable}{1}}
\DeclareOption{subfigure}{%
  \caption@twozerofalse\caption@setpackage{subfigure}{1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{none}
% \begin{macro}{all}
% These options will enable or suppress the support of all the above packages.
%    \begin{macrocode}
\DeclareOption{none}{\caption@twozerofalse
  \caption@setpackage{float}{0}\caption@setpackage{longtable}{0}%
  \caption@setpackage{subfigure}{0}}
\DeclareOption{all}{\ExecuteOptions{float,longtable,subfigure}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{ruled}
% \begin{macro}{boxed}
% The option `ruled' introduced in \textsf{caption} v1.2 is obsolete now, but
% we will still support it. The option `boxed' was introduced in version 2.0
% and is obsolete now, too.
%    \begin{macrocode}
\newif\ifcaption@ruled
\DeclareOption{ruled}{\caption@ruledtrue}
\DeclareOption{boxed}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{ignoreLTcapwidth}
% This option will make the caption code ignore the setting of \cs{LTcapwidth}
% and use the setting of \cs{setcaptionmargin} or \cs{setcaptionwidth} instead.
%    \begin{macrocode}
\DeclareOption{ignoreLTcapwidth}{\ignoreLTcapwidthtrue}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{debug}
% This option will put additional debug information in the log file.
%    \begin{macrocode}
\DeclareOption{debug}{\captionsetup{debug}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Execution of options}
%
% Now we set the default values and start processing the options.
% (If \cs{caption@twozero} is set to true (default) we will emulate the package
% load algorithm of \textsf{caption} v2.0: If the package is already loaded
% patch it, otherwise do nothing.)
% \changes{v2.1}{2002/02/19}{\cs{ProcessOptions} changed to \cs{ProcessOptions*}}
%    \begin{macrocode}
\newif\ifcaption@twozero
\normalcaptionparams
\ExecuteOptions{none,normal}
\caption@twozerotrue
\ProcessOptions*
\ifcaption@twozero
  \PackageInfo{caption2}{Running in caption2 v2.0 compatibility mode}
\fi
%    \end{macrocode}
%
% \subsection{More declarations}
%
% \begin{macro}{\captionof}
% \begin{macro}{\captionof*}
% \cs{captionof} resp.\ \cs{captionof*} will just set \cs{@captype} and do the normal
% \cs{caption} resp.\ \cs{caption*}, so we can also typeset captions outside floating
% environments.
% \changes{v2.1}{2002/02/19}{New commands \cs{captionof} and \cs{captionof*}}
%    \begin{macrocode}
\def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}
\newcommand*\caption@of[2]{\def\@captype{#2}#1}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\abovecaptionskip}
% \begin{macro}{\belowcaptionskip}
% Not all document classes define \cs{abovecaptionskip} and \cs{belowcaptionskip}
% (like \textsf{ucthesis}), so we do it here if not already done.
% \changes{v2.1}{2002/02/19}{\cs{abovecaptionskip} and \cs{belowcaptionskip} will be defined if neccessary}
%    \begin{macrocode}
\@ifundefined{abovecaptionskip}{%
  \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
\@ifundefined{belowcaptionskip}{%
  \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\captionlinewidth}
% \changes{v2.1}{2002/02/26}{Renamed from \cs{realcaptionwidth} to \cs{captionlinewidth}}
% \changes{v2.1a}{2003/11/12}{We offer \cs{realcaptionwidth}, again}
% \begin{macro}{\captionlabel}
% \begin{macro}{\captiontext}
% These values are only set and used within the caption code itself.
% \cs{captionlinewidth} will be set to the given vertical space for the caption,
% normally this is \cs{linewidth}. (This value was called \cs{realcaptionwidth}
% within \thispackage\ \mbox{2.0}, so we will offer this, too.)
%
% \cs{captionlabel} and \cs{captiontext} will be set to the caption label
% resp.\ the caption text.
% (Because \cs{captionlabel} and \cs{captiontext} will be locally defined with
% \cs{def} we do not need to define them here.)
%    \begin{macrocode}
\newdimen\captionlinewidth
\newdimen\realcaptionwidth
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\usecaptionmargin}
% A helper macro for caption style authors:
% It calculates \cs{leftskip} and \cs{rightskip} out of
% \cs{captionlinewidth} and \cs{captionmargin} resp.\ \cs{captionwidth}.
% Also \cs{captionlinewidth} will be corrected to the appropriate value.
%    \begin{macrocode}
\newcommand*\usecaptionmargin{%
  \ifcaptionwidth
    \leftskip\captionlinewidth
    \advance\leftskip by -\captionwidth
    \divide\leftskip by 2
    \rightskip\leftskip
    \captionlinewidth\captionwidth
  \else
    \leftskip\captionmargin
    \rightskip\captionmargin
    \advance\captionlinewidth by -2\captionmargin
  \fi
  \realcaptionwidth\captionlinewidth}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\onelinecaption}
% This macro definition helps setting captions the \LaTeX\ base classes way:
% If \cs{ifonelinecaptions} is set and the 1st argument fits within \cs{captionlinewidth},
% we typeset it centered -- otherway we typeset the 2nd argument.
% (We use the savebox \cs{@tempboxa} as helper for this.)
%    \begin{macrocode}
\newcommand\onelinecaption[1]{%
  \let\next\@firstofone
  \ifonelinecaptions
    \sbox\@tempboxa{#1}%
    \ifdim\wd\@tempboxa >\captionlinewidth
    \else
      \def\next{{\centering\usebox\@tempboxa\par}\@gobble}%
    \fi
  \fi\next}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\usecaptionstyle}
% First we check if we are inside a caption -- if \cs{captiontext} is undefined we are not.
% If we are we call the appropriate caption definition.
%
% \changes{v2.1b}{2004/04/16}{Missing percent added (and extra space removed)}
% \changes{v2.2}{2007/04/06}{\cs{let}\cs{caption@make}\cs{caption@makecaption} added}
%    \begin{macrocode}
\newcommand*\usecaptionstyle[1]{%
  \@ifundefined{captiontext}{%
    \PackageError{caption2}{You can't use \protect#1
      in normal text}{The usage of \protect#1 is only
      allowed inside code declared with\MessageBreak \protect\defcaptionstyle,
      \protect\newcaptionstyle \space or \protect\renewcaptionstyle.
      \space\caption@eh}
  }{%
    \@ifundefined{caption@@#1}%
      {\PackageError{caption2}{Caption style `#1' undefined}{\caption@eh}}%
      {\let\caption@make\caption@makecaption
       \@nameuse{caption@@#1}}%
  }}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makecaption}
% This is the heart of the \thispackage\ package -- the redefinition of the
% core caption code. It was taken from the \LaTeXe\ standard classes and modified.
% It's very easy -- apart from using \cs{abovecaptionskip} and \cs{belowcaptionskip}
% we just set \cs{captionlinewidth}, \cs{captionlabel} and \cs{captiontext}
% to its appropriate values and using the code of the actual caption style via
% \cs{usecaptionstyle}.
%    \begin{macrocode}
\renewcommand\@makecaption[2]{%
  \vskip\abovecaptionskip
  \captionlinewidth\hsize
  \realcaptionwidth\hsize
  \def\captionlabel{#1}%
  \def\captiontext{#2}%
  \usecaptionstyle\caption@style
  \vskip\belowcaptionskip}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Support of other packages}
%
% \begin{macro}{\caption@ifpackage}
% This macro will execute the code needed to support the package
% named within argument \#1. The parameter \#2 is the command
% which shows if the package is loaded -- it is defined, it is
% already loaded, otherwise not. The parameter \#3 contains code
% which will be executed if no support is required -- this is for
% cleanup purposes. The final parameter \#4 contains the code itself.
% \changes{v2.1c}{2004/05/09}{Compatibility warning removed}
%    \begin{macrocode}
\newcommand*\caption@ifpackage[3]{%
  \if1\@nameuse{caption@pkt@#1}%
    \@ifundefined{#2}%
      {\let\next\AtBeginDocument}%
      {\let\next\@firstofone}%
  \else\ifcaption@twozero
    \@ifundefined{#2}%
      {#3\let\next\@gobble}%
      {\let\next\@firstofone}%
  \else
    #3\let\next\@gobble
  \fi\fi
  \expandafter\let\csname caption@pkt@#1\endcsname\undefined
  \caption@ifdebug{%
    \ifx\next\@gobble\PackageInfo{caption2}{#1 => gobble}%
    \else\ifx\next\@firstofone\PackageInfo{caption2}{#1 => firstofone}%
    \else\ifx\next\AtBeginDocument\PackageInfo{caption2}{#1 => AtBeginDocument}%
    \fi\fi\fi}{}%
  \next}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Support of the float package}
%
%    \begin{macrocode}
\caption@ifpackage{float}{floatc@plain}{}{%
  \ifx\floatc@plain\relax
    \PackageWarning{caption2}{%
      Option `float' was set but there is no float package loaded}
  \else
    \PackageInfo{caption2}{float package v1.2 (or newer) detected}
%    \end{macrocode}
%
% \begin{macro}{\caption@floatc}
% First we define a helper macro to typeset the caption via \cs{usecaptionstyle},
% the 1st parameter is the caption style name,
% the 2nd and 3rd are the caption label and text.
%
% \textsf{caption2} has the goal not to modify the output just by
% loading it (without options), therefore we have to be tricky here to
% support \cs{@fs@cfont} which is in fact the same as our \cs{captionlabelfont}.
% So we test if a \cs{captionlabelfont} has been set by the user -- if not
% \cs{@fs@cfont} will be used, otherwise \cs{captionlabelfont}.
%
% \changes{v2.1b}{2004/03/19}{\cs{realcaptionwidth}$=$\cs{hsize} was missing here}
%    \begin{macrocode}
    \newcommand\caption@floatc[3]{%
      \ifx\captionlabelfont\@empty
        \let\captionlabelfont\@fs@cfont
      \fi
      \captionlinewidth\hsize
      \realcaptionwidth\hsize
      \def\captionlabel{#2}%
      \def\captiontext{#3}%
      \usecaptionstyle{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\floatc@plain}
% Now we can redefine the caption code of the \textsf{float} package.
% Here we redefine \cs{floatc@plain} to use our caption code, so
% \texttt{plain} and \texttt{boxed} float types will use the actual
% caption style set by the user.
%    \begin{macrocode}
    \renewcommand*\floatc@plain{\caption@floatc{\caption@style}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\floatc@ruled}
% The support of the \texttt{ruled} float type is a little
% more complex. First we define a caption style `ruled' so the end-user
% can change this caption style afterwards. If the (obsolete) option
% `ruled' is set, we define it in a \textsf{caption} v1.x compatible way,
% otherwise we define it in a \textsf{float} compatible way.
%
% Then we redefine \cs{floatc@ruled} so the caption style `ruled' will
% be used.
%    \begin{macrocode}
    \ifcaption@ruled
      \dummycaptionstyle{ruled}{\onelinecaptionsfalse\setcaptionmargin{\z@}}%
    \else
      \newcaptionstyle{ruled}{%
        \ifcaptionlabel
          {\@fs@cfont\captionlabel}\space%
        \fi\captiontext\par}%
    \fi
%    \end{macrocode}
%    \begin{macrocode}
    \renewcommand*\floatc@ruled{\caption@floatc{ruled}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@of}
% Typesetting captions outside floats is not so easy with redefined floats,
% because
% \begin{itemize}
% \item The caption code of the \textsf{float} package needs not only
% \cs{@captype} defined, but \cs{@fs@capt} (the command which will typeset the
% caption itself) either.
% \item The caption is only saved within a \cs{vbox}, so the \textsf{float}
% package can typeset the caption later at it's float style specific place
% (that means at top or at the bottom of the float).
% \end{itemize}
%
% Here is the new code: First we check if it's a restyled float by checking if
% \cs{fst@<floattype>} is defined. If yes, we use this command (it will define
% \cs{@fs@capt}).
% Then we execute \cs{@float@setevery}, if it exists (that means we are
% dealing with the \textsf{float} package 1.3 or newer here).
% Now comes the basic trick:
% We redefine the caption typesetting command \cs{@fs@capt}, so it will close
% the \cs{vbox}, typeset the caption outside the vbox and finally start the
% group again so the original \cs{@fs@capt} is happy with closing the group.
%
%    \begin{macrocode}
    \renewcommand*\caption@of[2]{\def\@captype{#2}%
      \@ifundefined{fst@#2}{}{%
        \@nameuse{fst@#2}%
        \@ifundefined{@float@setevery}{}{\@float@setevery{#2}}%
        \let\caption@fs@capt\@fs@capt
        \let\@fs@capt\caption@of@float}%
      #1}
%    \end{macrocode}
%
%    \begin{macrocode}
    \newcommand\caption@of@float[2]{\egroup
      \vskip\abovecaptionskip
      \normalsize\caption@fs@capt{#1}{#2}%
      \vskip\belowcaptionskip
      \bgroup}%
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
  \fi}
%    \end{macrocode}
%
% \subsubsection{Support of the longtable package}
%
%    \begin{macrocode}
\caption@ifpackage{longtable}{LT@makecaption}{}{%
  \ifx\LT@makecaption\relax
    \PackageWarning{caption2}{%
      Option `longtable' was set but there is no longtable package loaded}
  \else
    \PackageInfo{caption2}{longtable package v3.15 (or newer) detected}
%    \end{macrocode}
%
% \begin{macro}{\LT@makecaption}
% David Carlisle was so kind to introduce a macro called
% \cs{LT@makecaption} in version 3.15 of the \textsf{longtable}
% package which typeset the caption and can be easily redefined.
%
% This is the original definition:
% \begin{quote}
% |\def\LT@makecaption#1#2#3{%|\\
% |  \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%|\\
% |    |$\langle$\textit{typeset} |#1{#2: }#3| \textit{as caption}$\rangle$\\
% |    \endgraf\vskip\baselineskip}%|\\
% |  \hss}}}|
% \end{quote}
%
% So we do here:
% First we define a new (dummy) caption style `longtable',
% than we redefine \cs{LT@makecaption} so this style will be used.
% (Remember: |#1| is |\@gobble| in star form of |\caption|,
% and |\@firstofone| otherwise.)
%    \begin{macrocode}
    \dummycaptionstyle{longtable}{}
%    \end{macrocode}
%    \begin{macrocode}
    \renewcommand\LT@makecaption[3]{%
      \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\hsize{%
        \ifignoreLTcapwidth
        \else
          \setcaptionwidth\LTcapwidth
        \fi
        \captionlinewidth\hsize
        \realcaptionwidth\hsize
        \captionlabelfalse#1\captionlabeltrue
        \def\captionlabel{#2}%
        \def\captiontext{#3}%
        \usecaptionstyle{longtable}%
        \endgraf\vskip\baselineskip}%
      \hss}}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
  \fi}
%    \end{macrocode}
%
% \subsubsection{Support of the subfigure package}
%
% Some of the following code will not work within \cs{if},
% because of the (yet) undefined \cs{if}\textit{xxx}s. So we simply define
% the critical code within the helper commands \cs{setsubcapstyle}
% and \cs{caption@makesubcaption} already here.
%
% \begin{macro}{\setsubcapstyle}
% This sets the subcaptionstyle to a appropriate value.
%
% If \cs{ifsubcapraggedright} is undefined (it was introduced
% into v2.1 of the \textsf{subfigure} package) we define it first.
%    \begin{macrocode}
\newcommand*\setsubcapstyle{%
  \@ifundefined{subcapraggedrightfalse}{%
    \newif\ifsubcapraggedright}{}%
  \ifsubcaphang
    \ifsubcapcenter
      \subcapstyle{hang+center}%
    \else\ifsubcapcenterlast
      \subcapstyle{hang+centerlast}%
    \else\ifsubcapraggedright
      \subcapstyle{hang+flushleft}%
    \else
      \subcapstyle{hang}%
    \fi\fi\fi
  \else\ifsubcapcenter
    \subcapstyle{center}%
  \else\ifsubcapcenterlast
    \subcapstyle{centerlast}%
  \else\ifsubcapraggedright
    \subcapstyle{flushleft}%
  \else
    \subcapstyle{normal}%
  \fi\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@makesubcaption}
% \changes{v2.2c}{2008/07/01}{Bugfix: Usage of \cs{ifcaptionwidth} removed}
% This will typeset the subcaption.
% We just set all our \cs{caption}\textit{xxx} values to
% the values of \cs{subcap}\textit{xxx} and typeset the
% caption like \textsf{subfigure} within a \cs{hbox},
% but with the help of \cs{usecaptionstyle}.
%
% But this is not as easy as it seems. We typeset the caption like this:
% \begin{quote}
%   |\captionfont|\\
%   |  {\capionlabelfont\captionlabel\captionlabeldelim}%|\\
%   |\captionlabelsep\captiontext|
% \end{quote}
% Within \textsf{subfigure} 2.0 the caption will be set quite similar to:
% \begin{quote}
%   |\subcapsize|\\
%   |  {\subcaplabelfont\captionlabel}%|\\
%   |\space\captiontext|
% \end{quote}
% But within \textsf{subfigure} 2.1 this has changed to:
% \begin{quote}
%   |\subcapsize|\\
%   |  {\subcaplabelfont\captionlabel}%|\\
%   |\hskip\subfiglabelskip|\\
%   |  {\subcapfont\captiontext}}|
% \end{quote}
% So we have to be tricky here: We set \cs{captionlabelfont} to \cs{normalfont} plus
% \cs{subcapsize} \& \cs{subcaplabelfont}, so the font setting in \cs{captionfont}
% will not affect the caption label in subfigure captions.
%
% Note that \cs{hfil} has changed to \cs{hss} from subfigure 2.0 to 2.1,
% so we use \cs{caption@subfig@hss} instead. (We will define this later on.)
%    \begin{macrocode}
\newcommand\caption@makesubcaption[2]{%
  \renewcommand*\captionfont{\subcapsize\subcapfont}%
  \renewcommand*\captionlabelfont{\normalfont\subcapsize\subcaplabelfont}%
  \let\captionlabeldelim\subcaplabeldelim
  \let\captionlabelsep\subcaplabelsep
  \ifsubfigcapwidth
    \setcaptionwidth\subfigcapwidth
  \else
    \setcaptionmargin\subfigcapmargin
  \fi
  \setlength\captionmargin\subfigcapmargin
  \setlength\captionwidth\subfigcapwidth
  \captionindent\subcapindent
  \ifsubcapnooneline
    \onelinecaptionsfalse
  \else
    \onelinecaptionstrue
  \fi
  \hbox to\@tempdima{%
    \caption@subfig@hss\parbox[t]\@tempdima{%
      \captionlinewidth\@tempdima
      \realcaptionwidth\@tempdima
      \captionlabeltrue
      \def\captionlabel{#1}%
      \def\captiontext{\ignorespaces #2}%
      \usecaptionstyle\caption@substyle}%
    \caption@subfig@hss}}
%    \end{macrocode}
% \end{macro}
%
% If the subfigure support is not needed, we throw
% the helper macros in the garbage can.
%
%    \begin{macrocode}
\caption@ifpackage{subfigure}{@makesubfigurecaption}{%
  \let\setsubcapstyle\undefined
  \let\caption@makesubcaption\undefined}{%
  \ifx\@makesubfigurecaption\relax
    \PackageWarning{caption2}{%
      Option `subfigure' was set but there is no subfigure package loaded}
    \let\setsubcapstyle\undefined
    \let\caption@makesubcaption\undefined
  \else
%    \end{macrocode}
%
% Some stuff has changed from version 2.0 to 2.1 of the
% \textsf{subfigure} package, so we make a branch here.
% If \cs{subcapfont} is undefined we assume v2.0,
% otherwise we assume v2.1 or newer.
%
%    \begin{macrocode}
    \ifx\subcapfont\undefined
      \PackageInfo{caption2}{subfigure package v2.0 detected}
%    \end{macrocode}
%
% \begin{macro}{\subcapfont}
% We define \cs{subcapfont} here so we can use it later
% in common code for \textsf{subfigure} v2.0 and v2.1 (or newer).
%    \begin{macrocode}
      \let\subcapfont\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subfigcapwidth}
% \begin{macro}{\setsubcapmargin}
% \begin{macro}{\setsubcapwidth}
% Analogous to \cs{captionwidth}, \cs{setcaptionmargin}, and
% \cs{setcaptionwidth} we define \cs{subfigcapwidth},
% \cs{setsubcapmargin}, and \cs{setsubcapwidth}.
%
% Note: \cs{subfigcapmargin} is a command in v2.0 of \textsf{subfigure}.
% So we make \cs{subfigcapwidth} a command, too.
%    \begin{macrocode}
      \newcommand*\subfigcapwidth{\z@}
      \newcommand*\setsubcapmargin{%
        \subfigcapwidthfalse
        \renewcommand*\subfigcapmargin}
      \newcommand*\setsubcapwidth{%
        \subfigcapwidthtrue
        \renewcommand*\subfigcapwidth}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subcaplabelsep}
% Analogous to \cs{captionlabelsep} we define \cs{subcaplabelsep}.
%    \begin{macrocode}
      \newcommand*\subcaplabelsep{\space}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@subfig@hss}
% This will be uses within the caption code itself.
%    \begin{macrocode}
      \let\caption@subfig@hss\hfil
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
    \else
      \PackageInfo{caption2}{subfigure package v2.1 (or newer) detected}
%    \end{macrocode}
%
% \begin{macro}{\subfigcapwidth}
% \begin{macro}{\setsubcapmargin}
% \begin{macro}{\setsubcapwidth}
% Analogous to \cs{captionwidth}, \cs{setcaptionmargin}, and
% \cs{setcaptionwidth} we define \cs{subfigcapwidth},
% \cs{setsubcapmargin}, and \cs{setsubcapwidth}.
%
% Note: \cs{subfigcapmargin} is a length in v2.1 of \textsf{subfigure}.
% So we make \cs{subfigcapwidth} a length, too.
%    \begin{macrocode}
      \newdimen\subfigcapwidth
      \newcommand*\setsubcapmargin{%
        \subfigcapwidthfalse
        \setlength\subfigcapmargin}
      \newcommand*\setsubcapwidth{%
        \subfigcapwidthtrue
        \setlength\subfigcapwidth}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subcaplabelsep}
% Analogous to \cs{captionlabelsep} we define \cs{subcaplabelsep}.
%    \begin{macrocode}
      \newcommand*\subcaplabelsep{\hskip\subfiglabelskip}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\caption@subfig@hss}
% This will be uses within the caption code itself.
%    \begin{macrocode}
      \let\caption@subfig@hss\hss
%    \end{macrocode}
%
% \end{macro}
%    \begin{macrocode}
    \fi
%    \end{macrocode}
%
% Here starts the common code for \textsf{subfigure} v2.0 and v2.1.
%
% \begin{macro}{\ifsubfigcapwidth}
% \begin{macro}{\subcapindent}
% \begin{macro}{\subcaplabeldelim}
% Analogous to \cs{ifcaptionwidth}, \cs{captionindent} \& \cs{captionlabeldelim}
% we define \cs{ifsubfigcapwidth}, \cs{subcapindent} \& \cs{subcaplabeldelim}
%    \begin{macrocode}
    \newif\ifsubfigcapwidth
    \newdimen\subcapindent
    \newcommand*\subcaplabeldelim{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subcapstyle}
% Analogous to \cs{captionstyle} we define \cs{subcapstyle}
% and set it (via \cs{setsubcapstyle}) to a appropriate value.
%    \begin{macrocode}
    \newcommand*\subcapstyle[1]{%
      \expandafter\ifx\csname caption@@#1\endcsname\relax
        \PackageError{caption2}{Undefined caption style `#1'}{\caption@eh}%
      \else
        \def\caption@substyle{#1}%
      \fi}
    \setsubcapstyle
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@thesubfigure}
% \begin{macro}{\@thesubtable}
% The \textsf{subfigure} package makes use of \cs{subcaplabelfont} and
% \cs{subfiglabelskip} within its \cs{@thesub}\textit{xxx} macros.
% This is totally in contrast to the way the \textsf{caption2} package
% handle these settings. So we redefine the \cs{@thesub}\textit{xxx}
% to be just the plain label and nothing else.
%
%    \begin{macrocode}
    \renewcommand*\@thesubfigure{\thesubfigure}
    \renewcommand*\@thesubtable{\thesubtable}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@makesubfigurecaption}
% \begin{macro}{\@makesubtablecaption}
% Now we are ready to redefine \cs{@makesubfigurecaption}.
%    \begin{macrocode}
    \let\@makesubfigurecaption\caption@makesubcaption
    \let\@makesubtablecaption\caption@makesubcaption
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
  \fi}
%    \end{macrocode}
%
% That's all folks!
%
%    \begin{macrocode}
\let\caption@ifpackage\undefined
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \clearpage
% \begin{thebibliography}{9}
%   \bibitem{float}
%   Anselm Lingnau:
%   \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/float/}%
%        {\emph{An Improved Environment for Floats}},
%   2001/11/08
%
%   \bibitem{longtable}
%   David Carlisle:
%   \href{http://tug.ctan.org/tex-archive/macros/latex/required/tools/}%
%        {\emph{The longtable package}},
%   2000/10/22
%
%   \bibitem{rotating}
%   Sebastian Rahtz and Leonor Barroca:
%   \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/rotating/}%
%        {\emph{A style option for rotated objects in \LaTeX}},\\
%   1997/09/26
%
%   \bibitem{subfigure}
%   Steven D. Cochran:
%   \href{http://tug.ctan.org/tex-archive/macros/latex/contrib/subfigure/}%
%        {\emph{The subfigure package}},
%   2002/02/14
%
%   \bibitem{A-W:GMS94}
%   Michel Goossens, Frank Mittelbach and Alexander Samarin:
%   \newblock \textsl{The {\LaTeX} Companion},
%   \newblock Addison-Wesley, Reading, Massachusetts, 1994.
%
%   \bibitem{Anne}
%   Anne Br\"uggemann-Klein:
%   \textsl{Einf\"uhrung in die Dokumentverarbeitung},
%   B.G. Teubner, Stuttgart, 1989
%
%   \bibitem{Kopka-E}
%   Helmut Kopka:
%   \textsl{\LaTeX -- Erweiterungsm\"oglichkeiten},
%   3. \"uberarbeitete Auf\/lage, Addison-Wesley, Bonn, 1991
% \end{thebibliography}
%
% \Finale
%
\endinput
