3

How would one typset an array with cells above a bmatrix, something like

[a] & [b]
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix}

Where somehow the [a] and [b] cells would appear aligned and above the bmatrix.

David Carlisle
  • 757,742
ccook
  • 133
  • 5

4 Answers4

3

You can use a modified \bordermatrix. It is described in mathmode.

You can also use blkarray package for convenience, see also this question.

\documentclass{article}
\usepackage{blkarray}
\begin{document}

\[
\begin{blockarray}{cc}
[a] & [b] \\
\begin{block}{[cc]}
1 & 2 \\
3 & 4 \\
\end{block}
\end{blockarray}
\]

\end{document}

enter image description here

Leo Liu
  • 77,365
  • Is there a solution within the math environment? Great solution, but I need it to be within an equation environment. – ccook Feb 11 '11 at 14:30
  • @ccook: \[ ... \] is the math environment. You can replace it with euqation env. – Leo Liu Feb 11 '11 at 14:32
  • I should have made less of an assumption. I'm trying to typeset it for wikimedia and it doesn't recognize the blocks :( – ccook Feb 11 '11 at 14:34
  • @ccook: Wiki uses part of TeX syntax for math formulas. However, wiki does NOT have full TeX abilities. You'll have to use the restricted TeX described in http://en.wikipedia.org/wiki/Wikipedia:Editing_Math – Leo Liu Feb 11 '11 at 14:41
1

Instead of \[...\] you can use $...$. one example with arrays and one with \multicolumn

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\[
\begin{array}{cc}
[a] & [b]\\
\left[\begin{array}{c}
1\\
3 
\end{array}\right. &
\left.\begin{array}{c}
2\\
4 
\end{array}\right] 
\end{array}
\]

\[
\begin{array}{cc}
[a] & [b]\\
\multicolumn{2}{@{}c@{}}{%
\begin{bmatrix}
~1 & 2~ \\
~3 & 4~
\end{bmatrix}}%
\end{array}
\]

\end{document}

enter image description here

David Carlisle
  • 757,742
1

For wikipedia only, you can use this manual dirty version. It is tested in Wikipedia's sandbox.

<math>
\begin{matrix}
\begin{matrix} [a] & [b] \end{matrix} \\
\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
\end{matrix}
</math>
David Carlisle
  • 757,742
Leo Liu
  • 77,365
  • Thank you, this works well for wikimedia. I did have to push the header around with \quad, but as you said, quick and dirty for wikimedia. – ccook Feb 11 '11 at 14:54
0

With {bNiceMatrix} of nicematrix and its key first-row.

\documentclass{article}
\usepackage{nicematrix}
\begin{document}

[ \begin{bNiceMatrix}[first-row] [a] & [b] \ 1 & 2 \ 3 & 4 \ \end{bNiceMatrix} ]

\end{document}

Output of the above code

F. Pantigny
  • 40,250