%%
%% This is file `subfig.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% subfig.dtx  (with options: `package')
%% 
%% Copyright (C) 2003 Steven Douglas Cochran.
%% 
%% This file is NOT the source for the subfig package, because almost
%% all comments have been stripped from it.  It is NOT the preferred form
%% of the subfig package for making modifications to it.
%% 
%% Therefore you can NOT redistribute and/or modify THIS file.  You can
%% however redistribute the complete source package (README, Makefile,
%% subfig.dtx, and subfig.ins as well as the test/example file
%% test1.tex) and/or modify it under the terms 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/09/03 or later.
%% 
%% The subfig package is distributed in the hope that it will be
%% useful, but `as is', WITHOUT WARRANTY OF ANY KIND, either expressed
%% or implied, including, but not limited to, the implied warranties of
%% MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE.  See the LaTeX
%% Project Public License for more details.
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% @LaTeX-style-file{
%%    author     = "Steven Douglas Cochran",
%%    version    = "1.2",
%%    date       = "2004/01/28",
%%    time       = "11:40:56",
%%    filename   = "subfig.sty",
%%    address    = "Digital Mapping Laboratory,
%%                  School of Computer Science
%%                  Carnegie-Mellon University,
%%                  5000 Forbes Avenue
%%                  Pittsburgh, PA 15213-3890
%%                  USA",
%%    telephone  = "+1 412.268.5654",
%%    fax        = "+1 412.268.5576",
%%    email      = "cochran@ieee.org",
%%    codetable  = "ISO/ASCII",
%%    keywords   = "LaTeX, float, sub-float, continued figure",
%%    supported  = "yes",
%%    abstract   = "LaTeX package for providing support for the
%%                  inclusion of small, `sub', figures and tables.  It
%%                  simplifies the positioning, captioning and
%%                  labeling of them within a single figure or table
%%                  environment.  In addition, this package allows
%%                  such sub-captions to be written to the List of
%%                  Figures or List of Tables if desired."
%% }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{subfig}[2004/01/28 ver: 1.2 subfig package]
\RequirePackage{caption}[2003/12/20]
\def\sf@ifpositiontop{%
  \ifx\caption@position\@firstoftwo \let\next\@firstoftwo \else
  \let\next\@secondoftwo \fi \next}
