10

1

How would I create an output similar to the result produced by this $ \mathrm\LaTeX $ code:

```
M = \bordermatrix{~ & x & y \cr
A & 1 & 0 \cr
B & 0 & 1 \cr}
```

which when compiled, looks like

10

1

How would I create an output similar to the result produced by this $ \mathrm\LaTeX $ code:

```
M = \bordermatrix{~ & x & y \cr
A & 1 & 0 \cr
B & 0 & 1 \cr}
```

which when compiled, looks like

10

This seems to work, at least for your example:

```
TraditionalForm @ Grid[{{Null, Grid[{{x, y}}]}, {TableForm@{{A}, {B}},
MatrixForm[IdentityMatrix[2]]}}]
```

You can make a little function that generalises it:

```
makeBordermatrix[mat_?MatrixQ, top_?VectorQ, side_?VectorQ] :=
TraditionalForm@
Grid[{{Null, Grid[{top}]}, {TableForm[Transpose@{side}],
MatrixForm[mat]}}]
```

So we have:

```
makeBordermatrix[IdentityMatrix[3], {x, y, z}, {A, B, C}]
```

1By the way, welcolme to Mathematica.SE James! – Verbeia – 2012-04-26T05:08:06.757

Ah nice, I didn't quite manage to get

`TraditionalForm`

to give it this way – rm -rf – 2012-04-26T05:12:23.6431This isn't very robust, though: try

`makeBordermatrix[IdentityMatrix[3] {aaaaaaaaaa, 0, 0}, {x, y, z}, {A, B, C}]`

and the columns get misaligned. To fix this, you could make each element of the top row have an`Overlay`

in which all matrix entries below it are stacked on top of each other with`Opacity[0]`

, to force the top row to accomodate the maximum width of the row. – Jens – 2012-04-26T06:53:47.923@Jens I know, I didn't enforce matching dimensions or lengths of objects (limited lunch break time), but it would be straightforward to do. – Verbeia – 2012-04-26T06:58:56.057