% FLEXIBOX MACROS for LaTeX2e version 2.11,
% written by Herman Haverkort, 18 april 1995
% See end of file for information on warranty, distribution etc.

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hhflxbox}[1995/04/18 Scalable frames]
\RequirePackage{hhunits}[1995/02/16]
\RequirePackage{hhutils0}[1995/03/08]

% WARNING for those who had a hhflxbox 1.00 or 1.01: The parameter WIDTH
% for \iframe should be specified in thousands from version 1.02 on.

% ******************************
% º    HORIZONTAL CENTERING    º
% ******************************

\def\clap#1{\hbox to \z@{\hss #1\hss}}

% ******************************
% º IN-LINE VERTICAL CENTERING º
% ******************************

\def\lcenter#1{$\vcenter{\hbox{#1}}$}

% ******************************
% º     ISOMORPHOUS FRAMES     º
% ******************************
%
% \iframe sets isomorphous frames. Isomorphous frames are stretchable
% neither horizontally nor vertically; they are only scalable by the
% same factor in all directions.
%
% The syntax of \iframe is the following:
% \iframe IFRAME (HPOS, VPOS) WIDTH MINHEIGHT HSTRETCH VSTRETCH
%         UNITHEIGHT:CONTENTS
%
% *  IFRAME should be a macro that draws the frame in a picture environment,
%    assuming that the unitlength has been set equal to the height of the
%    area which is to contain the frame's contents.
%
% *  HPOS and VPOS determine the position of the frame's contents within
%    the frame; they are given by the distance between the frame's lower
%    left corner and the lower left corner of the contents area.
%    HPOS and VPOS should be in units, assuming that the unitlength is
%    the height of the contents area.
%
% *  WIDTH is 1000 times the width/height ratio of the frame's contents area.
%
% *  MINHEIGHT is the minimum height of the contents.
%
% *  HSTRETCH should be a macro that takes two arguments: a dimension
%    HSIZE and a box number BOX. HSTRETCH reads the box and enlarges
%    it to have width HSIZE. The following HSTRETCH macros are defined:
%    -  \ifrl  (sets the box flushed left)
%    -  \ifrr  (sets the box flushed right)
%    -  \ifrch (sets the box centered)
%    VSTRETCH does the similar thing for the vertical dimension:
%    -  \ifrt  (sets the box flushed up by increasing its depth)
%    -  \ifrb  (sets the box flushed down by increasing its height)
%    -  \ifrcv (sets the box `centerd' by increasing depth and height by
%              the same amount)
%
% *  UNITHEIGHT (optional) is an identifier (just some string of alphabetic
%    characters) which identifies the so-called unit height. Every time
%    a frame is set, the smaller of the contents height and the unit height
%    is set to the larger one. After compiling the entire file, the unit
%    height will have been increased to fit the largest contents which have
%    been framed with it. The unit height is then saved, and reloaded the
%    next time the file is compiled. All frames using that unit height
%    will be set to the same size then, which is determined by the largest
%    box which should fit in it.
%
% *  CONTENTS is what is to be framed.

\def\ifrl#1#2{\hbox to #1{\box#2\hss}}
\def\ifrr#1#2{\hbox to #1{\hss\box#2}}
\def\ifrch#1#2{\hbox to #1{\hss\box#2\hss}}
\def\ifrb#1#2{\hbox{{%
    \@tempdima #1\advance\@tempdima-\dp#2\ht#2\@tempdima \box#2}}}
\def\ifrt#1#2{\hbox{{%
    \@tempdima #1\advance\@tempdima-\ht#2\dp#2\@tempdima \box#2}}}
\def\ifrcv#1#2{\hbox{{%
    \@tempdima #1\relax
    \@tempdimb #1\relax
    \advance\@tempdima \ht#2%
    \advance\@tempdima-\dp#2%
    \ht#2.5 \@tempdima
    \advance\@tempdimb-\ht#2%
    \dp#2\@tempdimb
    \box#2}}}

\def\iframe#1(#2,#3)#4#5#6#7#8:#9{{%
  %
  % box what is to be framed:
  \sbox\@tempboxa{#9}%
  %
  % determine the total height of the box
  \@tempdima\ht\@tempboxa \advance\@tempdima\dp\@tempboxa
  %
  % if it is less than the minimum height, stretch the box vertically
  \ifdim\@tempdima<#5\setbox\@tempboxa #7{#5}{\@tempboxa}\@tempdima #5\fi
  %
  % calculate the natural height of the box, given its width
  \setlength\@tempdimb{\wd\@tempboxa}%
  \divide\@tempdimb#4%
  \setlength\@tempdimb{1000\@tempdimb}%
  %
  \ifdim\@tempdimb>\@tempdima
    % if the box is lower than its natural height then stretch it vertically
    \setbox\@tempboxa #7{\@tempdimb}{\@tempboxa}\@tempdima\@tempdimb
  \else
    % if the box is higher than its natural height then stretch it horizontally
    \setlength\@tempdimb{.001\@tempdima}%
    \setbox\@tempboxa #6{#4\@tempdimb}{\@tempboxa}%
  \fi
  %
  % determine if a unit name is specified
  \def\@tempa{#8}\ifx\@tempa\@empty\else
    % if so, get the right height for the box and stretch it to the extent
    % that is necessary
    \@tempdimb\unit #8:{\@tempdima}\@tempdima\@tempdimb%
    \setbox\@tempboxa #7{\@tempdima}{\@tempboxa}%
    \setlength\@tempdimb{.001\@tempdima}%
    \setbox\@tempboxa #6{#4\@tempdimb}{\@tempboxa}%
  \fi
  %
  % calculate the unit length for the frame drawing
  \divide\@tempdima 1000
  %
  % calculate the depth of the framed box, taking in account the
  % width of the lower frame part and the depth of the framed box
  \@tempdimb #3\@tempdima \advance\@tempdimb\dp\@tempboxa
  %
  % and finally put it all together
  \hbox{\lower\@tempdimb\hbox{%
    \unitlength\@tempdima
    \begin{picture}(0,0)%
      \put(#2,#3){\hbox{\raise\dp\@tempboxa\box\@tempboxa}}%
    \end{picture}%
    #1}}}}

% ******************************
% º         ENCIRCLING         º
% ******************************
%
% The first encircling macro has the following syntax:
% \ringbox UNITHEIGHT:CONTENTS
% where the parameters are as described above.

\def\ringbox{\iframe\@ringbox(200,200){1000}{0pt}\ifrch\ifrcv}
\def\@ringbox{%
  \begin{picture}(1400,1400)\put(700,700){\circle{1400}}\end{picture}}

% The second encircling macro is very much alike the first one. It also
% puts the CONTENTS in a square, which is surrounded by a circle. The
% circle, however, does not contribute anything to the size of the
% resulting box. The result of \outringbox is a box with the dimensions
% of the squared contents, causing the circle to stick out.

\def\outringbox{\iframe\@outringbox(0,0){1000}{0pt}\ifrch\ifrcv}
\def\@outringbox{%
  \begin{picture}(1000,1000)\put(500,500){\circle{1400}}\end{picture}}

% Finally, \bellybox sticks out by 5% of its diameter on every side
\def\bellybox{\iframe\@bellybox(130,130){1000}{0pt}\ifrch\ifrcv}
\def\@bellybox{%
  \begin{picture}(1260,1260)\put(630,630){\circle{1400}}\end{picture}}

% ******************************
% º     STRETCHABLE FRAMES     º
% ******************************
%
% Stretchable frames consist of four parts: two side parts (left and right)
% and two ledger parts (top and bottom).
% The side and ledger parts are macros which take (unfortunately) a lot
% of arguments: eight to be exact. The first is the box in which the side or
% ledger part is to be set. The second is the basic width of the box to
% be framed. Imagine this is the top border of the box to be framed:
% ------*-------------------------*---.
%   #3                             #4
% The asterisks specify the part of the border that has to be spanned by
% the top ledger of the frame. The total length of this border should be
% given by the second argument of the macro. The third and the fourth
% argument should specify the distances between the ends and the
% fastening points (indicated by the asterisks). Of course these distances
% are usually zero. After the ledger has been fastened the fastening
% points should be moved, because the fastening points are considered
% to be the corners of the framed box and could be needed to position
% the side parts of the frame. Imagine a strange ledger like this one:
%
%   *################
%     #################################*
%       ###########################
% ------o-------------------------o---
% The asterisks indicate the new fastening points. The position of the left
% fastening point should be stored in the dimensions identified by argument
% five and seven. The fifth argument should be set to the horizontal distance
% from the left end of the framed box border to the new left fastening point.
% The seventh argument should be set to the vertical distance between the
% framed box border and the fastening point. This distance should be
% negative if the new fastening point is outside the box, which it usually
% is. Similarly, the position of the right fastening point should be
% stored in the sixth and eighth argument. Note that if a new fastening
% point is positioned to the left or right of the framed box, its
% horizontal coordinate should be set negative. For example: in the
% above figure the right fastening point sticks out horizontally, so
% the sixth argument should be set to a negative value.
%
% For left part macros, swap left en top, and swap right and bottom in
% the above explanation. For bottom part macros, mirror the above story
% in the horizontal axis. For right part macros, mirror the left part
% explanation in the vertical axis.
%
% The basic syntax of a stretchable frame call is:
%    \sframe LEFTSIDE TOPLEDGER RIGHTSIDE BOTTOMLEDGER -HORIZALIGN |VERTALIGN
%            CONTENTS
% LEFTSIDE to BOTTOMLEDGER are as explained above.
% -HORIZALIGN and |VERTALIGN are optional. If specified the aligns have
% the following syntax:
%            [MINDIM] STRETCH UNITDIM:
% where [MINDIM] and UNITDIM are optional (however, it does not make sense
% to omit both of them). The effect of specifying aligns is similar to
% the effect of specifying minimal heights, stretches and unit heights for
% an \iframe. The difference is that \iframe aligns work in horizontal and
% vertical direction simultaneously, while \sframe offers independent
% handling of the horizontal and vertical directions.
%
% \sfrsrule is a predefined macro which can be used as a left or right
% side. It draws a vertical rule with thickness \fboxrule.
% \sfrlrule does the similar thing horizontally and can be used as a
% top or bottom ledger. Note however that
%    \sframe\sfrsrule\sfrlrule\sfrsrule\sfrlrule{stuff}
% does _not_ draw a proper box around stuff. There will be no corners!
% The solution is to divide the frame constructing process in phases.
% The first phase is drawing the side parts. The second phase is
% drawing the ledger parts, taking in account the width contributed
% by the already drawn side parts. Up to four phases can be used.
% The phases can be specified simply by typing the phase number
% between brackets just before each part, for example:
%    \sframe [1]\sfrsrule [2]\sfrlrule [1]\sfrsrule [2]\sfrlrule {stuff}
% Each part for which no phase is specified will be drawn in phase four.
%
% To specify an empty side or ledger, specify any macro with a invalid
% phase number, e.g.: "[0]\open".
%
% There is a environment variant of \sframe: use
% \begin{sframed}... STUFF\end{sframed} instead of \sframe...{STUFF}.
% =============================================================================

\newenvironment{sframed}%
  {\begingroup\@h@sfrenvironmenttrue\h@Zsframe}%
  {\h@Ksframe}
\def\sframe{\begingroup\@h@sfrenvironmentfalse\h@Zsframe}
\def\h@Zsframe{\@ifnextchar[{\h@Asframe}{\h@Asframe[4]}}
\def\h@Asframe[#1]#2{\def\h@sfrlphase{#1}\def\h@sfrlside{#2}%
  \@ifnextchar[{\h@Bsframe}{\h@Bsframe[4]}}
\def\h@Bsframe[#1]#2{\def\h@sfrtphase{#1}\def\h@sfrtledger{#2}%
  \@ifnextchar[{\h@Csframe}{\h@Csframe[4]}}
\def\h@Csframe[#1]#2{\def\h@sfrrphase{#1}\def\h@sfrrside{#2}%
  \@ifnextchar[{\h@Dsframe}{\h@Dsframe[4]}}
\def\h@Dsframe[#1]#2{\def\h@sfrbphase{#1}\def\h@sfrbledger{#2}%
  \@ifnextchar-{\h@Esframe}{\h@Esframe-\ifrch:}}
\def\h@Esframe-{\@ifnextchar[{\h@Fsframe}{\h@Fsframe[\z@]}}
\def\h@Fsframe[#1]#2#3:{%
  \def\h@sfrhmin{#1}\def\h@sfrhstretch{#2}\def\h@sfrhunit{#3}%
  \@ifnextchar|{\h@Gsframe}{\h@Gsframe|\ifrcv:}}
\def\h@Gsframe|{\@ifnextchar[{\h@Hsframe}{\h@Hsframe[\z@]}}
\def\h@Hsframe[#1]#2#3:{%
  \def\h@sfrvmin{#1}\def\h@sfrvstretch{#2}\def\h@sfrvunit{#3}%
  \if@h@sfrenvironment\def\next{\h@Jsframe\ignorespaces}%
                 \else\def\next{\h@Isframe}\fi\next}
\def\h@Isframe#1{\h@Jsframe #1\h@Ksframe}
\def\h@Jsframe{\mufoff\sbox\@tempboxa\bgroup}
\def\h@Ksframe{\egroup
  \@tempdima\ht\@tempboxa \addtolength\@tempdima{\dp\@tempboxa}%
  \ifdim\@tempdima<\h@sfrvmin
    \setbox\@tempboxa\h@sfrvstretch{\h@sfrvmin}{\@tempboxa}\@tempdima\h@sfrvmin\fi
  \ifx\h@sfrvunit\@empty\else
    \@tempdimb\unit\h@sfrvunit:{\@tempdima}\@tempdima\@tempdimb
    \setbox\@tempboxa\h@sfrvstretch{\@tempdima}{\@tempboxa}\fi
  \ifdim\wd\@tempboxa<\h@sfrhmin
    \setbox\@tempboxa\h@sfrhstretch{\h@sfrhmin}{\@tempboxa}\fi
  \ifx\h@sfrhunit\@empty\else
    \@tempdimb\unit\h@sfrhunit:{\wd\@tempboxa}%
    \setbox\@tempboxa\h@sfrhstretch{\@tempdimb}{\@tempboxa}\fi
  \setlength\@tempdimq{\dp\@tempboxa}%
  \sbox\@tempboxa{\raise\@tempdimq\box\@tempboxa}%
  \setlength\@tempdima\z@\setlength\@tempdimb\z@%
  \setlength\@tempdimc\z@\setlength\@tempdimd\z@%
  \setlength\@tempdime\z@\setlength\@tempdimf\z@%
  \setlength\@tempdimg\z@\setlength\@tempdimh\z@%
  \def\h@sfrphase{1}\h@sfrdophase
  \def\h@sfrphase{2}\h@sfrdophase
  \def\h@sfrphase{3}\h@sfrdophase
  \def\h@sfrphase{4}\h@sfrdophase
  \hbox{\lower\@tempdimq\box\@tempboxa}%
  \muffin
  \endgroup}
\newif\if@h@sfrenvironment\@h@sfrenvironmentfalse
\def\h@sfrdophase{%
  \setlength\@tempdimi\@tempdima\setlength\@tempdimj\@tempdimb
  \setlength\@tempdimk\@tempdimc\setlength\@tempdiml\@tempdimd
  \setlength\@tempdimm\@tempdime\setlength\@tempdimn\@tempdimf
  \setlength\@tempdimo\@tempdimg\setlength\@tempdimp\@tempdimh
  \ifx\h@sfrphase\h@sfrlphase\h@sfrlside\@tempboxb{\ht\@tempboxa}\@tempdima\@tempdimb
    \@tempdimi\@tempdimj\@tempdimm\@tempdimo\else\sbox\@tempboxb{}\fi
  \ifx\h@sfrphase\h@sfrtphase\h@sfrtledger\@tempboxc{\wd\@tempboxa}\@tempdime\@tempdimf
    \@tempdimm\@tempdimn\@tempdimi\@tempdimk\else\sbox\@tempboxc{}\fi
  \ifx\h@sfrphase\h@sfrrphase\h@sfrrside\@tempboxd{\ht\@tempboxa}\@tempdimc\@tempdimd
    \@tempdimk\@tempdiml\@tempdimn\@tempdimp\else\sbox\@tempboxd{}\fi
  \ifx\h@sfrphase\h@sfrbphase\h@sfrbledger\@tempboxe{\wd\@tempboxa}\@tempdimg\@tempdimh
    \@tempdimo\@tempdimp\@tempdimj\@tempdiml\else\sbox\@tempboxe{}\fi
  \addtolength\@tempdimi{\ht\@tempboxc}\addtolength\@tempdimk{\ht\@tempboxc}%
  \addtolength\@tempdimj{\ht\@tempboxe}\addtolength\@tempdiml{\ht\@tempboxe}%
  \addtolength\@tempdimm{\wd\@tempboxb}\addtolength\@tempdimo{\wd\@tempboxb}%
  \addtolength\@tempdimn{\wd\@tempboxd}\addtolength\@tempdimp{\wd\@tempboxd}%
  \addtolength\@tempdimq{\ht\@tempboxe}%
  \setbox\@tempboxa\vbox{\offinterlineskip
    \hbox{\kern\wd\@tempboxb\kern\@tempdime\rlap{\box\@tempboxc}}%
    \hbox{\raise\@tempdimb\copy\@tempboxb\box\@tempboxa\raise\@tempdimd\box\@tempboxd}%
    \hbox{\kern\wd\@tempboxb\kern\@tempdimg\rlap{\box\@tempboxe}}}%
  \setlength\@tempdima\@tempdimi\setlength\@tempdimb\@tempdimj
  \setlength\@tempdimc\@tempdimk\setlength\@tempdimd\@tempdiml
  \setlength\@tempdime\@tempdimm\setlength\@tempdimf\@tempdimn
  \setlength\@tempdimg\@tempdimo\setlength\@tempdimh\@tempdimp}

\def\sfrsrule{\sfrrule{height\@tempdimq width\fboxrule}}
\def\sfrlrule{\sfrrule{height\fboxrule width\@tempdimq}}
\def\sfrrule#1#2#3#4#5#6#7#8#9{%
  \sbox#2{\sfrcalclength{#3}{#4}{#5}\vrule #1}%
  \sfrsetoffsets{\fboxrule}{#4}{#5}#6#7#8#9}

\def\sfrcalclength#1#2#3{%
  \setlength\@tempdimq{#1}%
  \addtolength\@tempdimq{-#2}\addtolength\@tempdimq{-#3}}
\def\sfrsetoffsets#1#2#3#4#5#6#7{%
  \setlength#4#2\setlength#5#3%
  \setlength#6{-#1}\setlength#7{-#1}}

% ******************************
% º       UTILITY FRAMES       º
% ******************************
%
% Separation frames consist of blank space around a box, which forces
% surrounding self-scaling boxes to stretch and leave some space between
% the surrounding frame and its contents.
%
% The generic seperation frame macro takes four parameters:
% \sepbox(LEFTMARGIN, UPPERMARGIN, RIGHTMARGIN, LOWERMARGIN)
% A abbreviation for \mframe(MARGIN,MARGIN,MARGIN,MARGIN) is available too:
% \separbox MARGIN
%
% Instead of \sepbox and \separbox one can use the environment variants
% started by \begin{sepboxed} and \begin{separboxed} and ended by
% \end{sepboxed} and \end{separboxed}.

\newenvironment{sepboxed}%
  {\begingroup\@h@sbxenvironmenttrue\h@Asepbox}%
  {\h@Dsepbox}
\def\sepbox{\begingroup\@h@sbxenvironmentfalse\h@Asepbox}
\def\h@Asepbox(#1,#2,#3,#4){%
  \def\h@sbxlsep{#1}\def\h@sbxtsep{#2}\def\h@sbxrsep{#3}\def\h@sbxbsep{#4}%
  \if@h@sbxenvironment\def\next{\h@Csepbox\ignorespaces}%
                 \else\def\next{\h@Bsepbox}\fi\next}
\long\def\h@Bsepbox#1{\h@Csepbox #1\h@Dsepbox}
\def\h@Csepbox{\sbox\@tempboxa\bgroup\mufoff{\kern\h@sbxlsep}}
\def\h@Dsepbox{{\kern\h@sbxrsep}\egroup
  \setlength\@tempdima{\ht\@tempboxa}\addtolength\@tempdima{\h@sbxtsep}%
  \ht\@tempboxa\@tempdima
  \setlength\@tempdima{\dp\@tempboxa}\addtolength\@tempdima{\h@sbxbsep}%
  \dp\@tempboxa\@tempdima
  \box\@tempboxa\muffin\endgroup}
\newif\if@h@sbxenvironment\@h@sbxenvironmentfalse

\newenvironment{separboxed}[1]%
  {\begin{sepboxed}(#1,#1,#1,#1)}%
  {\end{sepboxed}}
\def\separbox#1{\sepbox(#1,#1,#1,#1)}

% \broadbox{DIMENSION}{CONTENTS} sets CONTENTS in a parbox which has width
% current linewidth minus DIMENSION. Instead of \broadbox{DIMENSION}{CONTENTS}
% one can also use \begin{broadboxed}{DIMENSION}CONTENTS\end{broadboxed}.

\long\def\broadbox#1#2{\vtop{\h@leavespace{#1}\mufoff #2}\muffin}
\newenvironment{broadboxed}[1]%
  {\vtop\bgroup\h@leavespace{#1}\mufoff\ignorespaces}%
  {\egroup\muffin}

% Putting \boxhigh in front of something that is boxed (that is: _in_ the
% box!) suppresses leading vertical blank space. \boxlow does the similar
% thing at the end of the box: put it at the end of the boxed material.

\newif\if@boxhigh
\def\boxhigh{%
  \ifx\h@boxhigh@addvspace\undefined
    \let\addpenalty\@gobble
    \let\h@boxhigh@addvspace=\addvspace
    \def\addvspace{\if@boxhigh
        \ifdim\prevdepth>-4774pt\relax
          \@boxhighfalse\def\next{\h@boxhigh@addvspace}%
        \else\def\next{\@gobble}\fi
      \else\def\next{\h@boxhigh@addvspace}\fi\next}\fi
  \setlength\prevdepth{-4774pt}\@boxhightrue}

\def\boxlow{\unskip}

% ******************************
% º  SOME INTERNAL UTILITIES   º
% ******************************

\h@newdimen\@tempdima\h@newdimen\@tempdimb\h@newdimen\@tempdimc
\h@newdimen\@tempdimd\h@newdimen\@tempdime\h@newdimen\@tempdimf
\h@newdimen\@tempdimg\h@newdimen\@tempdimh\h@newdimen\@tempdimi
\h@newdimen\@tempdimj\h@newdimen\@tempdimk\h@newdimen\@tempdiml
\h@newdimen\@tempdimm\h@newdimen\@tempdimn\h@newdimen\@tempdimo
\h@newdimen\@tempdimp\h@newdimen\@tempdimq
\h@newbox\@tempboxb\h@newbox\@tempboxc\h@newbox\@tempboxd\h@newbox\@tempboxe

\def\h@leavespace#1{%
  \hsize\linewidth\advance\hsize-#1\linewidth\hsize
  \parshape\@ne\@totalleftmargin\linewidth}

\newif\if@squeezing
\newcount\h@tsqo@level
\def\topsqueezeout{%
  \ifx\h@tsqo@addvspace\undefined
    \let\h@tsqo@addvspace=\addvspace
    \def\addvspace{\if@squeezing
        \ifdim\prevdepth>-4774pt\relax
          \@squeezingfalse\def\next{\h@tsqo@addvspace}%
        \else\def\next{\h@tsqo@savesqueeze\h@tsqo@addvspace}\fi
      \else\def\next{\h@tsqo@addvspace}\fi\next}%
    \let\h@tsqo@addpenalty=\addpenalty
    \def\addpenalty{\if@squeezing
        \ifdim\prevdepth>-4774pt\relax
          \@squeezingfalse\def\next{\h@tsqo@addpenalty}%
        \else\def\next{\h@tsqo@savesqueeze\h@tsqo@addpenalty}\fi
      \else\def\next{\h@tsqo@addpenalty}\fi\next}%
  \fi
  \def\topsqueezein{%
    \global\advance\h@tsqo@level-1\relax
    \global\setbox\h@tsqo@currentsqueeze\vbox{%
      \unvbox\h@tsqo@currentsqueeze
      \advance\h@tsqo@level 1\relax
      \unvbox\h@tsqo@currentsqueeze}}%
  \global\advance\h@tsqo@level 1\relax
  \expandafter\expandafter\expandafter\h@newbox\h@tsqo@currentsqueeze
  \global\setbox\h@tsqo@currentsqueeze\vbox{}%
  \setlength\prevdepth{-4774pt}\@squeezingtrue}
\def\topsqueezein{\unvbox\h@tsqo@currentsqueeze
  \global\advance\h@tsqo@level-1\relax}
\def\h@tsqo@currentsqueeze{\csname h@tsqo@squeeze\number\h@tsqo@level\endcsname}
\def\h@tsqo@savesqueeze#1#2{\global\setbox\h@tsqo@currentsqueeze\vbox{%
    \unvbox\h@tsqo@currentsqueeze #1{#2}}}

\newcount\h@bsqo@level
\newcount\h@bsqo@zeros
\newif\if@bsqo@zero
\def\botsqueezeout{\par
  \global\advance\h@bsqo@level 1\relax
  \expandafter\expandafter\expandafter\h@newbox\h@bsqo@currentsqueeze
  \global\setbox\h@bsqo@currentsqueeze\vbox{}%
  \h@bsqo@zeros=0\relax
  \@whilenum\h@bsqo@zeros<3\do{%
    \@bsqo@zerotrue
    \ifdim\lastskip=\z@\relax\unskip\else
      \setlength\@tempskipa\lastskip
      \h@bsqo@savesqueeze\addvspace\@tempskipa
      \unskip\@bsqo@zerofalse\fi
    \ifnum\lastpenalty=\z@\relax\unpenalty\else
      \@tempcnta=\lastpenalty
      \h@bsqo@savesqueeze\addpenalty\@tempcnta
      \unpenalty\@bsqo@zerofalse\fi
    \if@bsqo@zero\advance\h@bsqo@zeros 1\else\h@bsqo@zeros=0\fi}}
\def\botsqueezein{\unvbox\h@bsqo@currentsqueeze
  \global\advance\h@bsqo@level-1\relax}
\def\h@bsqo@currentsqueeze{\csname h@bsqo@squeeze\number\h@bsqo@level\endcsname}
\def\h@bsqo@savesqueeze#1#2{\global\setbox\h@bsqo@currentsqueeze\vbox{%
    #1{#2}\unvbox\h@bsqo@currentsqueeze}}

\providecommand\mufoff{}
\providecommand\muffin{}

\endinput% **********************
% * WARRANTY, DISTRIBUTION ETC. *
% *******************************
%
% This is a TeX style file by Herman Haverkort. This file is distributed
% in the hope that it will be useful, but without any warranty; without
% even the implied warranty of merchantability or fitness for a particular
% purpose. The author does not accept any responsability for any damage,
% loss, injury, psychosis, annoyance, marital problems, murders etc. which
% are caused by this file.
%
% This style file has not been tested systematically, so there are
% probably undiscoverd errors in it. If you find one, if you have
% trouble using this file, if you have a suggestion for an extension or
% another modification, or if you are just a happy user, please report
% it to:
%                       Herman Haverkort
%                       Heyenoordseweg 40
%                      NL-6813 GA  Arnhem
%                      herman@fgbbs.iaf.nl
%
% You are allowed to change this file, but you are not allowed to distribute
% the changed version unless you obey the following:
% -  give the changed file another name than the original one;
% -  record clearly in the changed file:
%    -  the original name of the file;
%    -  its original author;
%    -  that it is a changed version;
% -  do not remove the restrictions on distributing the file.
%
% You are not allowed to take money for the distribution or use of either
% this file or a changed version, except for a nominal charge for copying
% etc.
%
% Have fun!