\def\DeclareCaptionListOfFormat#1{%
  \@namedef{caption@lstfmt@#1}##1##2}
\@onlypreamble\DeclareCaptionListOfFormat
\def\caption@setlistofformat#1{%
  \@ifundefined{caption@lstfmt@#1}{%
    \PackageError
      {subfig}%
      {Undefined caption list-of format `#1'}%
      {\caption@eh}%
  }{%
   \expandafter\let\expandafter\caption@lstfmt
         \csname caption@lstfmt@#1\endcsname}}
\DeclareCaptionListOfFormat{empty}{}
\DeclareCaptionListOfFormat{simple}{#1#2}
\DeclareCaptionListOfFormat{parens}{#1(#2)}
\DeclareCaptionListOfFormat{subsimple}{#2}
\DeclareCaptionListOfFormat{subparens}{(#2)}
\DeclareCaptionOption{listofformat}{\caption@setlistofformat{#1}}
\def\sf@indent{3.8em}
\define@key{caption}{listofindent}[3.8em]{\def\sf@indent{#1}}
\def\sf@numwidth{2.5em}
\define@key{caption}{listofnumwidth}[2.5em]{\def\sf@numwidth{#1}}
\newcounter{KVtest}
\def\sf@config{config}
\def\sf@split#1=#2=#3\relax{%
  \setcounter{KVtest}{1}%
  \KV@@sp@def\@tempa{#1}%
  \ifx\@tempa\@empty
  \else\ifx\@tempa\sf@config
    \setcounter{KVtest}{2}%
    \expandafter\let\expandafter\@tempc
        \csname\KV@prefix\@tempa\endcsname
    \ifx\@tempc\relax
      \KV@errx
          {\@tempa\space undefined}%
    \else\ifx\@empty#3\@empty
      \KV@default
    \else
      \KV@@sp@def\@tempb{#2}%
      \expandafter\@tempc\expandafter{\@tempb}\relax
    \fi\fi
  \fi\fi}
\def\ProcessPackageOptions{%
  \def\KV@prefix{KV@\@currname @}%
  \let\@tempc\relax
  \let\caption@tempa\@empty
  \@for\CurrentOption:=\@classoptionslist\do{%
    \@ifundefined{KV@caption@\CurrentOption}{}{%
      \edef\caption@tempa{\caption@tempa,\CurrentOption,}%
      \@expandtwoargs\@removeelement\CurrentOption
        \@unusedoptionlist\@unusedoptionlist}}%
  \edef\caption@tempb{\@ptionlist{\@currname.\@currext}}%
  \@for\CurrentOption:=\caption@tempb\do{%
    \expandafter\sf@split\CurrentOption==\relax
    \ifnum\c@KVtest<2\relax
      \edef\caption@tempa{\caption@tempa,\CurrentOption,}%
    \fi}%
  \edef\caption@tempa{%
    \noexpand\captionsetup[subfloat]{\caption@tempa}}%
  \caption@tempa}
\def\@dottedxxxline#1#2#3#4#5#6#7{%
  \begingroup
    \@ifundefined{caption@setfloattype}%
      \caption@settype
      \caption@setfloattype
          {#1}
    \caption@settype{subfloat}%
    \caption@settype{sub#1}%
    \ifnum #3>\@nameuse{c@#2depth}\else
      \@dottedtocline{\z@}{#4}{#5}{#6}{#7}%
    \fi
  \endgroup}
\newif\ifmaincaptiontop
\def\newsubfloat{%
  \@ifnextchar[  %] bracket matching
    {\@newsubfloat}
    {\@newsubfloat[]}}
\def\@newsubfloat[#1]#2{%
  \@ifundefined{c@sub#2}{%
    \newcounter{sub#2}[#2]
    \newcounter{sub#2@save}%
    \@namedef{sub#2name}{}%
    \@namedef{p@sub#2}{\@nameuse{the#2}}%
    \@namedef{thesub#2}{\alph{sub#2}}%
    \@namedef{ext@sub#2}{\@nameuse{ext@#2}}%
    \@namedef{l@sub#2}{%
        \@dottedxxxline{#2}%
            {\@nameuse{ext@sub#2}}{2}{\sf@indent}{\sf@numwidth}}%
    \@ifundefined{c@\@nameuse{ext@#2}depth}{%
      \expandafter\newcounter\expandafter{\@nameuse{ext@#2}depth}%
      \expandafter\addtocounter\expandafter{\@nameuse{ext@#2}depth}\@ne}{}%
    \edef\sf@counterlist{%
      \@ifundefined{sf@counterlist}{}%
        {\sf@counterlist,}sub#2}%
    \captionsetup[sub#2]{#1}%
  }{%
    \PackageWarning{subfig}{%
        The sub#2\space type is already defined.}%
  }}
\@onlypreamble\@newsubfloat
\@onlypreamble\newsubfloat
\newskip\sf@farskip
\sf@farskip 10\p@
\define@key{caption}{farskip}[10\p@]{\sf@farskip=#1}
\newdimen\sf@captopadj
\sf@captopadj \z@
\define@key{caption}{topadjust}[\z@]{\sf@captopadj=#1}
\newskip\sf@capskip
\sf@capskip 4\p@
\define@key{caption}{captionskip}[4\p@]{\sf@capskip=#1}
\newskip\sf@nearskip
\sf@nearskip \z@
\define@key{caption}{nearskip}[5\p@]{\sf@nearskip=#1}
\let\caption@@orig\@caption
\let\sf@oldcaption\caption@@orig
\def\@caption{\caption@}
\captionsetup[subfloat]{%
    font=footnotesize,
    labelformat=parens,labelsep=space,
    listofformat=subparens}
\define@key{subfig}{config}[subfig]{%
  \InputIfFileExists{#1.cfg}{%
    \typeout{***********************************************^^J%
             * Subfig configuration file #1.cfg used ^^J%
             ***********************************************}%
  }{%
    \PackageWarning{subfig}{Configuration file #1.cfg not found}}%
}
\ProcessPackageOptions
\@ifundefined{c@subfigure}{\newsubfloat{figure}}{}
\@ifundefined{c@subtable}{\newsubfloat{table}}{}
\AtEndOfPackage{%
  \global\let\KV@config@\relax
  \global\let\sf@split\relax
  \global\let\ProcessPackageOptions\relax
  \global\let\@unprocessedoptions\relax
  \let\CurrentOption\@empty
}
\newskip\sf@top
\newskip\sf@bottom
\def\subfloat{%
  \ifx\@captype\@undefined
    \@latex@error{\noexpand\subfloat outside float}\@ehd
     \expandafter\@gobble
  \else
    \expandafter\@firstofone
  \fi
  {\sf@subfloat}}
\def\sf@subfloat{%
  \begingroup
    \@ifundefined{caption@setfloattype}%
      \caption@settype
      \caption@setfloattype
          \@captype
    \sf@ifpositiontop{%
      \maincaptiontoptrue
    }{%
      \maincaptiontopfalse
    }%
    \caption@settype{subfloat}%
    \caption@settype{sub\@captype}%
    \let\sf@oldlabel=\label
    \let\label=\subfloat@label
    \ifmaincaptiontop\else
      \advance\@nameuse{c@\@captype}\@ne
    \fi
    \refstepcounter{sub\@captype}%
    \setcounter{sub\@captype @save}{\value{sub\@captype}}%
    \@ifnextchar [%  %] match left bracket
      {\sf@@subfloat}%
      {\sf@@subfloat[\@empty]}}
\long\def\sf@@subfloat[#1]{%
    \@ifnextchar [%  %] match left bracket
      {\sf@@@subfloat{sub\@captype}[{#1}]}%
      {\sf@@@subfloat{sub\@captype}[\@empty{#1}][{#1}]}}
\long\def\sf@@@subfloat#1[#2][#3]#4{%
    \@tempcnta=\@ne
    \if@minipage
      \@tempcnta=\z@
    \else\ifdim \lastskip=\z@ \else
      \@tempcnta=\tw@
    \fi\fi
    \ifmaincaptiontop
      \sf@top=\sf@nearskip
      \sf@bottom=\sf@farskip
    \else
      \sf@top=\sf@farskip
      \sf@bottom=\sf@nearskip
    \fi
    \leavevmode
    \setbox\@tempboxa \hbox{#4}%
    \@tempdima=\wd\@tempboxa
    \vtop\bgroup
      \vbox\bgroup
        \ifcase\@tempcnta
          \@minipagefalse
        \or
%%       \leaders\vrule\vskip\sf@top                  %debug
          \vskip\sf@top
        \or
          \ifdim \lastskip=\z@ \else
            \@tempskipb\sf@top\relax\@xaddvskip
          \fi
        \fi
        \sf@ifpositiontop{%
          \ifx \@empty#3\relax \else
            \@subcaption{#1}{#2}{#3}%
%%          \leaders\vrule width.8pt\vskip\sf@capskip    %debug
%%          \leaders\vrule width1.2pt\vskip\sf@captopadj %debug
            \vskip\sf@capskip
            \vskip\sf@captopadj
          \fi\egroup
          \hrule width0pt height0pt depth0pt
          \box\@tempboxa
        }{%
          \box\@tempboxa\egroup
          \ifx \@empty#3\relax \else
%%          \leaders\vrule width.8pt\vskip\sf@capskip    %debug
            \vskip\sf@capskip
            \hrule width0pt height0pt depth0pt
            \@subcaption{#1}{#2}{#3}%
          \fi
        }%
%%    \leaders\vrule\vskip\sf@bottom  %debug
      \vskip\sf@bottom
    \egroup
    \ifmaincaptiontop\else
      \global\advance\@nameuse{c@\@captype}\m@ne
    \fi
  \endgroup}
\long\def\@subcaption#1#2#3{%
  \ifx \relax#2\relax \else
    \bgroup
      \let\label=\@gobble
      \let\protect=\string
      \def\@subcaplabel{%
        \caption@lstfmt{\@nameuse{p@#1}}{\@nameuse{the#1}}}%
      \xdef\sf@captionlist{%
        \sf@captionlist,%
        {\protect\numberline{\@subcaplabel}\noexpand{\ignorespaces #2}}}%
    \egroup
  \fi
  \bgroup
    \ifx \relax#3\relax
      \let\captionlabelsep=\relax
    \fi
    \hb@xt@\the\@tempdima{%
      \hss
      \parbox[t]{\the\@tempdima}{%
        \caption@make
            {\@nameuse{sub\@captype name}}%
            {\@nameuse{thesub\@captype}}%
            {#3}}%
      \hss}%
  \egroup}
\def\sf@captionlist{}
\def\listsubcaptions{%
  \@ifstar
    {\gdef\sf@captionlist{}}%
    {\@listsubcaptions{\@captype}}}
\def\@listsubcaptions#1{%
  \@ifundefined{@captype}{}{%
    \@ifundefined{ext@sub#1}{}{%
      \@for \sf@temp:=\sf@captionlist \do {%
        \ifx \@empty\sf@temp\relax \else
          \sf@addcontentsline
            {\@nameuse{ext@sub#1}}%
            {sub#1}%
            {\sf@temp}%
        \fi}}}%
  \gdef\sf@captionlist{}}
\long\def\caption@#1[#2]#3{%
  \@ifundefined{caption@setfloattype}%
    \caption@settype
    \caption@setfloattype
        \@captype
  \sf@ifpositiontop{%
    \@listsubcaptions{#1}%
    \sf@oldcaption{#1}[{#2}]{#3}%
  }{%
    \sf@oldcaption{#1}[{#2}]{#3}%
    \@listsubcaptions{#1}%
  }}
\AtBeginDocument{%
  \let\sf@addcontentsline=\addcontentsline}
\let\sf@oldlabel=\relax
\def\subfloat@label{%
  \@ifnextchar(%   %) match left parenthesis
    {\sf@sub@label}
    {\sf@sub@label(Sub\@captype\space
                   \@ifundefined{thechapter}{}{%
                     \@nameuse{thechapter}\space}%
                   \@nameuse{p@sub\@captype}%
                   \@nameuse{thesub\@captype}.)}}
\let\sub@label=\subfloat@label
\def\sf@sub@label(#1)#2{%
  \ifhyperrefloaded
    \protected@edef\@currentlabelname{%
      \expandafter\strip@period #1\relax.\relax\@@@}%
  \fi
  \sf@@sub@label{#2}}
\def\sf@@sub@label#1{%
  \@bsphack
  \sf@oldlabel{#1}%
  \ifhyperrefloaded
    \protected@write\@auxout{}{%
        \string\newlabel{sub@#1}%
            {{\caption@lstfmt
               {\@nameuse{p@sub\@captype}}%
               {\@nameuse{thesub\@captype}}}%
             {\@nameuse{thesub\@captype}}%
             {\expandafter\strip@period\@currentlabelname\relax.\relax\@@@}%
             {\@currentHref}%
             {}}}%
  \else
    \protected@write\@auxout{}{%
        \string\newlabel{sub@#1}%
            {{\caption@lstfmt
               {\@nameuse{p@sub\@captype}}%
               {\@nameuse{thesub\@captype}}}%
            {\@nameuse{thesub\@captype}}}}%
  \fi
  \@esphack}
\def\subref{%
  \@ifstar
    \sf@@subref
    \sf@subref}
\def\sf@subref#1{\ref{sub@#1}}
\def\sf@@subref#1{\pageref{sub@#1}}
\newif\if@ccflag
\@ccflagfalse
\AtBeginDocument{%
  %
  \let\sf@refstepcounter=\refstepcounter
  %
  \@ifpackageloaded{captcont}{}{%
    \def\refsteponlycounter#1{%
      \if@ccflag
        \global\expandafter\advance\csname c@#1\endcsname\@ne
        \let\sf@temp\protect
        \def\protect{\noexpand\protect\noexpand}%
        \edef\@currentlabel{\csname p@#1\endcsname\csname the#1\endcsname}%
        \let\protect\sf@temp
      \else
        \sf@refstepcounter{#1}%
      \fi
      \@ccflagfalse}%
  }%
  %
  \def\ContinuedFloat{%
    \addtocounter{\@captype}{\m@ne}%
    \setcounter{sub\@captype}{\value{sub\@captype @save}}%
    \@ccflagtrue}}
\def\sf@caption{%
  \let\refstepcounter=\refsteponlycounter
  \sf@savecaption}
\AtBeginDocument{
  \let\sf@savecaption=\caption
  \let\caption=\sf@caption
}
\let\sf@end@float=\end@float
\def\end@float{%
  \@ifundefined{sf@counterlist}{}{%
    \@for\sf@temp:=\sf@counterlist\do{%
      \setcounter{\sf@temp}{\z@}}%
    \@listsubcaptions{\@captype}}%
  \sf@end@float}%
\let\sf@end@dblfloat=\end@dblfloat
\def\end@dblfloat{%
  \@ifundefined{sf@counterlist}{}{%
    \@for\sf@temp:=\sf@counterlist\do{%
      \setcounter{\sf@temp}{\z@}}%
    \@listsubcaptions{\@captype}}%
  \sf@end@dblfloat}
\newif\ifhyperrefloaded
\AtBeginDocument{%
  \@ifpackageloaded{hyperref}{%
    \hyperrefloadedtrue
    %
    \def\sf@setref#1sub#2\relax{%
      \@namedef{theHsub#2\expandafter}{\@nameuse{the#2}.\arabic{sub#2}}%
      \@namedef{toclevel@sub#2}{1}%
    }
    %
    \@for\sf@temp:=\sf@counterlist\do{%
      \expandafter\sf@setref\sf@temp\relax}%
    %
    \global\let\sf@setref\relax
    %
  }{}%
  \@ifpackageloaded{float}{%
    \let\sf@endfloatbox=\@endfloatbox
    \def\@endfloatbox{%
      \listsubcaptions
      \sf@endfloatbox}%
  }{}%
  \@ifpackageloaded{fixltx2e}{%
    \def\end@dblfloat{%
      \if@twocolumn
        \@ifundefined{sf@counterlist}{}{%
          \@for\sf@temp:=\sf@counterlist\do{%
            \setcounter{\sf@temp}{\z@}}%
          \@listsubcaptions{\@captype}}%
        \@endfloatbox
        \ifnum\@floatpenalty <\z@
          \@largefloatcheck
          \global\dp\@currbox1sp %
          \expandafter\@gobble\sf@end@float
        \fi
      \else
        \end@float
      \fi}%
  }{%
    \@ifpackageloaded{fix2col}{%
      \def\end@dblfloat{%
        \if@twocolumn
          \@ifundefined{sf@counterlist}{}{%
            \@for\sf@temp:=\sf@counterlist\do{%
              \setcounter{\sf@temp}{\z@}}%
            \@listsubcaptions{\@captype}}%
          \@endfloatbox
          \ifnum\@floatpenalty <\z@
            \@largefloatcheck
            \global\dp\@currbox1sp %
            \expandafter\@gobble\sf@end@float
          \fi
        \else
          \end@float
        \fi}}{}%
  }
}
\endinput
%%
%% End of file `subfig.sty'.
