[Tex/LaTex] Problem with \bordermatrix inside array

arraysmatrices

When a \bordermatrix is placed inside an array, the spacing between rows will be wrong (see the MWE below). What is causing this problem? Is there a solution?

\documentclass{book}

\begin{document}

A simple matrix created with \verb+\bordermatrix+; right spacing between rows:
\[
  \bordermatrix{%
    & 1 & 2 \cr
    1 & x1 & x2 \cr
    2 & x3 & x4 \cr
    3 & x5 & x6}
\]

The same matrix inside an \texttt{array}; wrong spacing between rows:
\[
\begin{array}{c}
  \bordermatrix{%
    & 1 & 2 \cr
    1 & x1 & x2 \cr
    2 & x3 & x4 \cr
    3 & x5 & x6}
\end{array}
\]

\end{document}

Best Answer

This is caused because the \bordermatrix uses the \baselineskip for the spacing and array sets this to 0pt.

Restoring the value of \baselineskip in the cell fixes the issue:

\documentclass{book}

\begin{document}

\[
\edef\savedbaselineskip{\the\baselineskip\relax}
\begin{array}{c}
    {\baselineskip=\savedbaselineskip
    \bordermatrix{%
    & 1 & 2 \cr
    1 & x1 & x2 \cr
    2 & x3 & x4 \cr
    3 & x5 & x6}}
\end{array}
\]

\end{document}

This is done inside a group to keep the definition local.