答案1
定义自己的边界矩阵,源自latex.ltx
:
\documentclass{article}
\makeatletter
\def\BorderMatrix#1{%
\begingroup
\m@th\@tempdima8.75\p@\setbox\z@\vbox{%
\def\cr{\crcr\noalign{\kern2\p@\global\let\cr\endline }}%
\ialign{\hfil$##$\hfil\kern2\p@\kern\@tempdima & \thinspace
\hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut
\hfil\crcr\noalign{\kern-\baselineskip}#1\crcr\omit
\strut\cr}}%
\setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
\setbox\tw@\hbox{%
$\kern\wd\@ne\kern-\@tempdima\left(\kern2pt
\global\setbox\@ne\vbox{\box\@ne\kern2\p@}%
\vcenter{\kern -\ht\@ne \unvbox\z@\kern-\baselineskip}%
\kern-2\@tempdima\kern4\p@\right)$}%
\null\;\vbox{\kern\ht\@ne\box\tw@}%
\endgroup
}
\makeatother
\begin{document}
$\bordermatrix{%
& 1 & 2 \cr
1 & x1 & x2 \cr
2 & x3 & x4 \cr
3 & x5 & x6 \cr
}$
\qquad
$\BorderMatrix{%
1 & 2 & \cr
x1 & x2 & 1 \cr
x3 & x4 & 2 \cr
x5 & x6 & 3 \cr
}$
\end{document}