%% $Id: kbordermatrix.tex 1337 2026-07-23 09:17:02Z herbert $
%%
\documentclass[10pt]{article}

\usepackage[a4paper,margin=2cm]{geometry}

\usepackage{amsmath}
\usepackage{libertinus}
\usepackage[FakeStretch=0.9,Scale=MatchLowercase]{juliamono}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\usepackage{hvdoctools}
\usepackage{minted-code}
\usepackage{graphicx}
\usepackage{multirow,url}

\usepackage{kbordermatrix}
\usepackage{makeidx}\makeindex

\title{Using the kbordermatrix package}
\author{Kim C. Border\thanks{The original author \dagger\ 2020-11-19} \and 
Herbert Voß\thanks{\protect\url{hvoss@tug.org}}}
\date{\today}

\begin{document}
\maketitle


%	In particular, as with \bordermatrix,
%	1.	It takes the array as an argument.  It does not use \begin{}..\end{}.
%	2.	The first row is spaced a bit further apart from the rest.
%	3.	The lower (n-1) by (n-1) block is set off by delimiters.
%	4.	There is an invisible bottom row of the same height as the segregated
%		top row that adds to the height of the equation.

%	Differences from \bordermatrix:
%	1.  Square brackets are used in place of parentheses.
%	2.  You may use \\ instead of \cr.
%	3.  The line heights agree with LaTeX's line heights for the
%		array environment, and \arraystretch is respected.  This means
%		the bottom (n-1) rows align with the rows of an (n-1)-rowed
%		\begin{array}..\end{array} (with or without delimiters).
%	4.	All columns are centered.
%	** Modified 2003-9-20 to allow flush right option.
%	5.	The first column is spaced a bit further apart from the rest.


%	Differences from \left\[\begin{array}...\end{array}\right\]
%	1.	It takes the array as an argument.  It does not use \begin{}..\end{}.
%		Is this a feature or a bug?
%	2.	Consequently, you cannot use a column specifier (e.g., {l|cr}).
%	3.	Consequently the maximum number of columns is not specified.
%	4.	Vertical rules must be put in each row in a separate column.
%	5.  You can use \hline and \cline.

%	At least it works in the cases I have tried, but I offer no guarantees.
%	cf. \bordermatrix p. 361, and \vrulealign p. 392 of The TeXbook
%	Style parameters, they may be redefined according to taste.





The kbordermatrix package provides the \Lcs{kbordermatrix} 
command, which can be used to make displays such as this, taken from 
my article, »Reduced form auctions revisited«.~\parencite{kcb}

\begin{BDef}
\Lcs{kbordermatrix}\Larga{Left}\Larga{Right}\Largb{math expression}
\end{BDef}

\begin{codeExampleA}{Simple examples}
\newcommand\testMatrix{1 & 2 & 3 & 4\\
  2 & a & b & c\\ 3 & d & e & f}

$\kbordermatrix{\testMatrix}$\\  % default []
$\kbordermatrix[]{\testMatrix}$\qquad
$\kbordermatrix(){\testMatrix}$\\
$\kbordermatrix\{\}{\testMatrix}$\qquad
$\kbordermatrix\{\}{\testMatrix}$\\
$\kbordermatrix(.{\testMatrix}$\qquad
$\kbordermatrix.]{\testMatrix}$
\end{codeExampleA}



\begin{codeExampleM}{Complex examples}
$\kbordermatrix{\text{indices}
    & (1--11) & (1--12) & (1--22) &\vrule & (2--11) & (2--12) & (2--22)   \\
(1) & \lambda(1)^2 & 2\lambda(1)\lambda(2) & \lambda(2)^2 &\vrule & 0&0&0 \\
(2) & 0 & 0 & 0 &\vrule & \lambda()^2 & 2 \lambda(1) \lambda(2) & \lambda(2)^2 \\\hline
(111) & 3 & 0 & 0 & \vrule & 0 & 0 & 0 \\
(112) & 0 & 2 & 0 & \vrule & 1 & 0 & 0 \\
(122) & 0 & 0 & 1 & \vrule & 0 & 2 & 0 \\
(222) & 0 & 0 & 0 & \vrule & 0 & 0 & 3 }$
$\left[\begin{array}{l}p_{1 \cdot 11} \\ p_{1 \cdot 12} \\ p_{1 \cdot 22} \\\hline 
 p_{2 \cdot 11} \\ p_{2 \cdot 12} \\ p_{2 \cdot 22}\end{array}\right]$ 
