%\filename{bordermatrix.tex}
%\edited{last by stolfi on Tue Apr 21 03:33:30 1987}

% Macros for matrices with row & column of labels outside parenthesis:

\catcode`@=11\endlinechar=-1

    \def\bordermatrix#1{
      \begingroup
        \mathsurround=\z@
        \setbox\z@\hbox{\kern 2pt$\Big($}
        \dimen8=1\wd\z@
        \setbox\z@\notopb@rder#1\endb@rder
        \dimen0=1\ht0
        \setbox\z@\noleftb@rder#1\endb@rder
        \dimen2=-1\wd0
        \setbox\z@\hbox{\withb@rder#1\endb@rder}
        \dimen4=1\ht0 \advance \dimen2 by \wd0
        \ht\z@=\dimen0
        \setbox\z@\hbox{\kern\dimen2$\left(\kern-\dimen2\box\z@\right)$}
        \ht0=\dimen4
        \box\z@
      \endgroup
    }
    \def\ign@re#1{}
    \def\noleftb@rder#1\cr#2\endb@rder{
      \vbox{
        \resetlinesep\baselinesep=\matrixbaselinesep\mathsurround=\z@
        \hrule height0pt\kern0.1\baselinesep
        \ialign{
          \ign@re{##}&\hfil$\thinspace##$\hfil &&\quad\hfil$##$\hfil\crcr
          #1\crcr
          \noalign{\kern0.1\baselinesep\hrule height0pt\kern0.1\baselinesep}
          \mathstrut\crcr\noalign{\kern-\baselinesep}
          #2\crcr
          \mathstrut\crcr\noalign{\kern-\baselinesep}
        }
        \kern0.1\baselinesep
      }
    }
    \def\notopb@rder#1\cr#2\endb@rder{
      \vbox{
        \resetlinesep\baselinesep=\matrixbaselinesep\mathsurround=\z@
        \hrule height0pt\kern0.1\baselinesep
        \ialign{
          $##$\kern\dimen6&\hfil$\thinspace##$\hfil &&\quad\hfil$##$\hfil\crcr
          \mathstrut\crcr\noalign{\kern-\baselinesep}
          #2\crcr
          \mathstrut\crcr\noalign{\kern-\baselinesep}
        }
        \kern0.1\baselinesep
      }
    }
    \def\withb@rder#1\cr#2\endb@rder{
      \vbox{
        \resetlinesep\baselinesep=\matrixbaselinesep\mathsurround=\z@
        \hrule height0pt\kern0.1\baselinesep
        \ialign{
          $##$\kern\dimen6&\hfil$\thinspace##$\hfil &&\quad\hfil$##$\hfil\crcr
          #1\crcr
          \noalign{\kern0.1\baselinesep\hrule height0pt\kern0.1\baselinesep}
          \mathstrut\crcr\noalign{\kern-\baselinesep}
          #2\crcr
          \mathstrut\crcr\noalign{\kern-\baselinesep}
        }
        \kern0.1\baselinesep
      }
    }

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

% END

