LaTeX Matrices: Create 2x2, 3x3, 4x4 and Determinants
Date Published

Creating Matrices in LaTeX
Matrices are essential for linear algebra, physics, and engineering. Here's how to create them perfectly in LaTeX.
Basic Matrix Syntax
Use the amsmath package and matrix environments:
\usepackage{amsmath}
Matrix with Parentheses (pmatrix)
$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$
Creates a 2x2 matrix with round brackets.
Matrix with Square Brackets (bmatrix)
$\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}$
Creates a 3x3 matrix with square brackets.
2x2 Matrix
$A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}$
2x2 Determinant
$\det(A) = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc$
3x3 Matrix
$B = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}$
3x3 Determinant
Use vmatrix for determinant notation:
$\begin{vmatrix} a & b & c \\ d & e & f \\ g & h & i \end{vmatrix}$
4x4 Matrix
$C = \begin{bmatrix} c_{11} & c_{12} & c_{13} & c_{14} \\ c_{21} & c_{22} & c_{23} & c_{24} \\ c_{31} & c_{32} & c_{33} & c_{34} \\ c_{41} & c_{42} & c_{43} & c_{44} \end{bmatrix}$
All Matrix Bracket Types
- matrix — no brackets - pmatrix — parentheses ( ) - bmatrix — square brackets [ ] - Bmatrix — curly braces { } - vmatrix — vertical bars | | (determinant) - Vmatrix — double bars || ||
Special Matrices
Identity Matrix
$I = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$
Diagonal Matrix
$D = \begin{bmatrix} d_1 & 0 & 0 \\ 0 & d_2 & 0 \\ 0 & 0 & d_3 \end{bmatrix}$
Zero Matrix
$O = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}$
Augmented Matrices
For systems of equations, use array with a divider:
$\left[\begin{array}{ccc|c} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ 9 & 10 & 11 & 12 \end{array}\right]$
Large Matrices with Dots
$\begin{bmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mn} \end{bmatrix}$
Use \cdots (horizontal), \vdots (vertical), \ddots (diagonal).
Matrix Operations
Multiplication
$AB = \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e & f \\ g & h \end{bmatrix}$
Transpose
$A^T = \begin{bmatrix} a & c \\ b & d \end{bmatrix}$
Inverse
$A^{-1} = \frac{1}{ad-bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}$
Column and Row Vectors
Column Vector
$\mathbf{v} = \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix}$
Row Vector
$\mathbf{u} = \begin{bmatrix} u_1 & u_2 & u_3 \end{bmatrix}$
Create Matrices with Octree
Octree simplifies matrix creation:
- Visual matrix builder - Auto-formats rows and columns - Real-time preview - AI fixes alignment issues
Try it at https://useoctree.com

Learn LaTeX in 2025 with modern AI-powered tools. From setup to advanced tips, this guide helps you write papers, resumes, and documents like a pro.

Introducing Octree — an open-source AI-LaTeX editor with smart BibTeX management, TikZ visualization, and AI-assisted writing.

Discover how Octree compares to Overleaf — from AI-assisted LaTeX writing and TikZ/BibTeX automation to open-source flexibility and offline editing for researchers.