$\begin{array}{c} =\\ =\\\hline \leq \\\leq\\ \leq\\ \leq \end{array}$
$\left[\begin{array}{c}P_{1} \\ P_{2} \\ \hline 
 1 \\ 1 \\ 1 \\ 1\end{array}\right]$ 
\end{codeExampleM}

Note that the array on the left has a matrix surrounded 
by brackets with an additional row on top and column 
on the left. This is what Knuth calls a 
bordered matrix.~\parencite{knuth} He even provides a \Lcs{bordermatrix} 
command, which is still available 
in \LaTeX, but is not documented. I tweaked his 
command to work better with 
\LaTeX, and renamed it to avoid confusion.

Note that the border row and column are typeset in \Lcs{scriptstyle}, 
but the most important thing about this display is the the rows of the 
left-hand matrix align with the rows of the right-hand matrix, and the 
top row is seemingly ignored. To convince yourself that this is so, let's 
»open up« the display with the \LaTeX\ command
\Lcs{renewcommand}\Lcs{arraystretch}\Largb{2}

\renewcommand\arraystretch{2}

$\kbordermatrix{\text{indices}
    & (1--11) & (1--12) & (1--22) &\vrule & (2--11) & (2--12) & (2--22)   \\
(1) & \lambda(1)^2 & 2\lambda(1)\lambda(2) & \lambda(2)^2 &\vrule & 0&0&0 \\
(2) & 0 & 0 & 0 &\vrule & \lambda()^2 & 2 \lambda(1) \lambda(2) & \lambda(2)^2 \\\hline
(111) & 3 & 0 & 0 & \vrule & 0 & 0 & 0 \\
(112) & 0 & 2 & 0 & \vrule & 1 & 0 & 0 \\
(122) & 0 & 0 & 1 & \vrule & 0 & 2 & 0 \\
(222) & 0 & 0 & 0 & \vrule & 0 & 0 & 3 }$
$\left[\begin{array}{l}p_{1 \cdot 11} \\ p_{1 \cdot 12} \\ p_{1 \cdot 22} \\\hline 
 p_{2 \cdot 11} \\ p_{2 \cdot 12} \\ p_{2 \cdot 22}\end{array}\right]$ 
$\begin{array}{c} =\\ =\\\hline \leq \\\leq\\ \leq\\ \leq \end{array}$
$\left[\begin{array}{c}P_{1} \\ P_{2} \\ \hline 
 1 \\ 1 \\ 1 \\ 1\end{array}\right]$ 

I also have an experimental version that will put the labels on the right 
and bottom. If you ask, I will make it available. I might even try to make a 
version that lets you specify the layout, but I am content with top and left.

\section*{Known issues}
The command works by first typesetting the array without delimiters and 
then disassembling the resulting box to make some measurements, and 
finally overlaying the delimiters on the typeset box. Since the first 
row and first column are typeset differently, it is not surprising that 
if there are not at least two rows and two columns that the command may 
behave strangely, but I wouldn't call this a bug. For instance, an empty 
array, \Lcs{kbordermatrix}\Largb{}, reverses the delimiters. 
A one-element array, e.g., \Lcs{kbordermatrix}\Largb{x}, yields:

\begin{codeExampleA}%[righthand width=0.6\linewidth]
{Without column specifier}
$\kbordermatrix{x}$
\end{codeExampleA}

\begin{codeExampleA}%[righthand width=0.6\linewidth]
{Using bracket}
$\kbordermatrix{x & {[],}}$
\end{codeExampleA}

