LaTeX

How to Create a Matrix in LaTeX

Build matrices with rows, columns, delimiters, alignment, and common environments.

Updated 2026-07-27 · Reviewed 2026-07-26 by Chevee Math Tools

Load the matrix tools

The standard matrix environments are provided by amsmath in a full LaTeX document:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix}
\]
\end{document}

Use & between columns and \\ between rows.

Choose an environment

  • matrix has no surrounding delimiter.
  • pmatrix uses parentheses.
  • bmatrix uses square brackets.
  • Bmatrix uses braces.
  • vmatrix uses single vertical bars, commonly for determinants.
  • Vmatrix uses double vertical bars.

Choose the delimiter for mathematical meaning, not decoration.

Validate rows and columns

Every row should have the same number of entries unless the environment intentionally includes special formatting. For a three-column matrix, each row needs two & separators:

\begin{pmatrix}
a & b & c \\
d & e & f
\end{pmatrix}

A misplaced separator can shift entries or produce an alignment error.

Write augmented matrices

For a vertical separator inside an array, use an array environment with an explicit column specification:

\left[\begin{array}{cc|c}
1 & 2 & 3 \\
4 & 5 & 6
\end{array}\right]

Check that the delimiter scales around the complete array.

Distinguish matrices and determinants

Square brackets normally denote a matrix, while vertical bars may denote a determinant. Do not replace determinant notation with an absolute-value-looking expression unless the context is unambiguous.

Troubleshoot errors

“Extra alignment tab” usually means a row contains too many & characters. A missing row break can merge rows. If the environment is undefined, load amsmath or confirm that the web renderer supports it. If delimiters are too small around an array, use matching scalable delimiters.

Common mistakes

  • Using commas instead of column separators.
  • Giving different row lengths accidentally.
  • Forgetting the package in a full LaTeX document.
  • Using vmatrix when ordinary matrix brackets are intended.
  • Typing a large matrix inline where it harms readability.

Verify the rendered matrix

Count rows and columns in both the source and output. Check each entry’s sign and subscript, then verify the intended operation with a small calculation such as a determinant, trace, or matrix-vector product.

Editorial test case

The verification matrix used two rows and three columns, then intentionally removed one & separator and one row break. Those changes reproduced alignment failures and confirmed that entry count, not visual spacing in the source, determines the rendered grid. The same source was also compared with pmatrix, bmatrix, and vmatrix to confirm that only the delimiters changed.

Build a minimal test before the full expression

For create matrix in latex, start with the smallest source that contains the required command or environment. Render it with the same engine used by the final document, then add bounds, labels, alignment, and surrounding text one change at a time. This makes a missing brace, unsupported package, or environment error easy to isolate.

% Minimal test: keep only the structure being checked
\[ x^2 + y^2 = z^2 \]

Verify structure rather than appearance

  1. Confirm that every multi-token argument is grouped with braces.
  2. Check that operators, limits, and text labels use semantic commands rather than manual spacing.
  3. Compile with the intended packages and document class.
  4. Copy from the exported result and confirm that the editable source remains available.

Portability boundary

A command that works in a full TeX distribution may not work in KaTeX, MathJax, Word, or a Markdown renderer. Keep a fallback expression and record any required package. Convert to MathML only after the LaTeX structure is correct; conversion cannot recover semantics that were omitted from the source.

Put this guide into practice

Continue with a browser tool

Use the related reference or tool while the notation and workflow are still fresh.

How this guide was checked

Review method: Intent alignment review, notation/source verification, worked-example check, cross-format rendering review, and duplicate-content comparison for How to Create a Matrix in LaTeX

Verified against: Official standards, primary documentation, and the page-specific sources listed below

What changed: Removed repeated sitewide boilerplate and added content-type-specific decision, verification, and applicability guidance for this exact task.

Page purpose: create matrix in latex — Format and verify the topic in LaTeX

Automated quality check: Passed critical indexing checks.

Verification references

These primary standards and official documentation pages were used to check character identity, syntax, or platform behavior described above.

Reuse, attribution, and correction

Share this reference without losing its source

Copy a citation, permanent link, Markdown link, or self-contained embed card. Each reusable format points readers back to the maintained canonical page.

Report an issue

Search the whole reference

Symbols, formulas, guides, tools and commands

Start typing to search.

move · Enter open · Esc close