\ProvidesPackage{mak-framedfig}
	[2000/02/06 various figures]

\def\framedstuffsidemargin{1em}
\def\framedstufftopmargin{.7em}

\newcommand{\framedstuffrule}
	{\par\vskip\framedstufftopmargin\hrule\vskip\framedstufftopmargin
         \framedstuffstarttrue}

\newcommand*{\framedstuffstarttrue}{\prevdepth=-1019731308sp\relax}
\def\testframedstuffstart\iftrue
   {\if Y\ifvmode\ifdim\prevdepth=-1019731308sp Y\else N\fi\else N\fi}
\@gobble{\fi\fi}

\newenvironment{framedstuff}
  {\setbox42\vbox\bgroup
   \hrule height0pt width\hsize\relax
   \vskip\framedstufftopmargin\relax
   \begin{list}{}
       {\parsep0pt \itemsep1em \parskip0pt
	\leftmargin\framedstuffsidemargin\relax \rightmargin\leftmargin
	\listparindent1em \itemindent0pt
	\topsep\framedstufftopmargin\relax
	\partopsep\z@\relax
	\labelwidth.3ex}
   \item
   \framedstuffstarttrue
   \begingroup
        \itemsep0pt\relax
  }
  {%\tracingmacros1
   %\tracingcommands1
   \par
   \endgroup
   \ifdim\prevdepth>0pt
     \ifdim\prevdepth<\framedstufftopmargin \vskip-\prevdepth \fi
   \fi
   \hrule height0pt\relax
   \end{list}
   \egroup
   %\showboxbreadth30\showboxdepth1\showbox42
   \hrule\hbox to\wd42{\vrule\hskip0ptminus1cm
                       \box42
                       \hskip0ptminus1cm\vrule}\hrule}

\newenvironment{figcenter}{\advance\rightskip by 2cmplus5cmminus2cm
			   \advance\leftskip by 2cmplus5cmminus2cm
			   \parfillskip=0pt\relax}{\par}

\def\FIGURE{{figure}}
\def\TIGHTFIG{{figure}\relax}
\def\WIDEFIG{{figure*}}
\def\TABLE{{table}[btp]}
\newenvironment{framedfig}[3][\FIGURE]
  {\let\start@framedfig#1%
   \ifx #1\TIGHTFIG	\let\framedstuffsidemargin\z@
			\let\framedstufftopmargin\z@ \fi
   \ifx #1\TABLE	\let\framedstuffsidemargin\z@ \fi
   \expandafter\begin\start@framedfig
   \def\endThisFigure{\Cut@Caption{#3\label{#2}}%
                      \expandafter\end@Framedfig#1.}%
   \begin{framedstuff}}
  {\end{framedstuff}\relax\itshape\small\endThisFigure}
\def\Cut@Caption#1{\Cut@@Caption#1.\Cut@@Caption{#1}}
\def\Cut@@Caption#1.#2\Cut@@Caption#3{{\caption[#1]{#3}}}
\def\end@Framedfig#1#2.{\end{#1}}

\ifx \thechapter\@undefined
  \newcounter{digression}
\else
  \newcounter{digression}[chapter]
  \renewcommand \thedigression
       {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@digression}
\fi
\def\fps@digression{tbp}
\def\ftype@digression{2}
\def\ext@digression{ldg}
\def\fnum@digression{Box~\thedigression}
\newenvironment{digression}[1]
               {\@float{digression}
		\begin{framedstuff}
		\def\@makecaption##1##2%
			{{\normalsize\fontfamily{pag}\selectfont ##1---##2}}
		\caption[foo]{#1}%
	 	\vskip.7em
		\small
		\parindent1em
		}
               {\end{framedstuff}
		\end@float
		}
