% \iffalse
% caption.dtx - The caption package
% (c) 1994-2002 Axel Sommerfeldt (caption@sommerfeldt.net)
%
%<*driver>
\documentclass{ltxdoc}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\smallskipamount}
\begin{document}
  \DocInput{caption.dtx}
\end{document}
%</driver>
% \fi
%
% \providecommand*{\LaTeXcomp}{The \LaTeX{} Companion}
% \newcommand*{\purerm}[1]{{\upshape\mdseries\rmfamily #1}}
% \newcommand*{\puresf}[1]{{\upshape\mdseries\sffamily #1}}
%
% \def\packageversion{1.4b}
% \def\packagedate{1995/04/05}
% \changes{v1.0}{27 Oct 94}{First release}
% \changes{v1.1}{3 Nov 94}{New captiontype: {\tt centerlast}}
% \changes{v1.2}{28 Nov 94}{Works now with the {\tt figure*} and {\tt table*} environments, too}
% \changes{v1.2}{28 Nov 94}{Support of the {\sf float} package}
% \changes{v1.3}{8 Jan 95}{Support of {\tt\protect\bslash captionlabelfont} in subcaptions}
% \changes{v1.4}{29 Jan 95}{{\tt\protect\bslash captionsize} changed to {\tt\protect\bslash captionfont}}
% \changes{v1.4}{30 Jan 95}{New option: {\tt nooneline}}
% \changes{v1.4b}{5 Apr 95}{Adapted to version 2.8 of the rotating package}
%
% \title{The \puresf{caption} package\thanks{This package has version number
%        \packageversion, last revised \packagedate.}}
% \author{Axel Sommerfeldt\\\texttt{caption@sommerfeldt.net}}
% \date{2002/01/28}
% \maketitle
%
% \begin{abstract}
% The \textsf{caption} package was superseeded by the new \textsf{caption2} package.
% So please use \textsf{caption2} instead; for migrating please see the enclosed
% manual.
% \end{abstract}
%
% \StopEventually{
%   \begin{thebibliography}{9}
%   \bibitem{rotating}
%   Sebastian Rahtz and Leonor Barroca:
%   \emph{A style option for rotated objects in \LaTeX},
%   1994/10/02
%   \bibitem{float}
%   Anselm Lingnau:
%   \emph{An Improved Environment for Floats},
%   1995/03/25
%   \bibitem{A-W:GMS94}
%   Michel Goossens, Frank Mittelbach and Alexander Samarin:
%   \newblock {\em The {\LaTeX} Companion},
%   \newblock Addison-Wesley, Reading, Massachusetts, 1994.
%   \bibitem{Anne}
%   Anne Br\"uggemann-Klein:
%   \emph{Einf\"uhrung in die Dokumentverarbeitung},
%   B.G. Teubner, Stuttgart, 1989
%   \bibitem{Kopka-E}
%   Helmut Kopka:
%   \emph{\LaTeX -- Erweiterungsm\"oglichkeiten},
%   3. \"uberarbeitete Auf\/lage, Addison-Wesley, Bonn, 1991
%   \end{thebibliography}
% }
% \setlength{\parskip}{0pt plus 1pt}
%
% \CheckSum{295}
% \DoNotIndex{\\,\_,\ }
% \DoNotIndex{\p@}
% \DoNotIndex{\active,\addtolength,\begin,\bfseries}
% \DoNotIndex{\catcode,\def,\else,\empty,\end,\fi,\footnotesize,\global}
% \DoNotIndex{\hangindent,\hspace,\ifcase,\ifdim,\ifx,\itshape}
% \DoNotIndex{\Large,\large,\leavevmode,\leftskip,\let,\linewidth}
% \DoNotIndex{\mdseries,\newcommand,\newlength,\newsavebox,\noindent,\normalsize}
% \DoNotIndex{\or,\par,\parbox,\parfillskip,\renewcommand,\rightskip,\rmfamily}
% \DoNotIndex{\sbox,\scriptsize,\scshape,\setlength,\sffamily,\slshape,\small,\space}
% \DoNotIndex{\textheight,\typeout,\ttfamily,\undefined,\upshape,\usebox}
% \DoNotIndex{\vsize,\vskip,\wd}
% \DoNotIndex{\AtBeginDocument,\DeclareOption,\ExecuteOptions,\NeedsTeXFormat}
% \DoNotIndex{\ProcessOptions,\ProvidesPackage}
%
% \section{The code}
% \iffalse
%<*package>
% \fi
%
% \subsection{Identification}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{caption}[1995/04/05 v1.4b caption package (AS)]
%    \end{macrocode}
%
% \subsection{Initial code}
% \begin{macro}{\captionfont}
% \begin{macro}{\captionlabelfont}
% \begin{macro}{\captionmargin}
% |\captionsize| is defined for backward compatibility with v1.3
% of this package.
%    \begin{macrocode}
\newcommand{\captionsize}{}
\newcommand{\captionfont}{\captionsize}
\newcommand{\captionlabelfont}{}
\newlength{\captionmargin}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Here are the different basic types of captions implemented:
% \begin{macro}{\as@normalcaption}
% \changes{v1.4a}{12 Feb 95}{{\tt\protect\bslash par} added}
% The `normal' caption
%    \begin{macrocode}
\newcommand{\as@normalcaption}[2]{%
  #1 #2\par}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\as@isucaption}
% \changes{v1.4}{27 Jan 95}{{\tt\protect\bslash leavevmode} added}
% The `iso' or `hang' caption;
% this code was taken from \LaTeXcomp\cite[p155]{A-W:GMS94} and modified
% \iffalse
%  \hangindent\wd\as@captionbox\noindent\usebox{\as@captionbox}#2}
% \fi
%    \begin{macrocode}
\newcommand{\as@isucaption}[2]{%
  \sbox{\as@captionbox}{#1\space}%
  \addtolength{\as@captionwidth}{-\wd\as@captionbox}%
  \usebox{\as@captionbox}\parbox[t]{\as@captionwidth}{\leavevmode#2}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\as@centercaption}
% \changes{v1.4a}{12 Feb 95}{{\tt center} environment changed to {\tt\protect\bslash centering}}
% The `center' caption
%    \begin{macrocode}
\newcommand{\as@centercaption}[2]{%
  \parbox[t]{\as@captionwidth}{{\centering#1 #2\par}}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\as@annecaption}
% \changes{v1.4a}{12 Feb 95}{{\tt\protect\bslash par} added}
% The `centerlast' caption; 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}
\newcommand{\as@annecaption}[2]{%
  \addtolength{\leftskip}{0pt plus 1fil}%
  \addtolength{\rightskip}{0pt plus -1fil}%
  \setlength{\parfillskip}{0pt plus 2fil}%
  #1 #2\par}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\as@shortcaption}
% Short captions are centered by default
%    \begin{macrocode}
\let\as@shortcaption\as@centercaption
%    \end{macrocode}
% \end{macro}
%
% \subsection{Detection of the \puresf{subfigure} package}
% \begin{macro}{\as@subcapsize}
% \begin{macro}{\@thesubfigure}
% \begin{macro}{\@thesubtable}
% If the \textsf{subfigure} package is loaded, a little message will be typeout
% and |\as@subcapsize| -- which sets the size of the subcaptions -- will be
% defined. Also |\@thesubfigure| and |\@thesubtable| will be redefined here to
% support the |\captionlabelfont| in subcaptions, too (thanks to Kevin Ruland for
% this idea!).
% If you don't like this behaviour, just load the |caption| package \emph{after}
% the |subfigure| package (and eventually redefine the |\subcapsize| by yourself)
% or redefine |\@thesubfigure| and |\@thesubtable| after loading the |caption|
% package as shown in the documentation of the \textsf{subfigure} package.
%    \begin{macrocode}
\ifx\thesubfigure\undefined
  \newcommand{\as@subcapsize}[1]{}
\else%
  \typeout{\space\space\space\space\space\space\space\space\space
           `subfigure' package detected}
  \let\as@subcapsize\subcapsize
  \renewcommand{\@thesubfigure}{{\captionlabelfont\thesubfigure}\space}
  \renewcommand{\@thesubtable}{{\captionlabelfont\thesubtable}\space}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Declaration of options}
% There are four different types of captions supported: |normal|,
% |isu|, |center| and |centerlast|. |hang| is exactly the same as |isu|.
%    \begin{macrocode}
\DeclareOption{normal}{\let\as@caption\as@normalcaption}
\DeclareOption{isu}{\let\as@caption\as@isucaption}
\DeclareOption{hang}{\ExecuteOptions{isu}}
\DeclareOption{center}{\let\as@caption\as@centercaption}
\DeclareOption{anne}{\let\as@caption\as@annecaption}
\DeclareOption{centerlast}{\ExecuteOptions{anne}}
%    \end{macrocode}
% If option |nooneline| is set, only-one-line captions will behave like normal
% ones.
%    \begin{macrocode}
\DeclareOption{nooneline}{\AtBeginDocument{\let\as@shortcaption\as@caption}}
%    \end{macrocode}
% There are options for six different font sizes available, they also
% redefine the |\subcapsize| provided by the \textsf{subfigure} package
% (if detected).
%    \begin{macrocode}
\DeclareOption{scriptsize}{%
  \renewcommand{\captionsize}{\scriptsize}
  \as@subcapsize{\scriptsize}}
\DeclareOption{footnotesize}{%
  \renewcommand{\captionsize}{\footnotesize}
  \as@subcapsize{\scriptsize}}
\DeclareOption{small}{%
  \renewcommand{\captionsize}{\small}
  \as@subcapsize{\footnotesize}}
\DeclareOption{normalsize}{%
  \renewcommand{\captionsize}{\normalsize}
  \as@subcapsize{\footnotesize}}
\DeclareOption{large}{%
  \renewcommand{\captionsize}{\large}
  \as@subcapsize{\normalsize}}
\DeclareOption{Large}{%
  \renewcommand{\captionsize}{\Large}
  \as@subcapsize{\large}}
%    \end{macrocode}
% There are nine options available to set the font attributes of the caption labels.
%    \begin{macrocode}
\DeclareOption{up}{\renewcommand{\captionlabelfont}{\upshape}}
\DeclareOption{it}{\renewcommand{\captionlabelfont}{\itshape}}
\DeclareOption{sl}{\renewcommand{\captionlabelfont}{\slshape}}
\DeclareOption{sc}{\renewcommand{\captionlabelfont}{\scshape}}
\DeclareOption{md}{\renewcommand{\captionlabelfont}{\mdseries}}
\DeclareOption{bf}{\renewcommand{\captionlabelfont}{\bfseries}}
\DeclareOption{rm}{\renewcommand{\captionlabelfont}{\rmfamily}}
\DeclareOption{sf}{\renewcommand{\captionlabelfont}{\sffamily}}
\DeclareOption{tt}{\renewcommand{\captionlabelfont}{\ttfamily}}
%    \end{macrocode}
% If the option |ruled| is set, the captions of ruled floats provided
% by the \textsf{float} package will also be supported.
%    \begin{macrocode}
\DeclareOption{ruled}{\newcommand\as@ruled{}}
%    \end{macrocode}
%
% \subsection{Execution of options}
% The `normal' type of caption is preselected.
%    \begin{macrocode}
\ExecuteOptions{normal}
\ProcessOptions
%    \end{macrocode}
%
% \subsection{Main code}
% \begin{macro}{\as@captionbox}
% \begin{macro}{\as@captionwidth}
% \begin{macro}{\as@makecaption}
% \begin{macro}{\@makecaption}
% \changes{v1.4}{30 Jan 95}{{\tt center} environment changed to {\tt\protect\bslash as@shortcaption}}
% \changes{v1.4a}{12 Feb 95}{{\tt\protect\bslash par} removed}
% And now \ldots\ it's \ldots\ the new |\@makecaption| code!
%    \begin{macrocode}
\newsavebox{\as@captionbox}
\newlength{\as@captionwidth}
\newcommand{\as@makecaption}[2]{%
  \setlength{\leftskip}{\captionmargin}%
  \setlength{\rightskip}{\captionmargin}%
  \addtolength{\as@captionwidth}{-2\captionmargin}%
  \captionfont%
  \sbox{\as@captionbox}{{\captionlabelfont #1:} #2}%
  \ifdim \wd\as@captionbox >\as@captionwidth
    \as@caption{{\captionlabelfont #1:}}{#2}%
  \else%
    \as@shortcaption{{\captionlabelfont #1:}}{#2}%
  \fi}
\renewcommand{\@makecaption}[2]{%
  \vskip\abovecaptionskip%
  \setlength{\as@captionwidth}{\linewidth}%
  \as@makecaption{#1}{#2}%
  \vskip\belowcaptionskip}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Support of the \puresf{rotating} package}
% \begin{macro}{\@makercaption}
% \changes{v1.4b}{5 Apr 95}{{\tt\protect\bslash @makercaption} removed}
% \begin{macro}{\@makerotcaption}
% If the \textsf{rotating} package is loaded, the command |\@makerotcaption|
% (for support of |\rotcaption|) will be
% redefined here. The code was taken from the \textsf{rotating} package
% \cite{rotating} itself and adapted.
%    \begin{macrocode}
\ifx\@makerotcaption\undefined
\else
  \typeout{\space\space\space\space\space\space\space\space\space
           `rotating' package detected}
% \let\@makercaption\undefined
  \renewcommand{\@makerotcaption}[2]{%
    \captionfont%
    \sbox{\as@captionbox}{{\captionlabelfont #1:} #2}%
    \ifdim \wd\as@captionbox > .8\vsize
      \rotatebox{90}{%
        \setlength{\as@captionwidth}{.8\textheight}%
        \begin{minipage}{\as@captionwidth}%
          \as@caption{{\captionlabelfont #1:}}{#2}%
        \end{minipage}}\par
    \else%
      \rotatebox{90}{\usebox{\as@captionbox}}%
    \fi
    \hspace{12pt}}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Support of the \puresf{float} package}
% \begin{macro}{\floatc@plain}
% \begin{macro}{\floatc@ruled}
% \changes{v1.3}{8 Jan 95}{{\tt\protect\bslash as@normalcaption} changed to {\tt\protect\bslash as@caption}}
% \changes{v1.4a}{12 Feb 95}{{\tt\protect\bslash par} removed}
% If the \textsf{float} package is loaded, the command |\floatc@plain|
% (and the command |\floatc@ruled| if the option |ruled| is given)
% will be redefined here.
%    \begin{macrocode}
\ifx\floatc@plain\undefined
\else
  \typeout{\space\space\space\space\space\space\space\space\space
           `float' package detected}
  \renewcommand\floatc@plain[2]{%
    \setlength{\as@captionwidth}{\linewidth}%
    \as@makecaption{#1}{#2}}
  \ifx\as@ruled\undefined
  \else
    \renewcommand\floatc@ruled[2]{%
      \setlength{\as@captionwidth}{\linewidth}%
      \captionfont%
      \as@caption{{\captionlabelfont #1:}}{#2}}
  \fi
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \iffalse
%</package>
% \fi
%
% \Finale
%
\endinput
