% --------------------------------------%--------------------------------------
% ---------------------------- Identification part ----------------------------
% --------------------------------------%--------------------------------------

% I use RCS for version control, and the rcs package from Joachim
% Schrod to fetch the useful information.  The ifthen package is used
% in the interpretation of the information.
\RequirePackage{rcs}

\RCS$Date: 1999/09/22 12:56:51 $
\RCS$RCSfile: aafloat.sty,v $
\RCS$Revision: 1.6 $
\RCS$State: Exp $
\RCS$Author: anders $

% Interpret, print and provide the RCS information.  This is a verry
% general approach used without any changes in all my LaTeX packages
% and classes.
\input{aausercs}


% --------------------------------------%--------------------------------------
% ----------------------------- The revision log ------------------------------
% --------------------------------------%--------------------------------------

% $Log: aafloat.sty,v $
% Revision 1.6  1999/09/22 12:56:51  anders
% Changed some spacing.
%
% Revision 1.5  1999/03/16 13:48:11  anders
% Increased @fs@mid from 5 to 10pt in aaruled and aaruledsmall.
%
% Revision 1.4  1998/06/04 13:23:48  anders
% Use aausercs to handle RCS information.
%
% Revision 1.3  1998/06/04 10:43:26  anders
% Added aaruledsmall float style as an option.
%
% Revision 1.2  1997/03/31 13:19:16  anders
% Made float placement and style configurable.
%
% Revision 1.1  1997/03/31 12:46:53  anders
% Added support for subfloats based on (and using) subfigure.sty.
%
% Revision 1.0  1997/03/25 14:31:53  anders
% This is the first version of my new aafloat.sty.  This is still a stripped
% down version, where new features will be added later.
%
% Revision 0.9  1997/03/25 12:36:37  anders
% This is the last of my old type of aafloat.sty.  The next release will be
% a completly rewritten stripped down version, where new features will be
% added later.


% --------------------------------------%--------------------------------------
% -------------------------------- Start code ---------------------------------
% --------------------------------------%--------------------------------------



% --------------------------------------%--------------------------------------
% -------------------------- Declaration of options ---------------------------
% --------------------------------------%--------------------------------------

% My prefered float style.
\DeclareOption{aaruled}{\def\aafloatstyle{aaruled}}
\DeclareOption{aaruledsmall}{\def\aafloatstyle{aaruledsmall}}

% Float styles from the float package.
\DeclareOption{plain}{\def\aafloatstyle{plain}}
\DeclareOption{ruled}{\def\aafloatstyle{ruled}}
\DeclareOption{boxed}{\def\aafloatstyle{boxed}}

% The rest of the options is passed to subfigure.sty.
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{subfigure}}


% --------------------------------------%--------------------------------------
% --------------------------- Execution of options ----------------------------
% --------------------------------------%--------------------------------------

\ExecuteOptions{aaruled}
\ProcessOptions


% --------------------------------------%--------------------------------------
% ------------------------------ Package loading ------------------------------
% --------------------------------------%--------------------------------------

\RequirePackage{float}
\RequirePackage{subfigure}


% --------------------------------------%--------------------------------------
% --------------------------------- Main code ---------------------------------
% --------------------------------------%--------------------------------------

% Change these to my prefered values.
\renewcommand{\topfraction}{.7}
\renewcommand{\textfraction}{.3}
\renewcommand{\floatpagefraction}{.7}
\renewcommand{\floatsep}{20pt}

% Configuration of sub figures.
\renewcommand{\subfigbottomskip}{0pt}
%\renewcommand{\subfigtopskip}{5pt}
%\renewcommand{\subfigcapskip}{7pt}
\renewcommand{\subcaplabelfont}{\bfseries}

% New sub figure.
\newcommand{\newsubaafloat}[2]{%
  \newcounter{sub#1}[#1]%
  \expandafter\def\csname thesub#1\endcsname{(\alph{sub#1})}%
  \expandafter\def\csname @thesub#1\endcsname{%
    {\subcaplabelfont\@nameuse{thesub#1}}\space}%
  \expandafter\let\csname p@sub#1\expandafter\endcsname
    \csname thesub#1\endcsname
  \expandafter\let\csname ext@sub#1\expandafter\endcsname
    \csname ext@#1\endcsname
  \expandafter\def\csname l@sub#1\endcsname{\expandafter\@dottedxxxline
    \csname ext@sub#1\endcsname{2}{3.9em}{2.3em}}%
  \newcounter{#2depth}\setcounter{#2depth}{1}%
  \expandafter\let\csname sub#1\endcsname\subfigure
  \expandafter\let\csname @makesub#1caption\endcsname\@makesubfigurecaption}

% The caption in my float style.
\newcommand\floatc@aaruled[2]{{\@fs@cfont #1}~~{\@fs@tfont#2}\par}

% My float style based on ruled (from the float package).
\newcommand\fs@aaruled{%
  \def\@fs@cfont{\bfseries}%
  \def\@fs@tfont{}%
  \let\@fs@capt\floatc@aaruled
  \def\@fs@pre{\kern5pt}%
  \def\@fs@mid{\kern10pt}%
  \def\@fs@post{\kern6pt\hrule\relax\kern2pt}%
  \let\@fs@iftopcapt\iffalse}

% The caption in my 'small figure text' float style.
\newcommand\floatc@aaruledsmall[2]{{\@fs@cfont #1}~~{\@fs@tfont#2}\par}

% My float style based on ruled (from the float package).
\newcommand\fs@aaruledsmall{%
  \def\@fs@cfont{\small\bfseries}%
  \def\@fs@tfont{\small}%
  \let\@fs@capt\floatc@aaruledsmall
  \def\@fs@pre{\kern5pt}%
  \def\@fs@mid{\kern10pt}%
  \def\@fs@post{\kern6pt\hrule\relax\kern2pt}%
  \let\@fs@iftopcapt\iffalse}

% A command for new floats with sub figures
\newcommand\newaafloat[2]{%
  \@ifnextchar[{\@newaafloat{#1}{#2}}{\@@newaafloat{#1}{#2}}}
\def\@newaafloat#1#2[#3]{\newfloat{#1}{\aafp}{#2}[#3]%
  \newsubaafloat{#1}{#2}}
\def\@@newaafloat#1#2{\newfloat{#1}{\aafp}{#2}%
  \newsubaafloat{#1}{#2}}

% Select a style and placement ...
\floatstyle{\aafloatstyle}
\@ifundefined{aafp}{\def\aafp{tp}}{}

% ... also for table and figure
\AtBeginDocument{%
  \floatplacement{table}{\aafp}%
  \floatplacement{figure}{\aafp}%
  \restylefloat{table}%
  \restylefloat{figure}}
