Learn how to create professional matrices in LaTeX with this comprehensive guide. From basic 2×2 matrices to complex block structures, master all matrix environments and techniques for mathematical typesetting.
What You’ll Learn
✅ All matrix environments (pmatrix, bmatrix, vmatrix, etc.)
✅ Creating arrays with custom delimiters
✅ Block matrices and augmented matrices
✅ Matrix operations and notation
✅ Small inline matrices
✅ Advanced formatting and decorations
✅ Troubleshooting common issues
Basic Matrix Environments
LaTeX provides six standard matrix environments through the amsmath
package, each with different delimiters:
Matrix Environment Overview
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Parentheses matrix (most common)
$ \begin { pmatrix }
a & b \\
c & d
\end { pmatrix } $
% Square bracket matrix
$ \begin { bmatrix }
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end { bmatrix } $
% Curly brace matrix
$ \begin { Bmatrix }
x_ 1 \\
x_ 2 \\
x_ 3
\end { Bmatrix } $
% Determinant (vertical bars)
$ \begin { vmatrix }
a & b \\
c & d
\end { vmatrix } = ad - bc $
% Norm (double vertical bars)
$ \begin { Vmatrix }
\mathbf{v}
\end { Vmatrix } = \begin { Vmatrix }
1 & 2 \\
3 & 4
\end { Vmatrix } $
% No delimiters
$ \begin { matrix }
a & b \\
c & d
\end { matrix } $
\end { document }
Rendered output:
All matrix environments with different delimiters:
Matrix Environment Summary Table
Environment Delimiters Common Use Example matrix
None Building block for custom delimiters Basic array pmatrix
( ) General matrices, transformations Linear algebra bmatrix
[ ] General matrices, data tables Numerical data Bmatrix
Set notation, systems Set theory vmatrix
| | Determinants det(A) Vmatrix
|| || Norms, magnitudes ||v||
Creating Your First Matrix
Simple 2×2 Matrix
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Basic 2x2 matrix
The matrix $ A = \begin { pmatrix }
1 & 2 \\
3 & 4
\end { pmatrix } $ is invertible.
% With variables
The general form is $ \begin { pmatrix }
a & b \\
c & d
\end { pmatrix } $ where $ ad - bc \neq 0 $ .
% Matrix equation
$ \begin { pmatrix }
2 & 1 \\
1 & 3
\end { pmatrix }
\begin { pmatrix }
x \\
y
\end { pmatrix }
=
\begin { pmatrix }
5 \\
7
\end { pmatrix } $
\end { document }
Rendered output:
The matrix A =
(
1 2 3 4 ) is invertible. The general form is
(
a b c d )
where ad - bc ≠ 0 .
( 2 1 1 3 ) ( x y ) = ( 5 7 )
Key points for matrix creation:
Use &
to separate columns
Use \\
to end rows
Don’t add \\
after the last row
Matrices must be in math mode ($...$
or \[...\]
)
Matrix Elements and Structure
Matrix with Subscripts
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% General m×n matrix
$ A = \begin { pmatrix }
a_{ 11 } & a_{ 12 } & \cdots & a_{ 1 n} \\
a_{ 21 } & a_{ 22 } & \cdots & a_{ 2 n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m 1 } & a_{m 2 } & \cdots & a_{mn}
\end { pmatrix } $
% 3×3 example
$ B = \begin { bmatrix }
b_{ 11 } & b_{ 12 } & b_{ 13 } \\
b_{ 21 } & b_{ 22 } & b_{ 23 } \\
b_{ 31 } & b_{ 32 } & b_{ 33 }
\end { bmatrix } $
% Column vector
$ \mathbf{x} = \begin { pmatrix }
x_ 1 \\
x_ 2 \\
x_ 3 \\
\vdots \\
x_n
\end { pmatrix } $
% Row vector
$ \mathbf{y}^T = \begin { pmatrix }
y_ 1 & y_ 2 & y_ 3 & \cdots & y_n
\end { pmatrix } $
\end { document }
Rendered output:
General m×n matrix with subscript notation:
A = ( a₁₁ a₁₂ ⋯ a₁ₙ a₂₁ a₂₂ ⋯ a₂ₙ ⋮ ⋮ ⋱ ⋮ aₘ₁ aₘ₂ ⋯ aₘₙ )
Column and row vectors:
Column vector
x = ( x₁ x₂ x₃ ⋮ xₙ )
Row vector
y T = ( y₁ y₂ y₃ ⋯ yₙ )
Using Dots in Matrices
LaTeX provides three types of dots for indicating patterns in matrices:
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Horizontal dots: \cdots
% Vertical dots: \vdots
% Diagonal dots: \ddots
% General matrix pattern
$ \begin { bmatrix }
a_{ 11 } & a_{ 12 } & \cdots & a_{ 1 n} \\
a_{ 21 } & a_{ 22 } & \cdots & a_{ 2 n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m 1 } & a_{m 2 } & \cdots & a_{mn}
\end { bmatrix } $
% Diagonal matrix
$ D = \begin { bmatrix }
d_ 1 & 0 & \cdots & 0 \\
0 & d_ 2 & \ddots & \vdots \\
\vdots & \ddots & \ddots & 0 \\
0 & \cdots & 0 & d_n
\end { bmatrix } $
% Block pattern
$ \begin { pmatrix }
A_{ 11 } & A_{ 12 } & \cdots & A_{ 1 n} \\
A_{ 21 } & A_{ 22 } & \cdots & A_{ 2 n} \\
\vdots & \vdots & \ddots & \vdots \\
A_{m 1 } & A_{m 2 } & \cdots & A_{mn}
\end { pmatrix } $
\end { document }
Rendered output:
Different types of dots in matrices:
General matrix with all dot types
[ a₁₁ a₁₂ ⋯ a₁ₙ a₂₁ a₂₂ ⋯ a₂ₙ ⋮ ⋮ ⋱ ⋮ aₘ₁ aₘ₂ ⋯ aₘₙ ]
Diagonal matrix pattern
D = [ d₁ 0 ⋯ 0 0 d₂ ⋱ ⋮ ⋮ ⋱ ⋱ 0 0 ⋯ 0 dₙ ]
Special Matrix Types
Identity and Zero Matrices
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Identity matrix
$ I_ 3 = \begin { pmatrix }
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end { pmatrix } $
% General identity
$ I_n = \begin { pmatrix }
1 & 0 & \cdots & 0 \\
0 & 1 & \cdots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & 1
\end { pmatrix } $
% Zero matrix
$ \mathbf{ 0 }_{ 3 \times 3 } = \begin { pmatrix }
0 & 0 & 0 \\
0 & 0 & 0 \\
0 & 0 & 0
\end { pmatrix } $
% Ones matrix
$ \mathbf{ 1 }_{ 2 \times 3 } = \begin { pmatrix }
1 & 1 & 1 \\
1 & 1 & 1
\end { pmatrix } $
\end { document }
Rendered output:
3×3 Identity matrix
I ₃ = ( 1 0 0 0 1 0 0 0 1 )
3×3 Zero matrix
0 ₃ₓ₃ = ( 0 0 0 0 0 0 0 0 0 )
2×3 Ones matrix
1 ₂ₓ₃ = ( 1 1 1 1 1 1 )
Triangular Matrices
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Upper triangular
$ U = \begin { pmatrix }
u_{ 11 } & u_{ 12 } & u_{ 13 } & u_{ 14 } \\
0 & u_{ 22 } & u_{ 23 } & u_{ 24 } \\
0 & 0 & u_{ 33 } & u_{ 34 } \\
0 & 0 & 0 & u_{ 44 }
\end { pmatrix } $
% Lower triangular
$ L = \begin { pmatrix }
l_{ 11 } & 0 & 0 & 0 \\
l_{ 21 } & l_{ 22 } & 0 & 0 \\
l_{ 31 } & l_{ 32 } & l_{ 33 } & 0 \\
l_{ 41 } & l_{ 42 } & l_{ 43 } & l_{ 44 }
\end { pmatrix } $
% Strictly upper triangular
$ U_ 0 = \begin { pmatrix }
0 & u_{ 12 } & u_{ 13 } \\
0 & 0 & u_{ 23 } \\
0 & 0 & 0
\end { pmatrix } $
% Tridiagonal
$ T = \begin { pmatrix }
a_ 1 & b_ 1 & 0 & 0 \\
c_ 1 & a_ 2 & b_ 2 & 0 \\
0 & c_ 2 & a_ 3 & b_ 3 \\
0 & 0 & c_ 3 & a_ 4
\end { pmatrix } $
\end { document }
Rendered output:
Upper triangular
U = ( u₁₁ u₁₂ u₁₃ u₁₄ 0 u₂₂ u₂₃ u₂₄ 0 0 u₃₃ u₃₄ 0 0 0 u₄₄ )
Lower triangular
L = ( l₁₁ 0 0 0 l₂₁ l₂₂ 0 0 l₃₁ l₃₂ l₃₃ 0 l₄₁ l₄₂ l₄₃ l₄₄ )
Tridiagonal
T = ( a₁ b₁ 0 0 c₁ a₂ b₂ 0 0 c₂ a₃ b₃ 0 0 c₃ a₄ )
Arrays - The Foundation of Matrices
The array
environment provides the most flexibility for creating custom matrix-like structures:
Basic Array Usage
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Basic array with alignment
$ \begin { array }{crl}
\text{center} & \text{right} & \text{left} \\
a + b & 12.34 & xyz \\
c & 5.6 & pqrs
\end { array } $
% Array with vertical lines
$ \left[ \begin { array }{c|cc|c}
1 & 2 & 3 & 4 \\
\hline
5 & 6 & 7 & 8
\end { array }\right] $
% Custom spacing
$ \begin { array }{r@{ \, }c@{ \, }l}
x & = & 2 y + 3 z \\
2 x - y & = & 7 \\
x + 3 y & = & 4 z - 1
\end { array } $
% Mixed content
$ \begin { array }{|l|c|}
\hline
\text{Type} & \text{Matrix} \\
\hline
\text{Identity} & \begin { pmatrix } 1 & 0 \\ 0 & 1 \end { pmatrix } \\
\hline
\text{Zero} & \begin { pmatrix } 0 & 0 \\ 0 & 0 \end { pmatrix } \\
\hline
\end { array } $
\end { document }
Rendered output:
Array with different column alignments (center, right, left):
center right left a + b 12.34 xyz c 5.6 pqrs
Array with vertical lines and horizontal rule:
System of equations with custom spacing:
x = 2y + 3z 2x − y = 7 x + 3y = 4z − 1
Array Column Specifiers
Specifier Alignment Description l
Left Left-aligned column c
Center Centered column r
Right Right-aligned column p{width}
Paragraph Fixed width with text wrapping ` ` — Vertical line between columns @{text}
— Custom separator (replaces default spacing) *{n}{spec}
— Repeat specifier n times
Block Matrices
Block matrices are used to partition large matrices into smaller submatrices:
Basic Block Matrices
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Simple 2×2 block matrix
$ M = \begin { pmatrix }
A & B \\
C & D
\end { pmatrix } $
% With array for lines
$ \left[ \begin { array }{c|c}
A & B \\
\hline
C & D
\end { array }\right] $
% Detailed block matrix
$ \begin { pmatrix }
\begin { matrix }
a_{ 11 } & a_{ 12 } \\
a_{ 21 } & a_{ 22 }
\end { matrix } &
\begin { matrix }
b_{ 11 } & b_{ 12 } \\
b_{ 21 } & b_{ 22 }
\end { matrix } \\ [ 1 em]
\begin { matrix }
c_{ 11 } & c_{ 12 } \\
c_{ 21 } & c_{ 22 }
\end { matrix } &
\begin { matrix }
d_{ 11 } & d_{ 12 } \\
d_{ 21 } & d_{ 22 }
\end { matrix }
\end { pmatrix } $
% Mixed size blocks
$ \begin { pmatrix }
A_{ 2 \times 2 } & \mathbf{b}_{ 2 \times 1 } \\
\mathbf{c}_{ 1 \times 2 } & d_{ 1 \times 1 }
\end { pmatrix }
=
\begin { pmatrix }
\begin { matrix }
a & b \\
c & d
\end { matrix } & \begin { matrix } e \\ f \end { matrix } \\ [ 0.5 em]
\begin { matrix } g & h \end { matrix } & i
\end { pmatrix } $
\end { document }
Rendered output:
Block matrix with dividing lines:
Mixed size blocks (2×2 matrix with vector and scalar):
Augmented Matrices
Augmented matrices are commonly used for solving systems of linear equations:
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Basic augmented matrix
$ \left[ \begin { array }{ccc|c}
1 & 2 & 3 & 6 \\
4 & 5 & 6 & 15 \\
7 & 8 & 9 & 24
\end { array }\right] $
% Row reduction example
$ \left[ \begin { array }{rrr|r}
1 & 2 & - 1 & 3 \\
2 & - 1 & 3 & 7 \\
- 1 & 3 & 2 & 0
\end { array }\right]
\xrightarrow{R_ 2 - 2 R_ 1 }
\left[ \begin { array }{rrr|r}
1 & 2 & - 1 & 3 \\
0 & - 5 & 5 & 1 \\
- 1 & 3 & 2 & 0
\end { array }\right] $
% Extended augmentation
$ \left[ \begin { array }{cc|c|cc}
a & b & e & 1 & 0 \\
c & d & f & 0 & 1
\end { array }\right] $
\end { document }
Rendered output:
Augmented matrix for system of equations:
Matrix Operations
Basic Operations Notation
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Matrix multiplication
$ AB = \begin { pmatrix }
a & b \\
c & d
\end { pmatrix }
\begin { pmatrix }
e & f \\
g & h
\end { pmatrix }
= \begin { pmatrix }
ae + bg & af + bh \\
ce + dg & cf + dh
\end { pmatrix } $
% Transpose
$ A^T = \begin { pmatrix }
1 & 2 & 3 \\
4 & 5 & 6
\end { pmatrix }^T
= \begin { pmatrix }
1 & 4 \\
2 & 5 \\
3 & 6
\end { pmatrix } $
% Inverse (2×2 formula)
$ A^{- 1 } = \begin { pmatrix }
a & b \\
c & d
\end { pmatrix }^{- 1 }
= \frac{ 1 }{ad-bc}
\begin { pmatrix }
d & -b \\
-c & a
\end { pmatrix } $
% Matrix power
$ A^ 2 = AA = \begin { pmatrix }
1 & 2 \\
3 & 4
\end { pmatrix }^ 2
= \begin { pmatrix }
7 & 10 \\
15 & 22
\end { pmatrix } $
\end { document }
Rendered output:
Matrix multiplication:
AB = ( a b c d ) ( e f g h ) = ( ae + bg af + bh ce + dg cf + dh )
Matrix transpose:
AT = ( 1 2 3 4 5 6 )T = ( 1 4 2 5 3 6 )
2×2 matrix inverse formula:
A−1 = ( a b c d )−1 = 1 ad − bc
( d −b −c a )
Determinants and Traces
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% 2×2 determinant
$ \det(A) = \begin { vmatrix }
a & b \\
c & d
\end { vmatrix } = ad - bc $
% 3×3 determinant
$ \begin { vmatrix }
a_{ 11 } & a_{ 12 } & a_{ 13 } \\
a_{ 21 } & a_{ 22 } & a_{ 23 } \\
a_{ 31 } & a_{ 32 } & a_{ 33 }
\end { vmatrix } $
% Alternative notations
$ |A| = \det(A) = \det \begin { pmatrix }
1 & 2 \\
3 & 4
\end { pmatrix } = - 2 $
% Trace
$ \text{tr}(A) = \sum _{i= 1 }^n a_{ii} = a_{ 11 } + a_{ 22 } + \cdots + a_{nn} $
% Example
$ \text{tr} \begin { pmatrix }
5 & 2 & 1 \\
3 & 7 & 4 \\
6 & 8 & 9
\end { pmatrix } = 5 + 7 + 9 = 21 $
\end { document }
Rendered output:
2×2 determinant calculation:
det(A) = | a b c d | = ad − bc
Trace example:
tr( 5 2 1 3 7 4 6 8 9 ) = 5 + 7 + 9 = 21
Small Inline Matrices
For matrices within text, use the smallmatrix
environment:
\documentclass { article }
\usepackage { amsmath }
\begin { document }
% Inline matrix in text
The rotation matrix $ \left( \begin { smallmatrix }
\cos \theta & -\sin \theta \\
\sin \theta & \cos \theta
\end { smallmatrix }\right) $ rotates vectors by angle $ \theta $ .
% Pauli matrices
The Pauli matrices are
$ \sigma _x = \left( \begin { smallmatrix }
0 & 1 \\
1 & 0
\end { smallmatrix }\right) $ ,
$ \sigma _y = \left( \begin { smallmatrix }
0 & -i \\
i & 0
\end { smallmatrix }\right) $ , and
$ \sigma _z = \left( \begin { smallmatrix }
1 & 0 \\
0 & - 1
\end { smallmatrix }\right) $ .
% Custom command for convenience
\newcommand { \mat }[1]{ \left ( \begin { smallmatrix } # 1 \end { smallmatrix } \right )}
Then we can write $ A = \mat{a & b \\ c & d} $ inline.
\end { document }
Rendered output:
The rotation matrix ( cos θ −sin θ sin θ cos θ ) rotates vectors by angle θ. The Pauli matrices are σₓ = ( 0 1 1 0 ), σᵧ = ( 0 −i i 0 ), and σᴢ = ( 1 0 0 −1 ).
Advanced Techniques
Matrices with Labels
\documentclass { article }
\usepackage { amsmath }
\usepackage { blkarray } % For labeled matrices
\begin { document }
% Using array for labels
$ \begin { array }{c|ccc}
& \text{Col 1 } & \text{Col 2 } & \text{Col 3 } \\
\hline
\text{Row 1 } & a_{ 11 } & a_{ 12 } & a_{ 13 } \\
\text{Row 2 } & a_{ 21 } & a_{ 22 } & a_{ 23 } \\
\text{Row 3 } & a_{ 31 } & a_{ 32 } & a_{ 33 }
\end { array } $
% Using blkarray package
$ \begin { blockarray }{cccc}
& x_1 & x_2 & x_3 \\
\begin { block }{c(ccc)}
y_1 & 0.8 & 0.1 & 0.1 \\
y_2 & 0.2 & 0.7 & 0.1 \\
y_3 & 0.1 & 0.2 & 0.7 \\
\end { block }
\end { blockarray } $
% Correlation matrix example
$ R = \begin { array }{c|ccc}
& X & Y & Z \\
\hline
X & 1.00 & 0.85 & 0.42 \\
Y & 0.85 & 1.00 & 0.67 \\
Z & 0.42 & 0.67 & 1.00
\end { array } $
\end { document }
Rendered output:
Matrix with row and column labels:
Col 1 Col 2 Col 3 Row 1 a₁₁ a₁₂ a₁₃ Row 2 a₂₁ a₂₂ a₂₃ Row 3 a₃₁ a₃₂ a₃₃
Correlation matrix example:
R = X Y Z X 1.00 0.85 0.42 Y 0.85 1.00 0.67 Z 0.42 0.67 1.00
Matrix Decorations
\documentclass { article }
\usepackage { amsmath }
\usepackage { color }
\begin { document }
% Highlighting diagonal elements
$ \begin { pmatrix }
\color{red} 1 & 0 & 0 \\
0 & \color{red} 2 & 0 \\
0 & 0 & \color{red} 3
\end { pmatrix } $
% Boxed elements
$ \begin { pmatrix }
\boxed{ 1 } & 0 & 0 \\
0 & \boxed{ 1 } & 0 \\
0 & 0 & \boxed{ 1 }
\end { pmatrix } $
% Matrix equation with decorations
$ \underbrace{ \begin { pmatrix }
2 & 1 \\
1 & 3
\end { pmatrix }}_{A}
\underbrace{ \begin { pmatrix }
x \\
y
\end { pmatrix }}_{\mathbf{x}}
=
\underbrace{ \begin { pmatrix }
5 \\
7
\end { pmatrix }}_{\mathbf{b}} $
% Annotated matrix
$ \left( \begin { array }{ccc}
a_{ 11 } & a_{ 12 } & a_{ 13 } \\
a_{ 21 } & a_{ 22 } & a_{ 23 } \\
a_{ 31 } & a_{ 32 } & a_{ 33 }
\end { array }\right)
\begin { array }{l}
\leftarrow \text{row 1 } \\
\leftarrow \text{row 2 } \\
\leftarrow \text{row 3 }
\end { array } $
\end { document }
Rendered output:
Highlighted diagonal elements:
Matrix equation with labels:
Common Pitfalls and Solutions
My matrix delimiters are too small
Problem : Parentheses/brackets don’t scale with matrix size.
Solution : Use \left
and \right
with array:
$ \left( \begin { array }{cc}
a & b \\
c & d
\end { array }\right) $
Or use the pre-defined environments like pmatrix
which handle this automatically.
Alignment issues in matrices
Problem : Numbers don’t align properly in columns.
Solution :
Use array
with explicit alignment: {rrr}
for right-aligned
For decimals, use the siunitx
package with S
columns
Add spacing with \phantom{}
for consistent widths
Problem : Large matrices extend beyond margins.
Solutions :
Use \small
or \footnotesize
before the matrix
Use bmatrix*}[r]
from mathtools
for right-aligned entries
Split into block matrices
Consider using array
environment with custom column spacing
Spacing between matrix elements
Problem : Elements too cramped or too spread out.
Solution : Adjust array stretch:
\renewcommand { \arraystretch }{1.5} % 1.5x normal spacing
\begin { pmatrix }
a & b \\
c & d
\end { pmatrix }
Best Practices
Matrix typesetting guidelines:
Choose appropriate delimiters : Use vmatrix
for determinants, pmatrix
for general matrices
Consistency : Use the same notation style throughout your document
Size considerations : Use smallmatrix
for inline matrices
Alignment : Right-align numbers in numeric matrices
Spacing : Add \,
or \:
for better readability when needed
Block structure : Use block matrices to show structure
Labels : Add row/column labels when they aid understanding
Package Recommendations
Essential Packages
Package Purpose Key Features amsmath
Basic matrix environments All standard matrix types mathtools
Extended matrix features Starred versions, more options array
Custom column types Full control over layout siunitx
Numeric alignment Decimal alignment in matrices blkarray
Block arrays Labels and blocks nicematrix
Enhanced matrices Many advanced features
Loading Order
\usepackage { amsmath } % Load first
\usepackage { mathtools } % Extends amsmath
\usepackage { array } % For custom columns
\usepackage { siunitx } % For numeric columns
Quick Reference Card
Matrix Environments Summary
% Basic environments (requires amsmath)
\begin { matrix } ... \end { matrix } % no delimiters
\begin { pmatrix } ... \end { pmatrix } % parentheses ( )
\begin { bmatrix } ... \end { bmatrix } % brackets [ ]
\begin { Bmatrix } ... \end { Bmatrix } % braces { }
\begin { vmatrix } ... \end { vmatrix } % single bars | |
\begin { Vmatrix } ... \end { Vmatrix } % double bars || ||
% Small matrices (inline)
\begin { smallmatrix } ... \end { smallmatrix }
% Custom delimiters with array
\left [ \begin { array } {cc} ... \end { array } \right ]
Common Patterns
% Identity matrix
\begin { pmatrix }
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end { pmatrix }
% General element notation
\begin { pmatrix }
a_{ 11 } & \cdots & a_{ 1 n} \\
\vdots & \ddots & \vdots \\
a_{m 1 } & \cdots & a_{mn}
\end { pmatrix }
% Augmented matrix
\left [ \begin { array } {cc|c}
a & b & e \\
c & d & f
\end { array } \right ]
% Block matrix
\begin { pmatrix }
A & B \\
C & D
\end { pmatrix }