Skip to main content
If you want to create a matrix in LaTeX, the usual answer is to load amsmath and use pmatrix or bmatrix. Use pmatrix for parentheses, bmatrix for square brackets, vmatrix for determinants, and smallmatrix for inline math. When you need vertical separators for an augmented matrix or custom alignment, switch to array. This guide starts with the common matrix environments, then covers augmented matrices, block matrices, spacing, and alignment.
Quick answer:Use pmatrix for ( ), bmatrix for [ ], and vmatrix for determinants.Package required: Most matrix environments need \usepackage{amsmath}. Some advanced layouts also use array or mathtools.Related topics: Mathematical equations | Subscripts & superscripts | Brackets & parentheses | LaTeX symbolsLast updated: April 2026 | Reading time: 15 min | Difficulty: Beginner to Intermediate

What You’ll Learn

  • ✅ All LaTeX matrix environments (pmatrix, bmatrix, vmatrix, Bmatrix, Vmatrix)
  • ✅ Creating arrays with custom delimiters and column alignment
  • ✅ Block matrices and augmented matrix notation
  • ✅ Matrix operations, determinants, and transpose notation
  • ✅ Small inline matrices with smallmatrix environment
  • ✅ Advanced matrix formatting, spacing, and decorations
  • ✅ Troubleshooting common LaTeX matrix issues

Frequently Asked Questions

The main difference between pmatrix and bmatrix is the type of delimiters (brackets) they use:
  • pmatrix uses parentheses ( ) - most common for general matrices in mathematics
  • bmatrix uses square brackets [ ] - preferred for numerical data and engineering
Both require the amsmath package and work identically in terms of syntax:When to use each:
  • Use pmatrix for: linear transformations, general matrices, mathematical proofs
  • Use bmatrix for: numerical data, matrices in data science, engineering applications
  • Use vmatrix for: determinants (single vertical bars)
To create an augmented matrix with vertical lines separating columns, use the array environment with the pipe symbol | in the column specification:How it works:
  • {cc|c} means: column-center, column-center, vertical line, column-center
  • Use c for centered, l for left-aligned, r for right-aligned
  • The pipe | symbol creates the vertical separator line
  • Use \left[ and \right] to automatically scale brackets
The amsmath package (American Mathematical Society) provides essential matrix environments that aren’t available in plain LaTeX:
  • pmatrix (parentheses)
  • bmatrix (square brackets)
  • vmatrix (determinant notation)
  • Vmatrix (norm notation)
  • Bmatrix (curly braces)
  • smallmatrix (inline matrices)
How to load it:Without amsmath, you’d be limited to the basic array environment with manual delimiter management.
Number alignment problems occur when columns contain different-width numbers. Use these solutions:Solution 1: Right-aligned arraySolution 2: Use siunitx for decimal alignmentSolution 3: Use phantom spacing
For matrices within text paragraphs, use the smallmatrix environment:Regular pmatrix environments are too large for inline use and disrupt line spacing. The smallmatrix environment uses smaller fonts and tighter spacing.
Column specifiers define how each column is formatted:Example with vertical line:
Use the vmatrix environment for determinant notation with vertical bar delimiters:For 3×3 matrices:
Use \renewcommand{\arraystretch}{factor} to control matrix element spacing:Recommended values:
  • 1.0 - Default compact spacing
  • 1.2 - Standard matrices
  • 1.5 - Matrices with fractions or subscripts
  • 2.0 - Matrices with tall expressions
Use curly braces to limit the effect to just one matrix.

Basic Matrix Environments

LaTeX provides six standard matrix environments through the amsmath package, each with different delimiters:

Matrix Environment Overview

Matrix Environment Summary Table

Creating Your First Matrix

Simple 2×2 Matrix

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

Using Dots in Matrices

LaTeX provides three types of dots for indicating patterns in matrices:

Special Matrix Types

Identity and Zero Matrices

Triangular Matrices

Arrays - The Foundation of Matrices

The array environment provides the most flexibility for creating custom matrix-like structures:

Basic Array Usage

Array Column Specifiers

Block Matrices

Block matrices are used to partition large matrices into smaller submatrices:

Basic Block Matrices

Augmented Matrices

Augmented matrices are commonly used for solving systems of linear equations:

Matrix Operations

Basic Operations Notation

Determinants and Traces

Small Inline Matrices

For matrices within text, use the smallmatrix environment:

Advanced Techniques

Matrices with Labels

Matrix Decorations

Common Pitfalls and Solutions

Problem: Parentheses/brackets don’t scale with matrix size.Solution: Use \left and \right with array:Or use the pre-defined environments like pmatrix which handle this automatically.
Problem: Numbers don’t align properly in columns.Solution:
  1. Use array with explicit alignment: {rrr} for right-aligned
  2. For decimals, use the siunitx package with S columns
  3. Add spacing with \phantom{} for consistent widths
Problem: Large matrices extend beyond margins.Solutions:
  1. Use \small or \footnotesize before the matrix
  2. Use bmatrix*}[r] from mathtools for right-aligned entries
  3. Split into block matrices
  4. Consider using array environment with custom column spacing
Problem: Elements too cramped or too spread out.Solution: Adjust array stretch:

Best Practices

Matrix typesetting guidelines:
  1. Choose appropriate delimiters: Use vmatrix for determinants, pmatrix for general matrices
  2. Consistency: Use the same notation style throughout your document
  3. Size considerations: Use smallmatrix for inline matrices
  4. Alignment: Right-align numbers in numeric matrices
  5. Spacing: Add \, or \: for better readability when needed
  6. Block structure: Use block matrices to show structure
  7. Labels: Add row/column labels when they aid understanding

Package Recommendations

Essential Packages

Loading Order

Quick Reference Card

Matrix Environments Summary

Common Patterns

Practice in LaTeX Cloud Studio

Try matrices in the editor

Test pmatrix, bmatrix, and augmented matrices in a live document and inspect the rendered output directly.

Tables vs matrices

Jump here when you need structured data layout rather than mathematical notation.

Subscripts & Superscripts

Matrix element notation with indices

Mathematical Equations

Multi-line equations and alignment

LaTeX Symbols Reference

Greek letters and math operators

Advanced Mathematics

Complex mathematical notation

Further Reading & References

For authoritative documentation on LaTeX matrix environments and mathematical typesetting:
  • amsmath Package Documentation - The standard package providing all matrix environments (pmatrix, bmatrix, vmatrix)
  • mathtools Package - Extended features for matrices including starred versions and additional options
  • The LaTeX Companion (3rd Edition) - Comprehensive reference for mathematical typesetting best practices
  • Linear Algebra Done Right by Sheldon Axler - Standard textbook demonstrating matrix notation conventions
Next steps:
LaTeX Cloud Studio tip: Use our real-time preview feature to instantly see how your matrices render. No compilation wait time needed!