%%
%% This is the file `ieeefloatlib.sty' generated on <1995/01/25>
%% by Andrew Lewis.
%%
%% This file contains some macros for making captions,
%% side-by-side figures with captions, etc.
%%
\NeedsTeXFormat{LaTeX2e}
\def\filedate{1994/09/20}
\ProvidesPackage{ieeefloatlib}[1995/01/25]
\RequirePackage{epsfig,theorem}

\newcommand\floatfont[1]{\def\float@headerfont{#1}}
\def\float@headerfont{\reset@font\small}

\newif\if@epsfiles\@epsfilestrue
\newcommand\@epsfiles{\@epsfilestrue
  \typeout{floatlib: I am compiling optional figures}}
\newcommand\@noepsfiles{\@epsfilesfalse
  \typeout{floatlib: I am not compiling optional figures}}

\DeclareOption{epsfiles}{\@epsfiles}
\DeclareOption{noepsfiles}{\@noepsfiles}
\ProcessOptions

\newcommand\cepsfig{\if@epsfiles\let\@cepsfig\@@cepsfig
  \else\let\@cepsfig\@dummycfig\fi\@cepsfig}
\def\@@cepsfig{\@ifnextchar[{\@cepsfigwid}{\@cepsfigplain}}
\def\@cepsfigwid[#1]#2{\begin{center}\epsfig{figure=#2,width=#1}\end{center}}
\newcommand\@cepsfigplain[1]{\begin{center}\epsfig{figure=#1}\end{center}}
\newcommand\@dummycfig{\@ifnextchar[{\@@dummycfig}
  {\@@dummycfig[0.4\textwidth]}}
\def\@@dummycfig[#1]{\begin{center}\unitlength=#1
  \begingroup\@filereader \@@@dummycfig}
\newcommand\@@@dummycfig[1]{\xdef\@filename{#1}\endgroup
  \begin{picture}(1,1)(0,0)
  \put(0,0){\framebox(1,1){\normalfont\texttt{\@filename}}}
  \end{picture}\end{center}}

\newcommand\ctwoepsfig{\@ifstar{\@ctwoepsfigstar}{\@ctwoepsfignostar}}
\newcommand\@ctwoepsfignostar{\if@epsfiles\let\@ctwoepsfig
  \@@ctwoepsfignostar\else\let\@ctwoepsfig\@dummyctwofig\fi\@ctwoepsfig}
\newcommand\@@ctwoepsfignostar{\@ifnextchar[{\@ctwoepsfigwidnostar}
  {\@ctwoepsfigwidnostar[\capskip]}}
\def\@ctwoepsfigwidnostar[#1]#2#3{\begin{center}\epsfig{figure=#2}\hspace{#1}
  \epsfig{figure=#3}\end{center}}
\newcommand\@ctwoepsfigstar{\if@epsfiles\let\@ctwoepsfig
  \@@ctwoepsfigstar\else\let\@ctwoepsfig\@dummyctwofig\fi\@ctwoepsfig}
\newcommand\@@ctwoepsfigstar{\@ifnextchar[{\@ctwoepsfigwidstar}
  {\@ctwoepsfigwidstar[\capskip]}}
\def\@ctwoepsfigwidstar[#1]#2#3{\begin{center}\epsfig{figure=#2,%
  width=\dblcapwidth}\hspace{#1}
  \epsfig{figure=#3,width=\dblcapwidth}\end{center}}
\newcommand\@dummyctwofig{\@ifnextchar[{\@@dummyctwofig}
  {\@@dummyctwofig[\capskip]}}
\def\@@dummyctwofig[#1]{\begin{center}\unitlength=\dblcapwidth
  \begingroup\@filereader \@@@dummyctwofig{#1}}
\newcommand\@@@dummyctwofig[3]{\xdef\@fileone{#2}\xdef\@filetwo{#3}\endgroup
  \begin{picture}(1,1)(0,0)
  \put(0,0){\framebox(1,1){\normalfont\texttt{\@fileone}}}
  \end{picture}\hspace{#1}
  \begin{picture}(1,1)(0,0)
  \put(0,0){\framebox(1,1){\normalfont\texttt{\@filetwo}}}
  \end{picture}\end{center}}

\def\@makeletter#1{\catcode`#111\relax}
\begingroup
\catcode`\_11
\gdef\@filereader{\@makeletter\_}
\endgroup

\newlength\capwidth\setlength{\capwidth}{\hsize}
\newlength\capindent
\newlength\dblcapwidth\setlength{\dblcapwidth}{0.42\hsize}
\newlength\capskip\setlength{\capskip}{0.04\hsize}

% all right, something strange here when used with caption2.sty... 
%\long\def\@caption#1[#2]#3{\par\addcontentsline{\csname ext@#1\endcsname}{#1}{%
%   \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}
%   \begingroup \@parboxrestore \reset@font
%     \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}{#1}\par
%   \endgroup}
%\def\figurestring{figure}

\long\def\@caption#1[#2]#3{\par\addcontentsline{\csname ext@#1\endcsname}{#1}{%
   \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}
   \begingroup \@parboxrestore \reset@font
     \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
   \endgroup}
\def\figurestring{figure}

\long\def\@makecaption#1#2#3{\ifx\figurestring#3
  \vskip 5pt
  \setbox\@tempboxa\hbox{{\float@headerfont#1.~ #2}}
  \ifdim \wd\@tempboxa >\capwidth
    \setbox\@tempboxa\hbox{{\float@headerfont#1.~ }}
    \setlength\capindent{\wd\@tempboxa} \divide\capindent by 2
    \parbox[t]{\capwidth}{\float@headerfont\hangindent \capindent%
     \hangafter=1\unhbox\@tempboxa#2}
  \else\hbox to\capwidth{\small\hfil\box\@tempboxa\hfil}
  \fi
  \else
    \begin{center}{\small #1}\\{\float@headerfont\textsc{#2}}\end{center}
    \vskip 8pt\fi}

\newcommand\@dblcaptioncr{\hskip\capskip}

\newcommand\dblcaption{\trivlist \let\\=\@dblcaptioncr\let\caption=\@dblcaption
  \rightskip\@flushglue\leftskip\@flushglue\parindent\z@\parfillskip\z@\item[]}

\let\enddblcaption=\endtrivlist

\newcommand\@dblcaption{\refstepcounter\@captype
  \@dblarg{\@@dblcaption\@captype}}

\long\def\@@dblcaption#1[#2]#3{\addcontentsline{\csname
  ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname}{\ignorespaces #2}}\setbox1=\hbox{\hskip\capindent}
  \parbox[t]{\dblcapwidth}{\noindent\hangindent\wd1\normalfont
  \hbox{\float@headerfont\csname fnum@\@captype\endcsname.\ }%
  \ignorespaces\small #3}}

\endinput
