%\filename{papermfigmacros.tex}
%\edited{last by stolfi on Fri Mar  6 23:02:18 1987}

% Figures with legent at the side

\catcode`@=11 \endlinechar=-1

  \message{marginal figures ...}

    %  Use \rfig5cm{\flower}{Figure 1: A Boojum},
    %  Use \lfig5cm{\flower}{Figure 1: A Boojum}
    %    for a figure 5 cm high and \mfigwidth wide on the right/left margin,
    %    with the given legend typeset by its side.
    

    \newdimen\mfigwidth % width of marginal figures

    \long\def\rfig#1#{\mf@g{R}{#1}}
    \long\def\lfig#1#{\mf@g{L}{#1}}

    \long\def\mf@g#1#2#3#4{\relax
      \ifomitfigures\else
        \dimen@=\hsize
        \advance\dimen@ by \if R#1 -\leftglue\else -\rightglue\fi
        \advance\dimen@ by -\mfigwidth\advance\dimen@ by -2pt
        \setbox2\vtop{\hsize=\dimen@\leftglue=0pt\rightglue=0pt #4}
        \setbox0\vtop{\hrule height0pt
           \ifcaptionsonly\else\vbox to #2{
             \hsize=\mfigwidth\leftglue=0pt\rightglue=0pt #3}\fi}
        \setbox0\hbox to \hsize{\if R#1\hskip\leftglue
        \box2\hskip 0pt plus 1000pt\raise1\ht2\box0\else
        \raise1\ht2\box0\hskip 0pt plus 1000pt\box2\hskip\rightglue\fi}
        \midinsert{\box0}
      \fi}

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

% END
