% \iffalse
% caption.dtx - The caption package
% (c) 1994-95 Axel Sommerfeldt (axel@hp1.ang-physik.uni-kiel.de)
% 
% --------------------------------------------------------------------------
% 
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% 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.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
%<*driver>
\documentclass{ltxdoc}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\smallskipamount}
\usepackage[hang,small,bf]{caption}[1995/01/30]
\setlength{\captionmargin}{20pt}
\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}}
% \newenvironment{Options}[1]%
%  {\begin{list}{}{\renewcommand{\makelabel}[1]{\texttt{##1}\hfil}%
%     \settowidth{\labelwidth}{\texttt{#1\space}}%
%     \setlength{\leftmargin}{\labelwidth}%
%     \addtolength{\leftmargin}{\labelsep}}}%
%  {\end{list}}
%
% \def\packageversion{1.4b}
% \def\packagedate{1995/04/05}
% \changes{v1.0}{27 Oct 94}{First release}
% \changes{v1.2}{28 Nov 94}{Works now with the {\tt figure*} and {\tt table*} environments, too}
%
% \title{The \puresf{caption} package\thanks{This package has version number
%        \packageversion, last revised \packagedate.}}
% \author{Axel Sommerfeldt\\\texttt{axel@hp1.ang-physik.uni-kiel.de}}
% \date{1995/04/05}
% \maketitle
%
% \begin{abstract}
% The \textsf{caption} package provides many ways to customise the captions
% in floating environments such |figure| and |table|.
% The |\rotcaption| command and the |sidewaysfigure| and |sidewaystable|
% environments provided by the \textsf{rotating} package from S.~Rahtz and
% L.~Barroca are also supported.
% The \textsf{caption} package also cooperates with the \textsf{float}
% package written by A.~Lingnau and the \textsf{subfigure} package written by
% S.D.~Cochran.
% \end{abstract}
%
% \section{The user interface}
% \changes{v1.1}{3 Nov 94}{New captiontype: {\tt centerlast}}
% \changes{v1.4}{30 Jan 95}{New option: {\tt nooneline}}
%
% To use this package just type
% \begin{quote}
%   |\usepackage|\oarg{options}|{caption}|
% \end{quote}
% in the preamble of your document,
% where the following options are supported:
% \begin{quote}\begin{Options}{scriptsize\purerm{, \ldots,\ }Large}
% \item[normal]
%   provides `normal' captions, this is the default
% \item[hang \purerm{or} isu]
%   provides captions with hanging indention
% \item[center]
%   provides captions where each line is centered
% \item[centerlast]
%   provides captions where the last line of the paragraph is centered
% \item[nooneline]
%   if a caption fits on \emph{one} line on the page, it will be centered.
%   If you don't like this behaviour, just select this option.
% \item[scriptsize\purerm{, \ldots,\ }Large]
%   sets the font size of the captions
% \item[\vbox{\hbox{up{\rm,} it{\rm,} sl{\rm,} sc{\rm,}}
%       \hbox{md{\rm,} bf{\rm,} rm{\rm,} sf{\rm, or} tt}}]
%   sets the font attribute of the caption labels.
% \item[ruled] supports ruled floats of the \textsf{float} package, see
%   section \ref{sec:float} for details
% \end{Options}\end{quote}
%
% \changes{v1.4}{29 Jan 95}{{\tt\protect\bslash captionsize} changed to {\tt\protect\bslash captionfont}}
% \DescribeMacro{\captionfont}
% \DescribeMacro{\captionlabelfont}
% To setup the font size and attributes of the captions, this package also provides
% the commands |\captionfont| and |\captionlabelfont| to allow a more
% flexible way to customize the captions than the above options could do.
% |\captionfont| is called before each caption, |\captionlabelfont| is
% called just before the label of the caption, so the whole caption
% will be created as
% \begin{quote}
%   |{\captionfont{\captionlabelfont |\meta{label}|: }|\meta{caption}|}| \quad.
% \end{quote}
% Note that these commands are used by the options, e.g.\ the options
% |small| and |sf| are identical to
% \begin{quote} |\renewcommand{\captionfont}{\small}| \quad and\\
%               |\renewcommand{\captionlabelfont}{\sffamily}| \quad. \end{quote}
%
% \DescribeMacro{\captionmargin}
% Furthermore there is a new length |\captionmargin| to setup an extra left and
% right margin for the captions, e.g.\ the command
% \begin{quote} |\setlength{\captionmargin}{10pt}| \end{quote}
% sets this margin to 10pt.
%
% \DescribeMacro{\abovecaptionskip}
% \DescribeMacro{\belowcaptionskip}
% The lengths |\abovecaptionskip| and |\belowcaptionskip| contain the amount of
% white space to leave above and below the caption.
% |\abovecaptionskip| is preset (in the \textsf{article}, \textsf{report} and
% \textsf{book} document class) to 10pt, |\belowcaptionskip| to 0pt.
%
% \subsection{The \puresf{rotating}, \puresf{float} and \puresf{subfigure} package}
% \changes{v1.2}{28 Nov 94}{Support of the {\sf float} package}
% \label{sec:float}
%
% If you want to use this package together with the \textsf{rotating}\cite{rotating},
% \textsf{float}\cite{float} and/or the \textsf{subfigure} package, you have to
% input this package \emph{after} the other ones, like
% \begin{quote}
% |\usepackage{float,rotating,subfigure}|\\
% |\usepackage[centerlast,small,sc]{caption}|
% \end{quote}
% The \textsf{caption} package now redefines the |sidewaysfigure| and
% |sidewaystable| environments and the |\rotcaption| command provided
% by the \textsf{rotating} package from S.~Rahtz and L.~Barroca.
% Note that the |\captionmargin| does not affect the |\rotcaption| command.
%
% It also redefines the captions of the |plain| and |boxed| styled floats
% provided by the \textsf{float} package from A.~Lingnau.
% |ruled| floats are not supported by default, but you can change this via
% setting the option |ruled|.
% Note that the |\captionmargin| is not supported in ruled floats.
%
% \changes{v1.3}{8 Jan 95}{Support of {\tt\protect\bslash captionlabelfont} in subcaptions}
% If the \textsf{subfigure} package from S.D.~Cochran is detected, the options
% |scriptsize|, \ldots, |large| will redefine |\subcapsize| in an adequate way.
% If you redefine |\captionfont| by yourself and use the \textsf{subfigure}
% package, you also have to redefine |\subcapsize| by yourself.
% Also the commands |\@thesubfigure| and |\@thesubtable| will be redefined to
% use the |\captionlabelfont| command, please take this into consideration if
% you redefine |\@thesubfigure| or |\@thesubtable| by yourself.
% E.g.\ a adequate version of the second example in |subfigure.sty| will be:
% \begin{verbatim}
% \renewcommand{\thesubfigure}{\thefigure.\arabic{subfigure}}
% \makeatletter
%   \renewcommand{\@thesubfigure}{{\captionlabelfont\thesubfigure:}\space}
%   \renewcommand{\p@subfigure}{}
% \makeatother
% ...
% \end{verbatim}
%
% \changes{v1.4b}{5 Apr 95}{Adapted to version 2.8 of the rotating package}
% This package cooperates with the version 2.8 (1995/04/02) of the
% \textsf{rotating} package, version 1.2c (1995/03/29) of the \textsf{float}
% package and version 1.6 (1993/05/13) of the \textsf{subfigure} package,
% but will hopefully work with future versions, too.
%
% \section{Example}
% Here's an example figure which was produced with the following code in the
% preamble of this document:
% \begin{quote}
% |\usepackage[hang,small,bf]{caption}|\\
% |\setlength{\captionmargin}{20pt}|
% \end{quote}
% \begin{figure}[!ht]
% \centerline{EXAMPLE FIGURE}
% \caption[Huba]{This is an example caption with a small font and a sans serif label.
%                The hang option was used. There is a left and right margin of 20pt.}
% \end{figure}
%
% \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