which is what it should do, if you think about it.\\
If you have really tall entries, such as 
$\sum_{n=1}^{\infty} \frac{1}{2^{n}}$, you will probably need to open 
up the array in order to make enough room for the rows to line up. 
That is what the \Lcs{arraystretch} parameter is for.

\section*{Using it}
First you must put

\begin{verbatim}
\usepackage{amsmath}
\usepackage{kbordermatrix}
\end{verbatim}


in your document preamble, but you knew that. Second, \Lcs{kbordermatrix} 
only works in equations.

Here are some simple examples of use. Start by replacing 
\Lcs{left}[\Lcs{begin}\Largb{array}\Largb{\ldots} 
by \Lcs{kbordermatrix}. Note  that there is no column specifier. 
You can make as many columns as you like, but they will all be centered. 
To finish, instead of \Lcs{end}\Lcs{array}\Lcs{right}\Larg{]}, just type 
\texttt{\}}.

\begin{codeExampleA}[righthand width=0.4\linewidth]{Short example}
\kbordermatrix{\text{indices}&1&2&3&4\\
1 &M_{1,1} &M_{1,2} &M_{1,3} &M_{1,4}\\
2 &M_{2,1} &M_{2,2} &M_{2,3} &M_{2,4}}
\end{codeExampleA}

