styleLatex
All free tools

LaTeX Matrix Generator

Set the rows and columns, type each entry and pick the brackets, and this LaTeX matrix generator writes the code as you go. Entries accept LaTeX math such as \alpha or x^2, and the result pastes straight into Overleaf or any document that loads amsmath.

Cells accept LaTeX math, such as \alpha or x^2. Empty cells become 0.

LaTeX

\begin{pmatrix}
  1 & 0 & 0 \\
  0 & 1 & 0 \\
  0 & 0 & 1
\end{pmatrix}

Got a whole page of equations? Turn a photo, scan or PDF into LaTeX that compiles.

Convert a file

What Is a LaTeX Matrix Generator?

LaTeX Matrix Code Without Typing Every Ampersand

Writing a matrix by hand means counting ampersands and double backslashes on every row. A LaTeX matrix code generator handles that layout, so you only think about the entries.

Matrix in LaTeX: pmatrix, bmatrix and vmatrix

Every matrix in LaTeX sits inside an amsmath environment. pmatrix draws round brackets, bmatrix square ones and vmatrix straight bars for determinants; the Brackets menu switches between them.

A LaTeX Matrix with Brackets, Bars or None

Bmatrix adds curly braces, Vmatrix double bars, and plain matrix leaves the entries unbracketed, handy inside your own \left and \right delimiters.

Why Use Our LaTeX Matrix Generator?

A Free LaTeX Matrix Generator Online

This LaTeX matrix generator runs in your browser with no account or download, and the code refreshes on every keystroke, up to 12 rows by 12 columns.

See all free LaTeX tools

A Matrix Generator for LaTeX That Accepts Math

Entries are written as LaTeX, so fractions, Greek letters, subscripts and \cdots all work, and the LaTeX matrix generator keeps them exactly as typed. Empty cells become 0.

Tables Too, Not Only Matrices

This LaTeX matrix generator also works as a LaTeX matrix creator for symbolic layouts. For rows of data with a header row, the table converter fits better.

Turn spreadsheet cells into a LaTeX table

How to Use It in 3 Steps

Step 1: Set the LaTeX Matrix Size

Choose rows and columns from 1 to 12. Entries that still fit are kept, so you can grow or shrink a LaTeX matrix without retyping it.

Step 2: Fill Entries, Dots or an Identity Matrix

The grid opens as a 3 by 3 identity matrix in LaTeX. Overwrite the entries, or type \cdots, \vdots or \ddots into a cell for LaTeX matrix dots.

Step 3: Pick Brackets and Copy the Code

Choose bmatrix in LaTeX for square brackets, or another style, then copy or download. An augmented matrix in LaTeX, or a LaTeX matrix with vertical line, needs array; see the FAQ.

Convert the rest of your notes to LaTeX

Official references: amsmath (CTAN)

LaTeX Matrix Generator: styleLatex card with the tool's purpose and a code sample | LaTeX Matrix Generator

LaTeX Matrix Generator FAQ

