% \filename{figuremacros.tex}
% \edited{last by stolfi on Wed Apr 20 11:22:33 1988}

\catcode`@=11\endlinechar=-1

% FIGURES

  \message{figures ...}

  %  figures with caption at bottom

    %  Use \fig 5cm{tag}{A Boojum}
    %    for a figure 5 cm high with given paste tag, followed by a
    %    centered caption with the given text.

    \def\figmag{100} % Figure magnification factor (percent)
    
    \long\def\fig#1#{\vf@g{#1}}

    % Makes a figure box with 
    % contents #1 (a vlist), caption #2 (an hlist),
    % width #3, caption width #4.

    \long\def\m@kefigbox#1#2#3#4{
      \vbox{\offinterlineskip
        \hbox to #3{
          \hss
          \ifcaptionsonly\else
            \vbox{\hsize=#3 #1}
            \hss
          \fi
        }
        \setbox2\vbox{
          \hsize=#4
          \leftglue=0pt\rightglue=0pt
          \parindent=0pt
          \smallsize
          #2
        }
        \ifdim 1\ht2>0pt
          \vskip2ex
          \hbox to #3{\hss\box2\hss}
          \vskip 0.5ex
          \hrule height0pt
        \fi
      }
    }
  
    % Insert a normal figure with height #1, tag #2, caption #3

    \newif\ifshowfigbox \showfigboxtrue 
    \newif\ifincludefigps \includefigpsfalse
    
    \long\def\vf@g#1#2#3{
      \ifomitfigures\else
        \dimen6=#1\relax
        \divide\dimen6 by 100\relax
        \multiply \dimen6 by \figmag\relax
        \setbox0\m@kefigbox{
          \vbox to \dimen6{
            \ifshowfigbox\hrule\else\null\fi
            \vss
            \ifincludefigps 
              { 
                \def\here{} \def\tagof{} \def\Fig##1{##1}
                \edef\n@xt{figbits/#2.ps}
                \centerpsfile{\hsize}{\dimen6}{\n@xt}
              }
            \else
              \centered\smallsize [\tagof#2]
            \fi
            \vss
            \ifshowfigbox\hrule\else \null\fi
          }
        }{\centered Figure #2. #3}{\hsize}{\figcapwidth}
        \ifhmode
          \vadjust{\penalty10000\vskip 0pt plus20pt\penalty10000}\null$$\box0$$
        \else
          \midinsert{\box0}
        \fi
      \fi
    }

\catcode`@=12\endlinechar=`\^^M

% END