\iffalse
\begin{codeExampleA}[righthand width=0.4\linewidth]{matrix and array}
\kbordermatrix{\text{indices} & 1 & 2 & 3 & 4\\
1 &M_{1,1} &M_{1,2} &M_{1,3} &M_{1,4}\\
2 &M_{2,1} &M_{2,2} &M_{2,3} &M_{2,4}
\end{codeExampleA}
\fi

Without a column specifier, how do we put vertical rules in? 
Unfortunately, you have to put a \Lcs{vrule} in its 
own column in each row.

\begin{codeExampleA}[righthand width=0.4\linewidth]{Vertical rule}
\kbordermatrix{\text{indices} 
 & 1     &2      &\vrule & 3 & 4\\
1&M_{1,1}&M_{1,2}&\vrule&M_{1,3}&M_{1,4}\\
2&M_{2,1}&M_{2,2}&\vrule&M_{2,3}&M_{2,4}}
\end{codeExampleA}

Note the gap in the bar below the first row. This emphasizes that the 
first row is different. (It also means that I couldn't figure out a 
nice way to get rid of it and still add extra space below the first row.)

If you don't like all the horizontal space around the vertical rule, 
you can get rid of it using plain \TeX's \Lcs{omit}-command.


\begin{codeExampleA}[righthand width=0.4\linewidth]{Vertical rule}
\kbordermatrix{\text{indices} & 1 & 2 &\omit& 3 & 4\\
1 & M_{1,1} & M_{1,2} & \omit\vrule &
              M_{1,3} & M_{1,4}\\
2&M_{2,1}&M_{2,2} & \omit\vrule & M_{2,3} & M_{2,4}}
\end{codeExampleA}

If you think the vertical rule in the first row is too tall, you can 
shorten it using plain \TeX's height command.


\begin{codeExampleA}[righthand width=0.4\linewidth]{Vertical rule}
\kbordermatrix{\text{indices}
& 1 & 2 &\omit\vrule height 1ex & 3 & 4\\
1 & M_{1,1} & M_{1,2} & \omit\vrule&
              M_{1,3}&M_{1,4}\\
2 & M_{2,1} & M_{2,2} & \omit\vrule &
              M_{2,3}&M_{2,4}}
\end{codeExampleA}



Horizontal lines works as you might expect.

\begin{codeExampleA}[righthand width=0.4\linewidth]{Horizontal line}
\kbordermatrix{\mbox{indices}&
1 & 2 &\vrule & 3 & 4\\
1 &M_{1,1} & M_{1,2} & \vrule &
             M_{1,3} & M_{1,4}\\\hline
2 & M_{2,1} & M_{2,2} & \vrule &
             M_{2,3} & M_{2,4}}
\end{codeExampleA}

Notice how the \Lcs{hline} cuts across all the columns, but it 
doesn't connect to the closing bracket. I am not sure I like this 
behavior, but you can use \Lcs{cline}.

\begin{codeExampleA}[righthand width=0.4\linewidth]{Partial horizontal line}
\kbordermatrix{\text{indices} & 1 & 2 &
     \vrule & 3 & 4\\
1 & M_{1,1} & M_{1,2} &\vrule & M_{1,3} &
              M_{1,4}\\\cline{1-1} \cline{2-6}
2 & M_{2,1} & M_{2,2} & \vrule & M_{2,3}&M_{2,4}}

\kbordermatrix{\text{indices} & 1 & 2 &
   \vrule & 3 & 4\\
1 & M_{1,1} & M_{1,2} & \vrule & M_{1,3}&
              M_{1,4}\\\cline{2-6}
2 & M_{2,1} & M_{2,2} & \vrule &
              M_{2,3} & M_{2,4}}
\end{codeExampleA}

\section*{Tall items}
Here is an example of how a tall item can destroy the row alignment, 
and how it can be fixed with \Lcs{renewcommand}\Lcs{arraystretch}\Largb{2.2}.

\begin{codeExampleM}{Vertical rule}
$\kbordermatrix{\text{indices}&1&2\\
1 & \frac{M_{1,1}}{2} & \frac{M_{1,2}}{2} \\
2 & \frac{M_{2,1}}{2} & \frac{M_{2,2}}{2} \\
3 & \frac{M_{3,1}}{2} & \frac{M_{3,2}}{2}}
\left[\begin{array}{ll}
a_{1,1} & a_{1,2} \\
a_{2,1} & a_{2,2} \\
a_{3,1} & a_{3,2}
\end{array}\right]$ \quad 
\kbordermatrix{\text{indices}&1&2\\
1 & \frac{M_{1,1}}{2} & \frac{M_{1,2}}{2} \\
2 & \frac{M_{2,1}}{2} & \frac{M_{2,2}}{2} \\
3 & \frac{M_{3,1}}{2} & \frac{M_{3,2}}{2}}
\renewcommand\arraystretch{1.35}%
$\left[\begin{array}{ll}
a_{1,1} & a_{1,2} \\
a_{2,1} & a_{2,2} \\
a_{3,1} & a_{3,2}
\end{array}\right]$ 
\end{codeExampleM}

\iffalse

\section*{The first example}
By the way, the listing for the first display is (in part):



\begin{verbatim}
\kbordermatrix{\text{indices}&
(1\cdot11)&(1\cdot12)&(1\cdot22)&
\vrule&
(2\cdot11)&(2\cdot12)&(2\cdot22)\\
%
(1)&\lambda(1)^2&2\lambda(1)\lambda(2)&\lambda(2)^2&\vrule&0&0&0\\
\end{verbatim}

\begin{verbatim}
(2)&O&O&O&\vrule&\lambda(1)^2&2\lambda(1)\lambda(2)&\lambda(2)^2\\
\hline
(111)&3&0&0&\vrule&0&0&0\\
(112)&0&2&0&\vrule&1&0&0\\
(122)&O&O&1&\vrule&0&2&0\\
(222)&O&O&O&\vrule&O&O&3}
\end{verbatim}
\fi

where \Lcs{text} is defined in the amstext package.

\section*{Changing delimiters}
The kbordermatrix package uses four style parameters that can be 
used to change the appearance of the array. The first two are saved internally as 
\Lcs{kbldelim} and \Lcs{kbrdelim}, the left and right delimiters. 
By default they are [ and ] but you can change them like this:

\begin{codeExampleA}[righthand width=0.4\linewidth]{Short example}
\kbordermatrix\{.{
  \text{indices}&1&2&3&4\\
1 &M_{1,1} &M_{1,2} &M_{1,3} &M_{1,4}\\
2 &M_{2,1} &M_{2,2} &M_{2,3} &M_{2,4}}
\end{codeExampleA}



\begin{codeExampleA}[righthand width=0.4\linewidth]{Short example}
\kbordermatrix\langle|{%
  \text{indices}&1&2&3&4\\
1 &M_{1,1} &M_{1,2} &M_{1,3} &M_{1,4}\\
2 &M_{2,1} &M_{2,2} &M_{2,3} &M_{2,4}}
\end{codeExampleA}

Or if you really like the \Lcs{bordermatrix} look, try

\begin{codeExampleA}[righthand width=0.4\linewidth]{Short example}
\kbordermatrix(){%
  \text{indices}&1&2&3&4\\
1 &M_{1,1} &M_{1,2} &M_{1,3} &M_{1,4}\\
2 &M_{2,1} &M_{2,2} &M_{2,3} &M_{2,4}}
\end{codeExampleA}



\section*{Changing the border row and column style}
You can change the style of the border row and column column entries 
by redefining \Lcs{kbrowstyle} and \Lcs{kbcolstyle}, 
which are by default set to \Lcs{scriptstyle}. You could, 
for instance, say
\verb|\renewcommand\kbrowstyle{\relax}| to typeset the first row as 
usual. By the way, the upper left corner is governed by the column style. 
You can always use an \verb|\mbox{...}| to change the style 
of any particular entry.\verb|\relax}| to typeset the first 
row as usual. By the way, the upper left corner is governed by the column style. 

%You can always use an $\backslash \operatorname{mbox}\}$ to change the style of 
%any particular entry.