How to write matrix in LaTeX?
Load amsmath, then in math mode write \begin{pmatrix} a & b \\ c & d \end{pmatrix}. An ampersand separates columns and \\ ends each row.
How to make augmented matrix in LaTeX?
Use array with a bar in the column spec, as in \left[\begin{array}{cc|c} … \end{array}\right]. Generate the entries above first.
How to write matrix in LaTeX equation?
Put the environment inside equation or \[ \], for example A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}.
How to write identity matrix in LaTeX?
Put 1 on the diagonal and leave other cells empty, since they become 0. For a general size, use \ddots or simply write I_n.
How to write matrix multiplication in LaTeX?
Place two environments side by side for AB, or put \cdot between them to show the product explicitly.
How to write column matrix in LaTeX?
Set columns to 1 in the LaTeX matrix generator to get a column vector such as \begin{bmatrix} x_1 \\ x_2 \end{bmatrix}. One row gives a row vector.
How to write a 2x2 matrix in LaTeX?
Set 2 rows and 2 columns in the LaTeX matrix generator to get \begin{pmatrix} a & b \\ c & d \end{pmatrix}, then change the brackets.
How to write matrix in LaTeX Overleaf?
Most Overleaf templates already load amsmath; if yours does not, add \usepackage{amsmath} and paste the code inside math mode.
How to draw vertical dots in LaTeX matrix?
Use \vdots for vertical, \cdots for horizontal and \ddots for diagonal dots, typed straight into a cell.
How to type matrix within line on LaTeX?
Use smallmatrix inside \( \), wrapped as \bigl(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\bigr) so it fits the line height.
How to draw a line in a matrix LaTeX?
Switch to array: a bar in the column spec draws a vertical line, and \hline between rows draws a horizontal one.
How to write diagonal matrix in LaTeX?
Fill only the diagonal and leave other cells empty, or write \operatorname{diag}(a, b, c) for a compact form.
How to write matrix determinant in LaTeX?
Pick vmatrix in the LaTeX matrix generator for straight bars, or write \det(A) when you only need the symbol.
How to write the inverse of a matrix LaTeX?
Write A^{-1} for the inverse. The transpose is A^{\top}, or A^T in a plainer style.
How to add brackets to matrix in LaTeX?
pmatrix gives round brackets, bmatrix square, Bmatrix curly, vmatrix single bars and Vmatrix double bars. Plain matrix has none.
How to put greek letters in matrix in LaTeX?
Type \alpha, \beta or subscripts such as a_{ij} into a cell. Entries are LaTeX math and reach the code unchanged.
How to make a matrix bigger in LaTeX?
Raise \arraystretch, wrap it in \large, or use \resizebox for very wide ones. This LaTeX matrix generator goes up to 12 by 12.
What is bmatrix in LaTeX?
An amsmath environment that draws square brackets around the entries. Load amsmath and use it in math mode.
How to add vertical spacing in matrix LaTeX?
Add \renewcommand{\arraystretch}{1.5} before the matrix, or end one row with \\[4pt] to space only that row.
How to label a matrix in LaTeX?
Row and column labels need the blkarray package and its blockarray environment, or the older \bordermatrix command.
How to number a matrix in LaTeX?
Put it in an equation environment to number it, and add \label{eq:A} so you can refer to it later.
How to write block matrix in LaTeX?
Use symbols as entries, as in \begin{pmatrix} A & B \\ C & D \end{pmatrix}, or array with lines between blocks.
How to make a 3x3 matrix in LaTeX?
The LaTeX matrix generator opens at 3 by 3, filled as an identity matrix. Overwrite the nine entries and copy.
How to write jacobian matrix in LaTeX?
Fill each cell with \frac{\partial f_i}{\partial x_j}, using real indices. A Hessian works the same way with second derivatives.
How to make a payoff matrix in LaTeX?
For number pairs such as (3, 1) a matrix works. When you need player and strategy labels, use a tabular instead.
How to type matrix symbol in LaTeX?
Matrices are usually bold capitals: \mathbf{A}, or \boldsymbol{A} from amsmath for bold Greek letters.
What is the LaTeX code for a matrix?
\begin{bmatrix} … \end{bmatrix} and its siblings, with an ampersand between columns and \\ between rows. The LaTeX matrix generator writes it for you.
Can the LaTeX matrix generator calculate matrices?
No. It only writes code and does not multiply, invert or row-reduce. Work out the values first, then type them in.
Can I generate a LaTeX array instead of a matrix?
It writes matrix environments. Switch to array when you need column alignment or lines, and add \left and \right brackets yourself.
What does a LaTeX matrix example look like?
A 2D rotation: \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix}. It pastes into any amsmath document.
Which LaTeX package do I need for pmatrix and bmatrix?
amsmath. Add \usepackage{amsmath} to the preamble; it provides pmatrix, bmatrix, Bmatrix, vmatrix and Vmatrix.
Does the generated matrix work in Markdown, Obsidian or MathJax?
Yes. MathJax and KaTeX support these environments, so the code works between $$ signs in Obsidian and most Markdown editors.

Have a whole page of notes, a scan or a PDF? Convert it to LaTeX that compiles.

Convert a file