% \iffalse meta-comment
%
% ccaption.dtx
% Copyright 1998, 1999 Peter R. Wilson
%
% This program is provided under the terms of the
% LaTeX Project Public License distributed from CTAN
% archives in directory macros/latex/base/lppl.txt.
%
% Author: Peter Wilson (CUA and NIST) (now at: peter.r.wilson@boeing.com)
% 
%<*driver>
\documentclass{ltxdoc}
\usepackage{ccaption}
%%\usepackage[subfigure20]{ccaption}
%%\usepackage{subfigure}
\EnableCrossrefs
\CodelineIndex
\setcounter{StandardModuleDepth}{1}
\begin{document}
  \DocInput{ccaption.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{377}
%
% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
% \DoNotIndex{\@centercr,\@cite}
% \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
% \DoNotIndex{\@input,\@ixpt,\@m}
% \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
% \DoNotIndex{\advance,\Alph,\alph}
% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
% \DoNotIndex{\bullet}
% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
% \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
% \DoNotIndex{\fbox}
% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
% \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
% \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
% \DoNotIndex{\input}
% \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
% \DoNotIndex{\NeedsTeXFormat,\newdimen}
% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
% \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
% \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
% \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
% \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
% \DoNotIndex{\wd,\xiipt,\year,\z@}
%
% \changes{v11}{1997/09/30}{Output character table to class and package files only}
% \changes{v2.1}{1998/10/14}{Added legends}
% \changes{v2.2}{1998/12/19}{Added fixed captions and new floats}
% \changes{v2.2a}{1999/01/23}{Improved documentation}
% \changes{v2.3}{1999/01/24}{Added namedlegend command}
% \changes{v2.3a}{1999/08/06}{Fixed uppercasing bug. Changed UpperCase to MakeUppercase}
% \changes{v2.4}{1999/09/20}{Added subfigure package support}
%
% \def\fileversion{v2.4}
% \def\filedate{1999/09/20}
% \newcommand*{\Lpack}[1]{\textsf {#1}}           ^^A typeset a package
% \newcommand*{\Lopt}[1]{\textsf {#1}}            ^^A typeset an option
% \newcommand*{\file}[1]{\texttt {#1}}            ^^A typeset a file
% \newcommand*{\Lcount}[1]{\textsl {\small#1}}    ^^A typeset a counter
% \newcommand*{\pstyle}[1]{\textsl {#1}}          ^^A typeset a pagestyle
% \newcommand*{\Lenv}[1]{\texttt {#1}}            ^^A typeset an environment
%
% \title{The \Lpack{ccaption} package\thanks{This
%        file has version number \fileversion, last revised
%        \filedate.}}
%
% \author{%
% Peter Wilson\\
% Catholic University of America \\
% Now at {\tt peter.r.wilson@boeing.com}
% }
% \date{\filedate}
% \maketitle
% \begin{abstract}
%  The \Lpack{ccaption} package provides for `continuation' captions,
%  unnumbered captions, and
%  an `anonymous' caption (a legend) that can be used in any
%  environment. It also provides commands to define captions
%  that can be used outside float environments. Further, it provides
%  a mechanism for creating new types of float environments.
%
%  The package has been tested in conjunction with the \Lpack{rotating},
%  \Lpack{caption2} and \Lpack{subfigure} packages.
% \end{abstract}
% \tableofcontents
% \listoftables
% \listoffigures
%
% \StopEventually{}
%
% 
%
% \section{Introduction}
%
% Some publishers require that documents that include multi-part
% tables use a \textit{continuation caption} on all but the first
% part of the multi-part table. For the times where such a table
% is specified by the author as a set of tables, the 
% \Lpack{ccaption} package
% provides a simple `continuation' caption command to meet this 
% requirement. It also provides
% a facility for an `anonymous' caption which can be used in any
% float environment. The package has been tested with the
% \Lpack{rotating}, \Lpack{caption2}, and \Lpack{subfigure} (v2.0) packages.
%
% Captions can be defined that are suitable for use in non-float
% environments, such as placing a picture in a minipage and captioning
% it just as though it had been put into a normal figure environment.
% Further, a mechanism is provided for defining new float environments.
%
% These facilities were originally developed in support of a suite
% for typesetting ISO international standard~\cite{PRW96i},
% but they are generally applicable.
% This manual is typeset according to the conventions of the
% \LaTeX{} \textsc{docstrip} utility which enables the automatic
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
%
%    Section~\ref{sec:usc} provides a short overview of the commands
% in the package and shows some examples of their use, while
% \S\ref{sec:ltx} gives examples of how \LaTeX 's captioning
% style can be changed without the use of any package.
% The implementation is given in Section~\ref{sec:code}.
%
% \section{The \Lpack{ccaption} package} \label{sec:usc}
%
%    The package takes one option, namely \Lopt{subfigure20}, for use
% in conjunction with version 2.0 of Steven Cochran's \Lpack{subfigure}
% package~\cite{SUBFIGURE20}.
%
%    The \LaTeX{} |\caption| command is used within either a |table|
% or a |figure| environment to produce appropriately labelled and numbered
% captions. The captioning text may also be listed via a |\listoftables|
% and/or |\listoffigures| command.
%
% \DescribeMacro{\contcaption}
%    The |\contcaption{|\meta{text}|}| command can be used to put 
% a `continuation' or `concluded'
% caption into a float environment. It neither increments the
% float number nor makes any entry into a float listing, but it
% does repeat the numbering of the previous |\caption| command.
% 
%
%   Table~\ref{tab:m} illustrates the use of the |\contcaption|
% command. The table was produced from the following code.
% \begin{verbatim}
%   \begin{table}
%   \centering
%   \caption{A multi-part table} \label{tab:m}
%   \begin{tabular}{lc} \hline
%    just a single line & 1 \\ \hline
%   \end{tabular}
%   \end{table}
%
%   \begin{table}
%   \centering
%   \contcaption{Continued}
%   \begin{tabular}{lc} \hline
%    just a single line & 2 \\ \hline
%   \end{tabular}
%   \end{table}
%
%   \begin{table}
%   \centering
%   \contcaption{Concluded}
%   \begin{tabular}{lc} \hline
%    just a single line & 3 \\ \hline
%   \end{tabular}
%   \end{table}
% \end{verbatim}
%
%   \begin{table}
%   \centering
%   \caption{A multi-part table} \label{tab:m}
%   \begin{tabular}{lc} \hline
%    just a single line & 1 \\ \hline
%   \end{tabular}
%   \end{table}
%
%   \begin{table}
%   \centering
%   \contcaption{Continued}
%   \begin{tabular}{lc} \hline
%    just a single line & 2 \\ \hline
%   \end{tabular}
%   \end{table}
%
%   \begin{table}
%   \centering
%   \contcaption{Concluded}
%   \begin{tabular}{lc} \hline
%    just a single line & 3 \\ \hline
%   \end{tabular}
%   \end{table}
%
% \DescribeMacro{\legend}
%  The |\legend{|\meta{text}|}| command can be used to put an anonymous 
%  caption into a float environment. 
%
%   \begin{table}
%   \centering
%   \caption{Another table} \label{tab:legend}
%   \begin{tabular}{lc} \hline
%    A legendary table & 5 \\
%    with two lines    & 6 \\ \hline
%   \end{tabular}
%   \legend{The legend}
%   \end{table}
%
%    For example, the following code was used to produce the two-line
% table~\ref{tab:legend}. The |\legend| command can be used within a float
% independently of any |\caption| command.
% \begin{verbatim}
%   \begin{table}
%   \centering
%   \caption{Another table} \label{tab:legend}
%   \begin{tabular}{lc} \hline
%    A legendary table & 5 \\
%    with two lines    & 6 \\ \hline
%   \end{tabular}
%   \legend{The legend}
%   \end{table}
% \end{verbatim}
%
%     \marginpar{\legend{Title legend}
%                This is a marginal note with a legend.}
%
%  Captioned floats are usually thought of in terms of the |table|
%  and |figure| environments. There can be other kinds of float.
%  As perhaps a more interesting example, the following code produces
%  the titled marginal note which should be displayed near here.
% \begin{verbatim}
%     \marginpar{\legend{Title legend}
%                This is a marginal note with a legend.}
% \end{verbatim}
%
%  You can even \legend{Legend in running text} use the |\legend|
%  command in running text, as has been done in this sentence, 
%  but I'm not sure why one might want to do that as \LaTeX{} already
%  provides the |center| environment.
%
% \DescribeMacro{\formatlegend}
% The macro |\formatlegend{|\meta{text}|}| is responsible for specifying
% how the \meta{text} of a |\legend| is to be typeset.
%  The |\legend| command can be used to make unnumbered captions in
% a |figure| or |table| environment. For example, in a |table| environment
% you could do something like:
% \begin{verbatim}
% \begin{table}
% ...
% \renewcommand{\formatlegend}[1]{\tablename: #1}
% ...
% \end{table}
% \end{verbatim}
% In addition, if you wanted the title text to be included in the List of
% Tables, use the |\addcontentsline| command in conjunction with the 
% |\legend|. For example:
% \begin{verbatim}
% \addcontentsline{lot}{table}{Titling text} % left justifified
% \addcontentsline{lot}{table}{\protect\numberline{}Titling text} % indented
% \end{verbatim}
% The first of these forms will align the first line of the titling text
% under the normal table numbers. The second form will align the first
% line of the titling text under the normal table titles. In either case,
% second and later lines of a multi-line title will be aligned under
% the normal title lines.
%
%   \begin{table}
%   \centering
%   \renewcommand{\formatlegend}[1]{\textbf{\tablename} #1}
%   \legend{A legendary table}
%   \addcontentsline{lot}{table}{A legendary table}
%   \addcontentsline{lot}{table}{\protect\numberline{}A legendary table}
%   \begin{tabular}{lc} \hline
%    An unnumbered table & 5 \\
%    with two lines    & 6 \\ \hline
%   \end{tabular}
%   \end{table}
%
% As an example, the last table is produced by the following code:
% \begin{verbatim}
%   \begin{table}
%   \centering
%   \renewcommand{\formatlegend}[1]{\textbf{\tablename} #1}
%   \legend{A legendary table}
%   \addcontentsline{lot}{table}{A legendary table}
%   \addcontentsline{lot}{table}{\protect\numberline{}A legendary table}
%   \begin{tabular}{lc} \hline
%    An unnumbered table & 5 \\
%    with two lines    & 6 \\ \hline
%   \end{tabular}
%   \end{table}
% \end{verbatim}
% Look at the List of Tables to see how the two forms of |\addcontentsline|
% are typeset.
%
% \DescribeMacro{\abovelegendskip}
% \DescribeMacro{\belowlegendskip}
%    Correspondingly to the |\abovecaptionskip| and |\belowcaptionskip|
% commands associated with the |\caption| command, the spacing before 
% and after
% a legend is controlled by the |\abovelegendskip| and |\belowlegendskip|
% commands. If necessary, these can be modified via the |\setlength|
% command. By default these are defined to give a half baseline spacing
% before and after the legend.
%
% \DescribeMacro{\namedlegend}
% As a convenience, the |\namedlegend[|\meta{short-title}|]{|\meta{long-title}|}|
% command is like the |\caption| command except that it does not number
% the caption and, by default, puts no entry into a listof file. Like
% the |\caption| command, it picks up the name to be prepended to the
% title text from the float environment in which it is called (e.g.,
% it uses |\tablename| if called within a |table| environment).
%
% The two examples of tables below are equivalent:
% \begin{verbatim}
% \begin{table}
% \renewcommand{\formatlegend}[1]{\tablename: #1}
% \legend{Long title text}
% ...
% \end{table}
%
% \begin{table}
% \namedlegend[Short title text]{Long title text}
% ...
% \end{table}
% \end{verbatim}
%
% \DescribeMacro{\flegtoc@type}
% The macro |\flegtoc@type{|\meta{title}|}|, where |type| is the name 
% of a float environment
% (e.g., |table|) is called by the |\namedlegend| macro. It is provided
% as a hook that can be used to add \meta{title} to the listof file.
% By default it is defined to do nothing, and can be changed via
% |\renewcommand|. For instance, it could be changed for tables as:
% \begin{verbatim}
% \makeatletter
% \renewcommand{\flegtoc@table}[1]{%
%   \addcontentsline{lot}{table}{#1}}
% \makeatother
% \end{verbatim}
%
%
% \DescribeMacro{\newfixedcaption}
% \DescribeMacro{\renewfixedcaption}
% \DescribeMacro{\providefixedcaption}
%  The |\legend| command produces a plain, unnumbered heading. It can also
% be useful sometimes to have named and numbered captions outside
% a floating environment, perhaps in a |minipage| if you want the table
% or picture to appear at a precise location in your document.
%
% The |\newfixedcaption[|\meta{capcommand}|]{|\meta{command}|}{|\meta{env}|}|
% command, and its friends, can be used to create a new captioning
% \meta{command} that may be used outside the float environment \meta{env}.
% Both the environment \meta{env} and a captioning command, 
% \meta{capcommand}, for that environment must have been defined before
% calling |\newfixedcaption|. Note that |\namedlegend| can be used
% as \meta{capcommand}.
%
% The |\renewfixedcaption| and |\providefixedcaption| commands take the same 
% arguments as |\newfixedcaption|; the three commands are analagous
% to those in the |\newcommand| family.
%
% For example, to define a new |\figcaption| command for captioning pictures
% outside the |figure| environment, do\\
% |\newfixedcaption{\figcaption}{figure}| \\
% The optional \meta{capcommand} argument is the name of the float
% captioning command that is being aliased. It defaults to |\caption|.
% As another example, where the optional argument is required, if you
% want to create a new continuation caption command for non-floating
% tables, say |\ctabcaption|, then do \\
% |\newfixedcaption[\contcaption]{\ctabcaption}{table}|
%
% Captioning commands created by |\newfixedcaption| will be named and
% numbered in the same style as the original \meta{capcommand}, can
% be given a |\label|, and will appear in the appropriate 
% \textbf{List of \ldots}. They can also be used within floating
% environments, but will not use the environment name as a guide to
% the caption name or entry into the \textbf{List of \ldots}. For
% example, using |\ctabcaption| in a |figure| environment will still
% produce a \textbf{Table\ldots} named caption.
%
% These commands have been tested with the \Lpack{caption2} and 
% \Lpack{rotating} packages. They will most likely fail if used with
% the \Lpack{float} package because of the way this package redefines
% the basic |\caption| command.
%
% The \Lpack{float} package, developed by Anselm Lingnau~\cite{LINGNAU95},
%  provides a simple scheme for creating new kinds
% of floats with a variety of captioning styles. Unfortunately the package
% does not effectively seperate the float creation aspects and the captioning
% styles.  I have therefore included in the \Lpack{ccaption} package a
% poor man's version of some aspects of the float creation elements that are
% in \Lpack{float}. Both the commands and their coding differ from those
% in the \Lpack{float} package.
%
% \DescribeMacro{\newfloatenv}
% The command |\newfloatenv[|\meta{within}|]{|\meta{fenv}|}{|\meta{ext}|}{|\meta{capname}|}|
% creates a new kind of floating environment called \meta{fenv}. A caption within
% the environment will be written out to a file with extension \meta{ext}.
% The caption, if present, will start with \meta{capname}. For example, if this
% command had been used to create the |figure| environment for the \Lpack{article}
% class it would have been used as (remembering that \LaTeX{} uses 
% |\figurename| to store the `Figure' text): \\
% |\newfloatenv{figure}{lof}{\figurename}| 
%
% The optional \meta{within} argument can be used if you want the captions to be 
% numbered within a particular document division, as figures are within the
% \Lpack{book} and \Lpack{report} classes with the numbering starting afresh with
% each new chapter. Creating the figure environment for either of these classes
% would have used: \\
% |\newfloatenv[chapter]{figure}{lof}{\figurename}|
%
% The captioning style for floats defined with |\newfloatenv| is the same as
% for figures and tables in the standard classes.
%
% \DescribeMacro{\listfloats}
% The |\listfloats{|\meta{fenv}|}{|\meta{heading}|}| command can be used to
% typeset a listing of the float captions for the float environment
% \meta{fenv}.
% The listing will be preceeded by \meta{heading} which will be in the same
% style as the headings for |\listoftables| and |\listoffigures|. So, just
% to finish off the figure example, instead of putting |\listoffigures| where
% you want the listing to appear, you would have had to use (remembering
% that \LaTeX{} uses |\listfigurename| to store the `List of Figures' text) \\
% |\listfloats{figure}{\listfigurename}|
%
%    As a fuller example, suppose you wanted both figures (which come with the
% standard classes), and diagrams. You could then do something like the following.
% \begin{verbatim}
% \usepackage{ccaption}
% ...
% \newfloatenv{diagram}{dgm}{Diagram}
% \newfixedcaption{\fdiagcaption}{diagram}
% \begin{document}
% ...
% \listoffigures
% \listfloats{diagram}{List of diagrams}
% ...
% \begin{diagram}
% \caption{A diagram} \label{diag1}
% ...
% \end{diagram}
% As diagram~\ref{diag1} shows ...
% \begin{minipage}{.9\textwidth}
% \fdiagcaption{Another diagram} \label{diag2}
% ...
% \end{minipage}
%
% In contrast to diagram~\ref{diag1}, diagram~\ref{diag2} provides ...
% \end{verbatim}
% As a matter of style, though, it would be more in keeping with \LaTeX{}
% to use the following for diagrams:
% \begin{verbatim}
% ...
% \newcommand{\diagramname}{Diagram}
% \newcommand{\listdiagramname}{List of Diagrams}
% \newfloatenv{diagram}{dgm}{\diagramname}
% ...
% \listfloats{diagram}{\listdiagramname}
% ...
% \end{verbatim}
%
%    As a word of warning, if you mix both floats and fixed environments with the
% same kind of caption you have to ensure that they get printed in the correct
% order in the final document. If you do not do this, then the |\list...| of
% captions will come out in the wrong order (the lists are ordered according the
% page number in the typest document, \emph{not} your source input order).
%
% \subsection{Use with the \Lpack{subfigure} package}
%
%     The \Lpack{subfigure} package enables the captioning of sub-figures
% within a larger figure, and similarly for tables. If a figure that
% includes sub-figures is itself continued then it may be desireable to
% continue the captioning of the sub-figures. For example, if Figure~3
% has three sub-figures, say A, B and C, and Figure~3 is continued then
% the sub-figures in the continuation should be D, E, etc.
%
% \DescribeMacro{\contsubfigure}
% \DescribeMacro{\contsubtable}
%  The command |\contsubfigure[|\meta{subcaption}|]{|\meta{figure}|}|
% will continue the sub-figure numbering scheme across (continued) figures.
% The |\contsubtable| command is similar but is intended for sub-tables.
%
% \DescribeMacro{\subconcluded}
% The |\subconcluded| command is used to indicate that the continued 
% sub-figures or sub-tables have been concluded and the numbering
% scheme is reinitialized. The command should be placed immediately
% before the end of the last continued environment.
%
%    For example:
% \begin{verbatim}
% \begin{figure}
% \subfigure{...} % captioned as (a)
% \subfigure{...} % captioned as (b)
% \caption{...}
% \end{figure}
% \begin{figure}
% \contsubfigure{...} % captioned as (c)
% \contsubfigure{...} % captioned as (d)
% \contcaption{Concluded}
% \subconcluded
% \end{figure}
% ...
% \begin{figure}
% \subfigure{...} % captioned as (a)
% \subfigure{...} % captioned as (b)
% \caption{...}
% \end{figure}
% \end{verbatim}
%
% \DescribeMacro{\subbottom}
% \DescribeMacro{\contsubbottom}
% \DescribeMacro{\subtop}
% \DescribeMacro{\contsubtop}
%    Version~2.0 of the \Lpack{subfigure} package assumes that the
% figure or table caption comes at the end of the figure or table
% environment. 
%
%  The \Lpack{ccaption} package provides the commands
% |\subbottom[|\meta{subcaption}|]{|\meta{text}|}| and
% |\contsubbottom[|\meta{subcaption}|]{|\meta{text}|}| for the cases
% when the normal |\caption| or |\contcaption| commands are placed
% at the end of the float environment, and the similar |\subtop|
% and |\contsubtop| commands for when the main caption is at the
% start of the float environment. Actually the \Lpack{ccaption} package
% |\subfigure| and |\contsubfigure| commands are aliases for the |\...bottom|
% commands, and likewise the |\...table| commands
% are aliases for the |\...top| commands.
%
%
% \subsection{How \LaTeX{} makes captions} \label{sec:ltx}
%
% This section provides an overview of how \LaTeX{} creates captions and
% gives some examples of how to change the captioning style without
% having to use any package. 
% The section need not be looked at more than once unless you like 
% reading \LaTeX{} code
% or you want to make changes to \LaTeX 's style of captioning.
%
% The \LaTeX{} kernel provides tools to help in the definition of captions,
% but it is the particular class that decides on their format.
%
% \DescribeMacro{\caption}
% The kernel (in \file{ltfloat.dtx}) defines the caption command via \\
% |\def\caption{\refstepcounter\@captype \@dblarg{\@caption\@captype}}|
%
% \DescribeMacro{\@captype}
% |\@captype| is defined by the code that creates a new float environment
% and is set to the environment's name (see the code for |\@xfloat|
% in \file{ltfloat.dtx}). For a |figure| environment,
% there is an equivalent to \\
% |\def\@captype{figure}|.
%
% \DescribeMacro{\@caption}
% The kernel also provides the 
% |\@caption{|\meta{type}|}[|\meta{short-title}|]{|\meta{full-title}|}|
% command as:
% \begin{verbatim}
% \long\def\@caption#1[#2]#3{%
%   \par
%   \addcontentsline{\csname ext@#1\endcsname}{#1}%    <----
%     {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
%   \begingroup
%      \@parboxrestore
%      \if@minipage
%        \@setminipage
%      \fi
%      \normalsize
%      \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par % <----
%   \endgroup}
% \end{verbatim}
% where \meta{type} is the name of the environment in which the caption
% will be used.
% Putting these three commands together results in the user's view of the caption
% command as |\caption[|\meta{short-title}|]{|\meta{full-title}|}|.
%
% It is the responsibilty of the class (or package) which defines floats
% to provide definitions for |\ext@type|, |\fnum@type| and |\@makecaption|
% which appear in the definition of |\@caption| (in the lines marked
% |<----| above).
%
% \DescribeMacro{\ext@type}
% This macro holds the name of the extension for a `List of\ldots' file.
% For example for the |figure| float environment there is the
% definition equivalent to \\
% |\newcommand{\ext@figure}{lof}|.
%
% \DescribeMacro{\fnum@type}
% This macro is responsible for typesetting the caption number. For example,
% for the |figure| environment there is the definition equivalent to \\
% |\newcommand{\fnum@figure}{\figurename~\thefigure}|.
%
% \DescribeMacro{\@makecaption}
% The |\@makecaption{|\meta{number}|}{|\meta{text}|}|, where \meta{number}
% is a string such as `Table~5.3' and \meta{text} is the caption text,
% performs the typesetting of the caption, and
% is defined in the standard classes (in \file{classes.dtx}) as the
% equivalent of:
% \begin{verbatim}
% \newcommand{\@makecaption}[2]{%
%   \vskip\abovecaptionskip       %  <- 1
%   \sbox\@tempboxa{#1: #2}%      %  <- 2
%   \ifdim \wd\@tempboxa >\hsize
%     #1: #2\par                  %  <- 3
%   \else
%     \global \@minipagefalse
%     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
%   \fi
%   \vskip\belowcaptionskip}      %  <- 4
% \end{verbatim}
%
% \DescribeMacro{\abovecaptionskip}
% \DescribeMacro{\belowcaptionskip}
%  Vertical space is added before and after a caption (lines marked 1 and 4
% in the code for |\@makecaption| above) and the amount of space is given
% by the lengths |\abovecaptionskip| and |\belowcaptionskip|. The
% standard classes set these to 10pt and 0pt respectively. If you want
% to change the space before or after a caption, use |\setlength| to change
% the values.
%
% The actual typesetting of a caption is effectively performed by the code
% in lines marked 2 and 3 in the code for |\@makecaption|. If you want to
% make complex changes to the default captioning style you may have to
% create your own version of |\@caption| using 
% |\renewcommand|. On the other hand, many such changes can be achieved
% by changing the definition of the 
% the appropriate |\fnum@type| command(s). For example: \\
% |\renewcommand{\fnum@figure}{\textbf{\figurename~\thefigure}}|
%
% REMEMBER: If you are doing anything involving commands that include
% the |@| character, and it's not in a class or package file, you have
% to do it within a |\makeatletter| and |\makeatother| pairing. So,
% if you modify the |\fnum@figure| command anywhere in your document
% it has to be done as:
% \begin{verbatim}
% \makeatletter
% \renewcommand{\fnum@figure}{......}
% \makeatother
% \end{verbatim}
%
% \makeatletter
% \renewcommand{\fnum@figure}{\textsc{\figurename~\thefigure}}
% \makeatother
% \begin{figure}
% \centering
% A THOUSAND WORDS\ldots
% \caption{A picture is worth a thousand words}\label{fig:sc}
% \end{figure}
%
% As an example, Figure~\ref{fig:sc} was created by the following code:
% \begin{verbatim}
% \makeatletter
% \renewcommand{\fnum@figure}{\textsc{\figurename~\thefigure}}
% \makeatother
% \begin{figure}
% \centering
% A THOUSAND WORDS\ldots
% \caption{A picture is worth a thousand words}\label{fig:sc}
% \end{figure}
% \end{verbatim}
%
% As another example, suppose that you needed to typeset the |\figurename|
% and its number in a bold font, replace the colon that normally appears
% after the number by a long dash, and typeset the actual title text in
% a sans-serif font, as is illustrated by the caption for 
% Figure~\ref{fig:sf}. The following code does this.
%
% \makeatletter
% \renewcommand{\fnum@figure}[1]{\textbf{\figurename~\thefigure} --- \sffamily}
% \makeatother
% \begin{figure}
%  \centering
%  ANOTHER THOUSAND WORDS\ldots
% \caption{A different kind of figure caption}\label{fig:sf}
% \end{figure}
%
% \begin{verbatim}
% \makeatletter
% \renewcommand{\fnum@figure}[1]{\textbf{\figurename~\thefigure} --- \sffamily}
% \makeatother
% \begin{figure}
%  \centering
%  ANOTHER THOUSAND WORDS\ldots
% \caption{A different kind of figure caption}\label{fig:sf}
% \end{figure}
% \end{verbatim}
% Perhaps a little description of how this works is in order.
% Doing a little bit of \TeX 's macro processing by hand, the typesetting
% lines in |\@makecaption| (lines 2 and 3) get instantiated like: \\
% |\fnum@figure{\figurename~\thefigure}: text| \\
% Redefining |\fnum@figure| to take one argument and then not using the
% value of the argument essentially gobbles up the colon. Using \\
% |\textbf{\figurename~\thefigure}| \\
% in the definition causes |\figurename| and the number to be typeset in
% a bold font. After this comes the long dash. Finally, putting |\sffamily|
% at the end of the redefinition causes any following text (i.e., the actual 
% title) to be typeset using the sans-serif font.
%
% If you do modify |\@makecaption|, then spaces in the definition may be
% important; also you must use the comment (\%) character in the same
% places as I have done above.
%
% You may also want to take a look at the \Lpack{caption2} package by
% Harald Axel Sommerfeldt which provides a ready-made set of differing
% captioning styles. This basically works by redefining the 
% |\@makecaption| command to provide some hooks. As the captions made
% by the \Lpack{ccaption} package use |\@makecaption| they should match
% any style that you pick from \Lpack{caption2}.
%
% In the \Lpack{article} class and its derivatives, captions are numbered
% continuously throughout the document, while in the \Lpack{book} and
% \Lpack{report} classes, numbering starts anew in each chapter.
%
% If you want captions to be numbered anew with sections in the 
% \Lpack{article} class you can do this:
% \begin{verbatim}
% \makeatletter
% \@addtoreset{table}{section}
% \renewcommand{\thetable}{\thesection.\arabic{table}}
% \makeatletter
% \end{verbatim}
% and similarly for all the other float environments.
%
% If you are using the \Lpack{book} or \Lpack{report} class and you want
% the captions to be numbered consecutively throughout the document you
% can do this:
% \begin{verbatim}
% \makeatletter
% \@removefromreset{table}{chapter}
% \renewcommand{\thetable}{\arabic{table}}
% \makeatother
% \end{verbatim}
% and similarly for all the other float environments. Note that you
% will need the \Lpack{remreset} package\footnote{Available on CTAN in
% \texttt{tex-archive/macros/latex/contrib/supported/carlise}.}
% which provides the definition of |\@removefromreset|.
%
% \section{The package code} \label{sec:code}
%
%    Announce the name and version of the package, which requires
% \LaTeXe.
%    \begin{macrocode}
%<*usc>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ccaption}[1999/09/20 v2.4 Extended captioning and new floats]
%    \end{macrocode}
%
% Do the option.
%
% \begin{macro}{\if@contsubfigxx}
% Used to remember if the \Lopt{subfigure20} option has been given.
%    \begin{macrocode}
\newif\if@contsubfigxx
\@contsubfigxxfalse
\DeclareOption{subfigure20}{\@contsubfigxxtrue}
\ProcessOptions
%    \end{macrocode}
% \end{macro}
%
% \subsection{Continuation captions and legends}
%
% \begin{macro}{\contcaption}
%    |\contcaption{|\meta{text}|}| is a user-level command. 
%    It is a simplified
%    version of the normal |\caption| command as it doesn't have to deal
%    with numbering or list of \dots entries.
%    \begin{macrocode}
\newcommand{\contcaption}{\@contcaption\@captype}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@contcaption}
%    This is the workhorse for the |\contcaption| command. In turn,
% it uses the |\@makecaption| command (defined in the usual classes)
% to do most of its work. It
% uses the number of the previous |\caption| command in the same
% type of float and its implementation includes much of the code
% used in the \LaTeX{} |\@caption| command.
% 
%    \begin{macrocode}
\long\def\@contcaption#1#2{%
  \begingroup
     \@parboxrestore
     \if@minipage
       \@setminipage
     \fi
     \normalsize
     \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #2}\par
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\abovelegendskip}
% \begin{macro}{\belowlegendskip}
%    These two lengths control the vertical spacing before and after a
% legend. We will give these values such that a legend will ocupy an
% integral number of lines.
%    \begin{macrocode}
\newlength{\abovelegendskip}
\setlength{\abovelegendskip}{0.5\baselineskip}
\newlength{\belowlegendskip}
\setlength{\belowlegendskip}{\abovelegendskip}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\legend}
%    The command is called as |\legend{|\meta{text}|}|. It is intended
% to be used in a float environment for an `anonymous' caption.
%
%    The implementation is similar to the |\caption| command.
%    \begin{macrocode}
\newcommand{\legend}[1]{%
  \par
  \begingroup
     \@parboxrestore
     \if@minipage
       \@setminipage
     \fi
     \normalsize
     \@makelegend{}{\ignorespaces \formatlegend{#1}}\par
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\formatlegend}
% |\formatlegend{|\meta{text}|}| is resonsible for typesetting a legend's
% text.
%    \begin{macrocode}
\newcommand{\formatlegend}[1]{#1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makelegend}
%    The implementation of this command is similar to that of the
% |\@makecaption| command in the standard classes, or to the redefined
% version of |\@makecaption| if the \Lpack{caption2} package has been
% loaded.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{caption2}{%
    \newcommand{\@makelegend}[2]{%
      \vskip\abovelegendskip
      \realcaptionwidth\linewidth
      \def\captionlabel{#1}%
      \def\captiontext{#2}%
      \usecaptionstyle{\caption@style}%
      \vskip\belowlegendskip}}{%
    \newcommand{\@makelegend}[2]{%
      \vskip\abovelegendskip
      \sbox\@tempboxa{#1 #2}%
      \ifdim \wd\@tempboxa >\hsize
        #1 #2\par
      \else
        \global \@minipagefalse
        \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
      \fi
      \vskip\belowlegendskip}}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\namedlegend}
% |\namedlegend[|\meta{short-title}|]{|\meta{long-title}|}| is like the
% |\caption| command except that it does not number the caption.
%    \begin{macrocode}
\newcommand{\namedlegend}{\@dblarg{\@legend\@captype}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@legend}
% |\@legend{|\meta{type}|}[|\meta{short-title}|]{|\meta{long-title}|}|
% is the workhorse for the |\namedlegend| command. In turn, it calls
% |\@makelegend|. It requires two commands to have been defined, namely
% |\flegtoc@type| and |\fleg@type|. The command |\flegtoc@type{|\meta{text}|}|
% is responsible for writing a title text to the appropriate listof file.
% |\fleg@type| is responsible for typeseting the name of the legend.
%    \begin{macrocode}
\long\def\@legend#1[#2]#3{%
  \par
  \csname flegtoc@#1\endcsname{#2}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \normalsize
    \@makelegend{\csname fleg@#1\endcsname}{\formatlegend{#3}}\par
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\flegtoc@table}
% \begin{macro}{\flegtoc@figure}
%  These macros write a |\namedlegend| title to the respective listof file.
% By default they do nothing.
%    \begin{macrocode}
\newcommand{\flegtoc@table}[1]{}
\newcommand{\flegtoc@figure}[1]{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fleg@table}
% \begin{macro}{\fleg@figure}
%  These macros typeset the name before the title of a |\namedlegend|. By
% default they are defined to mimic the normal captioning style.
%    \begin{macrocode}
\newcommand{\fleg@table}{\tablename: }
\newcommand{\fleg@figure}{\figurename: }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Non-float captions}
%
% \begin{macro}{\newfixedcaption}
% \begin{macro}{\renewfixedcaption}
% \begin{macro}{\providefixedcaption}
% These commands are defined in terms of their |\...command| counterparts.\\
% Call as |\...fixedcaption[|\meta{capcommand}|]{|\meta{command}|}{|\meta{env}|}|
%    \begin{macrocode}
\newcommand{\newfixedcaption}[3][\caption]{%
  \newcommand{#2}{\def\@captype{#3}#1}}
\newcommand{\renewfixedcaption}[3][\caption]{%
  \renewcommand{#2}{\def\@captype{#3}#1}}
\newcommand{\providefixedcaption}[3][\caption]{%
  \providecommand{#2}{\def\@captype{#3}#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{New floats}
%
% To define a float environment, say |fenv|, the following macros must be defined:
% \begin{itemize}
% \item |\fps@fenv| The default placement specifier (normally |tbp|). 
% \item |\ftype@fenv| The type number which is an integer and a power of 2.
% \item |\ext@fenv| The file extension for the contents list.
% \item |\c@fenv| A counter for the environment (for caption numbering).
% \item |\fnum@fenv| A macro to generate the caption `number'.
% \item |\l@fenv| A macro to produce an entry in a list of\ldots.
% \item |\flegtoc@fenv| A macro to write a |\namedlegend| title to a listof file.
% \item |\fleg@fenv| A macro to typeset the name of a |\namedlegend|.
% \end{itemize}
% Note that the last two are only required for the \Lpack{ccaption} package
% while the others are required for any new float, whether or not the
% \Lpack{ccaption} package is being used.
%
%
%
% \begin{macro}{newflo@tctr}
% A counter for the type number of a new float. Normally
% figures are of type 1, tables type 2, and the next float type is then 4, and so
% on. 
%    \begin{macrocode}
\newcounter{newflo@tctr}
\@ifundefined{c@figure}{\setcounter{newflo@tctr}{1}}{
  \@ifundefined{c@table}{\setcounter{newflo@tctr}{2}}{
    \setcounter{newflo@tctr}{4}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newfloatenv}
% The command |\newfloatenv[|\meta{within}|]{|\meta{fenv}|}{|\meta{ext}|}{|\meta{capname}|}|
% creates a new float environment called \meta{fenv}, with captions named
% \meta{capname}. Caption titles will be written to file |\jobname.|\meta{ext}.
% \meta{within} can be used for numbering within the document \meta{within}
% division.
%
% Start off by checking if this is not a new float, by testing the float counter.
% We can rely on the normal \LaTeX{} command/environment making code to handle
% the case when \meta{fenv} has been defined previously.
%    \begin{macrocode}
\newcommand{\newfloatenv}[4][*]{%
  \@ifundefined{c@#2}{%
%    \end{macrocode}
% It hasn't been defined before, so check if numbering is going to be within
% a some other numbering scheme.
%    \begin{macrocode}
    \def\opt@rg{#1}
    \ifcat*\opt@rg
      \newcounter{#2}
    \else
%    \end{macrocode}
% We are numbering within, so check that there is a within counter.
%    \begin{macrocode}
      \@ifundefined{c@#1}{\PackageWarning{ccaption}%
                          {#1 has no counter for use as a `within'}
        \newcounter{#2}}%
%    \end{macrocode}
% There is a valid within counter. Do complicated things to define the |\thefenv|.
% With just |\newcounter{#2}| |\the#2| is automatically set to arabic numbering.
% We have to set it to |\thewithin.\the#2|.
%    \begin{macrocode}
      {\newcounter{#2}[#1]%
       \expandafter\edef\csname the#2\endcsname{%
         \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}}
    \fi
%    \end{macrocode}
% Next we set the type for the new float, using \Lcount{newflo@tctr}, and doubling
% it afterwards.
%    \begin{macrocode}
    \@namedef{ftype@#2}{\value{newflo@tctr}} % float type
    \addtocounter{newflo@tctr}{\value{newflo@tctr}}
%    \end{macrocode}
% Having set up the counters, the rest is easy. We just define the commands that
% are needed for floats.
%    \begin{macrocode}
    \@namedef{fps@#2}{tbp}                   % default positioning
    \@namedef{ext@#2}{#3}                    % file extension
    \@namedef{fnum@#2}{#4~\@nameuse{the#2}}  % caption naming
    \@namedef{fleg@#2}{#4: }                 % named legend naming
    \@namedef{flegtoc@#2}##1{}                % legend title to listof
%    \end{macrocode}
% Define the macro that will format the entries. This is a straight copy
% from the book/article class code for figures (tables).
%    \begin{macrocode}
    \@namedef{l@#2}{\@dottedtocline{1}{1.5em}{2.3em}}%
%    \end{macrocode}
%  Finally, define the new (starred) floating environment.
%    \begin{macrocode}
    \newenvironment{#2}{\@float{#2}}{\end@float}
    \newenvironment{#2*}{\@dblfloat{#2}}{\end@dblfloat}
   }{%
%    \end{macrocode}
% Error handling for previously defined environment.
%    \begin{macrocode}
     \PackageError{ccaption}{#2 has been previously defined}{\@eha}
    }
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listfloats}
% The |\listfloats{|\meta{fenv}|}{|\meta{heading}|}| command can be 
% used to produce a list of floats for \meta{fenv}. The listing
% has title \meta{heading}. First check if there is a file extension 
% for \meta{fenv}.
%    \begin{macrocode}
\newcommand{\listfloats}[2]{%
  \@ifundefined{ext@#1}{\PackageError{ccaption}%
                        {File extension for #1 is undefined}{\@eha}}{%
%    \end{macrocode}
% Decide on the heading style. For classes with chapters this will be
% a |\chapter*| heading, otherwise a |\section*| heading. Copy the code from
% the book or article class as appropriate. Section style heading is easy.
%    \begin{macrocode}
    \@ifundefined{chapter}{%
      \section*{#2\@mkboth{\MakeUppercase{#2}}{\MakeUppercase{#2}}}}{%
%    \end{macrocode}
%  Chapter style is more tedious.
%    \begin{macrocode}
      \if@twocolumn
        \@restonecoltrue\onecolumn
      \else
        \@restonecolfalse
      \fi     
      \chapter*{#2\@mkboth{\MakeUppercase{#2}}{\MakeUppercase{#2}}}}%
%    \end{macrocode}
% And start reading the file.
%    \begin{macrocode}
    \@starttoc{\@nameuse{ext@#1}}
%    \end{macrocode}
% At the end, if it was a |\chapter*| style heading we may have to restore
% twocolumn typesetting.
%    \begin{macrocode}
    \@ifundefined{chapter}{}{\if@restonecol\twocolumn\fi}
  }}
%    \end{macrocode}
% \end{macro}
%
% \subsection{The \Lopt{subfigure20} option}
%
%     In order to eliminate an ordering dependency between the 
% \Lpack{subfigure} and \Lpack{ccaption} packages, modifications to the
% original \Lpack{subfigure} code have to be done at the start of the
% document after all packages have been loaded.
%    \begin{macrocode}
\AtBeginDocument{%
  \if@contsubfigxx
%    \end{macrocode}
%
% \begin{macro}{\@subcaption}
% The original |\@subcaption| command produces unexpected results in the
% ToC (i.e., |numberline| appears instead of |\numberline|). I have also
% modified it so that when a top main caption is being used, it
% adds the subcaption to the ToC dfirectly.
%    \begin{macrocode}
\renewcommand{\@subcaption}[2]{%
  \begingroup
    \let\label\@gobble
    \if@contbotsub
%%%      \def\protect{\string\string\string} % this was the problem
      \xdef\@subfigcaptionlist{%
      \@subfigcaptionlist,%
%%    {\protect\numberline {\@currentlabel}%
      {\string\numberline {\@currentlabel}%
       \noexpand{\ignorespaces #2}}}%
    \else
      \addcontentsline{\csname ext@#1\endcsname}{#1}%
        {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
      \gdef\@subfigcaptionlist{}
    \fi
  \endgroup
  \@nameuse{@make#1caption}{\@nameuse{@the#1}}{#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subfigure}
% \begin{macro}{\subtable}
%  These are revised versions of the original commands. They are now
% aliases for |\subbottom| and |\subtop| respectively. In their original
% form they were both effectively aliases for |\subbottom| only.
%    \begin{macrocode}
\let\subfigure\subbottom
\let\subtable\subtop
%    \end{macrocode}
% \end{macro}
% \end{macro}
% This is the end of |\AtBeginDocument| code.
%    \begin{macrocode}
\fi
}
%    \end{macrocode}
%
% \begin{macro}{\if@contbotsub}
% A flag indicating whether the main caption is at the top or
% bottom of the float environment. For reasons that I don't understand,
% the |\newif| cannot be within an |\if......\fi| construct.
%    \begin{macrocode}
\newif\if@contbotsub
\@contbotsubtrue
%    \end{macrocode}
% \end{macro}
%
%  Do the remaining code for the option, if called for.
%    \begin{macrocode}
\if@contsubfigxx
%    \end{macrocode}
% \begin{macro}{\@contkeep}
% \begin{macro}{\@contset}
% \begin{macro}{\subconcluded}
%  |\@contkeep| stores the value of the sub-caption counter, and
% |\@contset| assigns the stored value to the sub-caption counter.
% |\subconcluded| resets the sub-caption counter to zero, ready for
% a new non-continued float.
%    \begin{macrocode}
\newcounter{@contsubnum}
\newcommand{\@contkeep}{\setcounter{@contsubnum}{\value{sub\@captype}}}
\newcommand{\@contset}{\setcounter{sub\@captype}{\value{@contsubnum}}}
\newcommand{\subconcluded}{\setcounter{sub\@captype}{0}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\subbottom}
%  |\subbottom[|\meta{caption}|]{|\meta{text}|}| typesets a subcaption
% when the main caption is at the end of the float environment. The code
% is a slight modification of the original |\subfigure| command in that
% the bottom flag is added and set to true and the subcaption number is
% stored.
%    \begin{macrocode}
\newcommand{\subbottom}{%
  \@contbotsubtrue
  \bgroup
    \advance\csname c@\@captype\endcsname\@ne
    \refstepcounter{sub\@captype}\@contkeep%
    \leavevmode
    \@ifnextchar [%
      {\@subfloat{sub\@captype}}
      {\@subfloat{sub\@captype}[\@empty]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\contsubbottom}
%  The continued version of |\subbottom|. It restores the kept subcaption 
% number before incrementing and keeping it.
%    \begin{macrocode}
\newcommand{\contsubbottom}{%
  \@contbotsubtrue
\bgroup
  \@contset
  \refstepcounter{sub\@captype}\@contkeep%
  \leavevmode
  \@ifnextchar [%
    {\@subfloat{sub\@captype}}
    {\@subfloat{sub\@captype}[\@empty]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subtop}
%  |\subtop[|\meta{caption}|]{|\meta{text}|}| typesets a subcaption
% when the main caption is at the top of the float environment. This
% is new code and like the |\subbottom| code but the main caption
% number does not require incrementing.
%    \begin{macrocode}
\newcommand{\subtop}{%
  \@contbotsubfalse
\bgroup
    \refstepcounter{sub\@captype}\@contkeep%
    \leavevmode
    \@ifnextchar [%
      {\@subfloat{sub\@captype}}
      {\@subfloat{sub\@captype}[\@empty]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\contsubtop}
%  The continued version of |\subtop|. It restores the kept subcaption 
% number before incrementing and keeping it.
%    \begin{macrocode}
\newcommand{\contsubtop}{%
  \@contbotsubfalse
\bgroup
  \@contset
  \refstepcounter{sub\@captype}\@contkeep%
  \leavevmode
  \@ifnextchar [%
    {\@subfloat{sub\@captype}}
    {\@subfloat{sub\@captype}[\@empty]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@contcaption}
% The |\@contcaption| command must be modified to add the listed
% subcaptions (if any, and there should be none for top main captions)
% to the ToC.
%    \begin{macrocode}
\let\subfig@oldcontcaption\@contcaption
\long\def\@contcaption#1#2{%
  \subfig@oldcontcaption{#1}{#2}%
  \@for \@tempa:=\@subfigcaptionlist \do {%
    \ifx\@empty\@tempa\relax \else
      \addcontentsline
        {\@nameuse{ext@sub#1}}%
        {sub#1}%
        {\@tempa}%
     \fi}%
  \gdef\@subfigcaptionlist{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\contsubtable}
% \begin{macro}{\contsubfigure}
%  Aliases for |\contsubtop| and |\contsubbottom|, respectively.
%    \begin{macrocode}
\let\contsubtable\contsubtop
\let\contsubfigure\contsubbottom
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
%
% The end of the \Lopt{subfigure20} option code.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%
%    The end of this package.
%    \begin{macrocode}
%</usc>
%    \end{macrocode}
%
%
% \bibliographystyle{alpha}
%
% \begin{thebibliography}{GMS94}
%
% \bibitem[Coc95]{SUBFIGURE20}
% Steven Douglas Cochran.
% \newblock \emph{The subfigure package}.
% \newblock March 1995.
% \newblock (Available from CTAN as file \texttt{subfigure.dtx})
%
% \bibitem[GMS94]{GOOSSENS94}
% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
% \newblock {\em The LaTeX Companion}.
% \newblock Addison-Wesley Publishing Company, 1994.
%
% \bibitem[Lin95]{LINGNAU95}
% Anselm Lingnau.
% \newblock {\em {An Improved Environment for Floats}}.
% \newblock March 1995.
% \newblock (Available from CTAN as file \texttt{float.dtx})
%
% \bibitem[Wil96]{PRW96i}
% Peter~R. Wilson.
% \newblock {\em {LaTeX for standards: The LaTeX package files user manual}}.
% \newblock NIST Report NISTIR, June 1996.
%
% \end{thebibliography}
%
% 
% \Finale
% \PrintIndex
%
\endinput

%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}