\section*{Changing spacing}
Besides changing the delimiters, you can also change the space inserted 
after the first row and after the first column. These are governed by the 
lengths \Lcs{kbrowsep} and \Lcs{kbcolsep}. By default 
they are .2ex and 0.5\Lcs{arraycolsep}, respectively.

\begin{codeExampleA}[righthand width=0.4\linewidth]{Row sep}
\setlength\kbrowsep{0pt}
\setlength\kbcolsep{26pt}
\kbordermatrix{\text{indices}&1&2&3&4\\
1 &M_{1,1} &M_{1,2} &M_{1,3} &M_{1,4}\\
2 &M_{2,1} &M_{2,2} &M_{2,3} &M_{2,4}}
\end{codeExampleA}


Note how \Lcs{setlength}\Lcs{kbrowsep}\Largb{0pt} connects the vertical rule.

\section*{Comparison with the array environment}
There are some differences from the familiar 
\Lcs{left}[\Lcs{begin}\Largb{array}\ldots \Lcs{end}\Largb{array}\Lcs{right}] 
construction. 

\begin{enumerate}
  \item It takes the array as an argument. It does not use 
  \Lcs{begin}\ldots\Lcs{end}. Is this a feature or a bug?
  \item Consequently, you cannot use a column specifier. % (e.g.,  $\{l \mid c r\}$ ).
  \item Consequently the maximum number of columns is not specified.
  \item All columns are centered.
  \item Vertical rules must be put in each row in a separate column as \Lcs{vrule}.
  \item The first row and column are spaced a bit further apart from the rest.
  \item The way the array is centered vertically, it is almost as if there is an 
  invisible bottom row of the same height as the segregated top row that 
  adds to the height of the equation. You can see that here. The 
  \Lcs{fbox}\Largb{\ldots} puts a box around the array, but the 
  \Lcs{left}\ldots\Lcs{right} show its relation to the "math axis.
\end{enumerate}



\begin{codeExampleA}[righthand width=0.4\linewidth]{Short example}
\fboxsep0pt
$\left\{\fbox{$\kbordermatrix{&1&2\\
1&A&B\\
2&C&D\\
3&E&F}$}\right\}$
\end{codeExampleA}

\section*{Comparison with Knuth}
The \Lcs{kbordermatrix} command is based on Knuth's \Lcs{bordermatrix} command, 
which is defined on page 361 of The \TeX book. It also borrows from his 
\Lcs{vrulealign} command on page 392 . His command yields a display like this:

\begin{codeExampleM}{\TeX\ example}
$\bordermatrix{\text{indices}
    & (1--11) & (1--12) & (1--22) &\vrule & (2--11) & (2--12) & (2--22)   \cr
(1) & \lambda(1)^2 & 2\lambda(1)\lambda(2) & \lambda(2)^2 &\vrule & 0&0&0 \cr
(2) & 0 & 0 & 0 &\vrule & \lambda()^2 & 2 \lambda(1) \lambda(2) & \lambda(2)^2 \cr\hline
(111) & 3 & 0 & 0 & \vrule & 0 & 0 & 0 \cr
(112) & 0 & 2 & 0 & \vrule & 1 & 0 & 0 \cr
(122) & 0 & 0 & 1 & \vrule & 0 & 2 & 0 \cr
(222) & 0 & 0 & 0 & \vrule & 0 & 0 & 3 }$
\def\arraystretch{1}
$\left[\begin{array}{l}p_{1 \cdot 11} \cr p_{1 \cdot 12} \cr p_{1 \cdot 22} \cr\hline 
 p_{2 \cdot 11} \cr p_{2 \cdot 12} \cr p_{2 \cdot 22}
 \end{array}\right]
\begin{array}{c} =\cr =\cr\hline \leq \cr\leq\cr \leq\cr \leq \end{array}
\left[\begin{array}{c}P_{1} \cr P_{2} \cr \hline 
 1 \cr 1 \cr 1 \cr 1\end{array}\right]$ 
\end{codeExampleM}



This is not bad, but not surprisingly, I like mine better.\\
To illustrate a difference, let's »open up« the arrays with the 
\LaTeX-command \Lcs{arraystretch}


\begin{codeExampleM}{\LaTeX\ example}
\renewcommand\arraystretch{1.5}
$\kbordermatrix{\text{indices}
    & (1--11) & (1--12) & (1--22) &\vrule & (2--11) & (2--12) & (2--22)   \\
(1) & \lambda(1)^2 & 2\lambda(1)\lambda(2) & \lambda(2)^2 &\vrule & 0&0&0 \\
(2) & 0 & 0 & 0 &\vrule & \lambda()^2 & 2 \lambda(1) \lambda(2) & \lambda(2)^2 \\\hline
(111) & 3 & 0 & 0 & \vrule & 0 & 0 & 0 \\
(112) & 0 & 2 & 0 & \vrule & 1 & 0 & 0 \\
(122) & 0 & 0 & 1 & \vrule & 0 & 2 & 0 \\
(222) & 0 & 0 & 0 & \vrule & 0 & 0 & 3 }$
$\left[\begin{array}{l}
  p_{1 \cdot 11} \\ p_{1 \cdot 12} \\ p_{1 \cdot 22} \\\hline 
  p_{2 \cdot 11} \\ p_{2 \cdot 12} \\ p_{2 \cdot 22}\end{array}\right]
\begin{array}{c} =\\ =\\\hline \leq \\\leq\\ \leq\\ \leq \end{array}
\left[\begin{array}{c}P_{1} \\ P_{2} \\ \hline 
 1 \\ 1 \\ 1 \\ 1\end{array}\right]$ 
\end{codeExampleM}



Notice that the rows of the \Lcs{kbordermatrix}, which was designed 
with \TeX\ in mind, continue to line up with the other arrays, while 
\Lcs{bordermatrix}, which was written long before \LaTeX\, does not.

The \Lcs{kbordermatrix}, being derived from \Lcs{bordermatrix}, 
has a number of points in common with it.

\begin{enumerate}
  \item It takes the array as an argument. It does not use 
  \Lcs{begin}\ldots\Lcs{end}. Is this a feature or a bug? \}
  \item The lower $(n-1) \times(n-1)$ block is set off by delimiters.
  \item There is an invisible bottom row of the same height as the 
  segregated top row that adds to the height of the equation.
\end{enumerate}

But there are some differences from \Lcs{bordermatrix}:

\begin{enumerate}
  \item Square brackets are used in place of parentheses. (But you can change that.)
  \item By default the first row and column are set with \Lcs{scriptstyle}. 
  (But you can change that.)
  \item You may use \Lcs{\textbackslash} instead of \Lcs{cr}.
  \item The line heights agree with LaTeX's line heights for the 
  array environment, and \Lcs{arraystretch} is respected. This means 
  the bottom ( $n-1$ ) rows align with the rows of an ( $n-1$ )-rowed 
  \Lcs{begin}\Lenv{array}\ldots\Lcs{end}\Lenv{array} (with or without delimiters).
  \item You can use \Lcs{hline} and \Lcs{cline}.
  \item All columns are centered. Knuth's first column is left justified.
  \item There is more space following the first row and column. (But you can change that.)
  \item Knuth's \Lcs{bordermatrix} handles an empty argument more gracefully.
\end{enumerate}

\section*{Why you need it}
You might think that making such a display is easy, but let's see 
how we might try it. Here are some simpler displays. 
A standard \TeX\  matrix array, is usually made like this,

\begin{codeExampleA}{\TeX\ example}
\[
\left[\begin{array}{l|cr}
 \mbox{indices}&(1\cdot11)&(2\cdot11)\\\hline
  1 & a_{1,(1\cdot11)}&a_{1,(2\cdot11)}\\
  2 & a_{1,(1\cdot11)}&?
\end{array}\right]
\]
\end{codeExampleA}


This is not bad for a labeled bordered matrix, but let's put this next 
to another array.

\begin{codeExampleM}{\TeX\ array}
$ \left[\begin{array}{l|cr}\mbox{indices}& (1\cdot11)&(2\cdot11)\\\hline
  1&a_{1,(1\cdot11)}&a_{1,(2\cdot11)}\\  2&a_{1,(1\cdot11)}&?
  \end{array}\right]  \left[\begin{array}{cr}
  b_{1,(1\cdot11)}&b_{1,(2\cdot11)}\\ b_{1,(1\cdot11)}&b_{2,(2\cdot11)}
  \end{array}\right] \left[\begin{array}{l|rr}
\text{indices} & (1 \cdot 11) & (2 \cdot 11) \\ \hline 1&a_{1,(1\cdot 11)}&a_{1,(2 \cdot 11)} \\
2 & a_{1,(1 \cdot 11)} & ? \end{array}\right]\left[\begin{array}{ll}
b_{1,(1 \cdot 11)} & b_{1,(2 \cdot 11)} \\ b_{1,(1 \cdot 11)} & b_{2,(2 \cdot 11)}
\end{array}\right]$
\end{codeExampleM}

Usually you would want the rows to line up, and they don't. You can fix 
this by adding an extra blank row to the second array, like this,

\begin{codeExampleM}{\TeX\ array}
$\left[\begin{array}{l|cr}
\mbox{indices}&(1\cdot11)&(2\cdot11)\\\hline 1&a_{1,(1\cdot11)}&a_{1,(2\cdot11)}\\
2&a_{1,(1\cdot11)}&?  [\begin{array}{l|rr}{\text{indices}} & (1\cdot 11) & (2\cdot 11)\\\hline 
  1&{a_{1,(1\cdot 11)}}&{a_{1,(2\cdot 11)}}\\  2&{a_{1,(1\cdot11)}}&{?}\end{array}] 
  [\begin{array}{ll}   {}&{}\\  b_{1,(1\cdot11)}&{b_{1,(2\cdot11)}}\\
  b_{1,(1\cdot11)}&b_{2,(2\cdot11)}  \end{array}] \end{array}\right]
\left[\begin{array}{cr}\\ b_{1,(1\cdot11)}&b_{1,(2\cdot11)}\\
b_{1,(1\cdot11)}&b_{2,(2\cdot11)} \end{array}\right]$
\end{codeExampleM}

Now the brackets on the second don't look right. So you could put the 
second array inside another array, like this:


\begin{codeExampleM}{\TeX\ array}
$\left[\begin{array}{lcr} \mbox{indices} & (1\cdot11) & (2\cdot11)\\
1 & a_{1,(1\cdot11)} & a_{1,(2\cdot11)}\\  2 & a_{1,(1\cdot11)} & ?
\end{array}\right] [ \begin{array}{lrr}
  \text{indices} & (1\cdot11) & (2\cdot11)\\ 1 & a_{1,(1\cdot11)} & a_{1,(2\cdot11)}\\
  2 & a_{1,(1\cdot11)} &?
  \end{array}]   [\begin{array}{ll}
  b_{1,(1\cdot11)} & b_{1,(2\cdot11)}\\  b_{1,(1\cdot11)} & b_{2,(2\cdot11)}
  \end{array}]   \begin{array}{c} \\ \left[\begin{array}{cr}
  b_{1,(1\cdot11)}&b_{1,(2\cdot11)}\\  b_{1,(1\cdot11)}&b_{2,(2\cdot11)}
\end{array}\right] \end{array}$
\end{codeExampleM}

This is much better, but the brackets on the left aren't where a 
mathematician wants them. Let's try the array inside an array trick again:


\begin{codeExampleA}{Trick}
$\begin{array}{lc}
  \mbox{indices} & \begin{array}{cr}
  (1\cdot11) & (2\cdot11)\end{array}\\
\begin{array}{c}1\\2 \end{array} &
\left[\begin{array}{cr}
 a_{1,(1\cdot11)} & a_{1,(2\cdot11)}\\
 a_{1,(1\cdot11)}&?
\end{array}\right]
\end{array}$
\end{codeExampleA}

This works well in this case, but here is a natural example where this 
technique fails:

\begin{codeblockA}
\begin\{array\}\{lc\} }
\mbox\{indices\}\&
indices
\begin\{array\}\{cccc\}1\&2\&3\&4\end\{array\}\\}
\begin\{array\}\{c\}1\\2\end\{array\}\& }
\left[\begin\{array\}\{cccc\}\} }
M_\{1,1\}\&M_\{1,2\}\&M_\{1,3\}\&M_\{1,4\}\\
M_\{2,1\}\&M_\{2,2\}\&M_\{2,3\}\&M_\{2,4\}
\end\{array\}\right] }
\end\{array\} }
\end{codeblockA}

The problem is that by having three separate arrays for the first row, 
first column, and the body, the columns cannot maintain their spacing. 
You might try to use the \Lcs{lceil}, \Lcs{lfoor}, etc., commands to 
construct the delimiter on your own. The problem is matching the vertical 
rules with these pieces. It isn't well documented in 
The \TeX book. Moreover, you need to add blank rows at the top of 
you other arrays to get the proper row alignment. Here is my best 
shot at this approach, and it works reasonably well, at least in the 
one or two arrays I have used it. (It's on the left, \Lcs{kbordermatrix} 
is on the right.)


\noindent
\hfill \Lcs{bordermatrix}\hfill\Lcs{kbordermatrix}\hfill\null

$\displaystyle
\begin{array}{ccc}
\text { indices } & (j, t) & \\
 \begin{array}{c} 
 \vdots \\(i, \tau)\\ \vdots \\\hline
 \vdots \\ s \\ \vdots \end{array} 
&
 \left[\begin{array}{ccc} 
   &\vdots& \\
 \cdots& \delta_{i,j}\delta_{\tau,t_{j}}\mu_{i}\left(t^{-j}\mid\tau\right)&\cdots\\
   &\vdots& \\\hline
   &\vdots& \\
 \cdots & \delta_{s, t} & \cdots \\
   & \vdots & \end{array} \right]
\end{array}\quad\left[\begin{array}{c}
1 \\
2 \\
3 \\
\hline 4 \\
5 \\
6
\end{array}\right]$
\hfill
$\displaystyle\left[\begin{array}{c}
1 \\
2 \\
3 \\
\hline 4 \\
5 \\
6
\end{array}\right]
\quad 
\kbordermatrix{%
\text{indices} & (j, t) & \\
\vdots & \vdots & \\
(i, \tau) & \cdots & \delta_{i, j} \delta_{\tau, t_{j}} \mu_{i}\left(t^{-j}\mid\tau\right) & \cdots \\
\vdots & & \vdots & \\\hline 
\vdots & & \vdots & \\
s & \cdots & \delta_{s, t} & \cdots \\
\vdots & & \vdots & }$


\printbibliography

\printindex

\end{document}