Skip to content
site-logo
  • Home
  • Blog
  • JavaScript
  • Machine Learning
  • Numerical Techniques C++
  • Data Structures C++
  • Typing Guide
site-logo
Home / Tech Updates / How to Write Matrix in LaTeX?

How to Write Matrix in LaTeX?

ByLonz Updated onAugust 10, 2021
Tech Updates
latex code for matrix
Ad
Table of contents
  1. How to Write Matrix in LaTeX
    1. Latex Code For Matrix
    2. Brackets in Latex
      1. Latex pmatrix, bmatrix, vmatrix, Vmatrix
  2. How to write an m * n matrix in LaTeX
  3. How to Write 3 x 3 Matrix in LaTeX
    1. 3 x 3 Matrix with parentheses:
      1. 3 x 3 Matrix with brackets:
      2. 3 x 3 Matrix with no bracket
      3. 3 x 3 Matrix with Vertical Bar | Determinant
      4. 3 x 3 Latex matrix with curly brackets
      5. Latex matrix with double vertical bar brackets
  4. How to Write 2 x 2 Matrix in LaTeX
    1. pmatrix
    2. bmatrix
    3. vmatrix
    4. Vmatrix

How to Write Matrix in LaTeX

The important feature of latex is to display mathematical and scientific formulas and equations in their original style and to make math equations look beautiful on our web or other important documents.

There are a few ways to enter math mode, however, the most common is

Ad
    $..inline math..$
or
    $$ ..math in new line.. $$

where the text within the dollar signs is in the math mode environment.

And the other method is by using the command,

\begin{equation} and \end{equation}

There are equivalent ways of entering math mode for each of these methods as in the below example, however, the latter is now strongly preferred.

$$....$$ is equivalent to \[ ....\]

Latex Code For Matrix

A matrix can be described as a rectangular array of numbers, symbols, or expressions that are arranged in rows and columns. A matrix in LaTeX can be generated with the help of a math environment for typesetting matrices.

For generating matrix in LaTeX we have to use the package amsmath by giving the command:

\usepackage{amsmath}

	\documentclass{article}
	\usepackage{amsmath}
	\begin{document}
	$$
	\begin{bmatrix} 
	a & b & c \\
	c & d & d\\
	e & f & g \\
	\end{bmatrix}
	\quad
	$$
	\end{document}
Code language: JavaScript (javascript)

Output of the above code

$$ \begin{bmatrix} a & b & c \\ c & d & d\\ e & f & g \\ \end{bmatrix} \quad $$

Brackets in Latex

Latex pmatrix, bmatrix, vmatrix, Vmatrix

There can be various types of brackets to use in a matrix. Some of them are discussed below:

Ad
  • p for parentheses
  • b for square brackets
  • v for verts
  • B for curly braces
  • V for double vertical bars.

Code Explanation:

  • \begin{matrix} This command creates a matrix without brackets.
  • \begin{pmatrix} This command creates a matrix with parenthesis.
  • \begin{bmatrix} This command creates a matrix with square brackets.
  • \begin{Bmatrix} This command creates a matrix with curly brackets.
  • \begin{vmatrix} This command creates a matrix with a rectangular line boundary.
  • \begin{Vmatrix} This command creates a matrix with double vertical bar brackets.


How to write an m * n matrix in LaTeX

Latex Code for m * n Matrix

$$\begin{equation} A_{m,n} = \begin{pmatrix} 
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ 
   \vdots & \vdots & \vdots & \vdots\\ 
a_{m,1} & a_{m,2} & \cdots & a_{m,n} 
\end{pmatrix} 
\end{equation}
$$

Output of m * n matrix:

$$\begin{equation} A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ \vdots & \vdots & \vdots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix} \end{equation}$$

How to Write 3 x 3 Matrix in LaTeX

3 x 3 Matrix with parentheses:

\begin{equation} A = 
\begin{pmatrix} 
 1 & 2 & 3 \\
 4 & 5 & 6 \\
 7 & 8 & 9 
\end{pmatrix}
 \end{equation}

\begin{equation} A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} \end{equation}

3 x 3 Matrix with brackets:

\begin{equation} B = 
\begin{bmatrix} 
 a & b & c \\
 d & e & f \\
 g & h & i 
\end{bmatrix} 
\end{equation}

Output:

\begin{equation} B = \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix} \end{equation}

3 x 3 Matrix with no bracket

\begin{equation}
\begin{matrix}
a_{11} & a_{12} & a_{13}\\
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33} 
\end{matrix}
\end{equation}

Output:

\begin{equation}
\begin{matrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{matrix}
\end{equation}

3 x 3 Matrix with Vertical Bar | Determinant

\begin{equation}
\begin{vmatrix}
a_{11} & a_{12} & a_{13}\\
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33}
\end{vmatrix}
\end{equation}

Output:

\begin{equation}
\begin{vmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33} \
\end{vmatrix}
\end{equation}

3 x 3 Latex matrix with curly brackets

\begin{equation}
\begin{Bmatrix}
a_{11} & a_{12} & a_{13}\\
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33}
\end{Bmatrix}
\end{equation}

Output:

\begin{equation}
\begin{Bmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{Bmatrix}
\end{equation}

Latex matrix with double vertical bar brackets

\begin{equation}
\begin{Vmatrix}
a_{11} & a_{12} & a_{13}\\
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33} 
\end{Vmatrix}
\end{equation}

Output:

\begin{equation}
\begin{Vmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{Vmatrix}
\end{equation}

How to Write 2 x 2 Matrix in LaTeX


Here are some examples of 2 x 2 matrix with pmatrix, bmatrix, vmatrix, Vmatrix.

\begin{matrix}
a & b\\
c & d
\end{matrix}

Output:

\begin{matrix}
a & b\\
c & d
\end{matrix}

pmatrix

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

Output:

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

bmatrix

\begin{bmatrix}
a & b\\
c & d
\end{bmatrix}

Output:

\begin{bmatrix}
a & b\\
c & d
\end{bmatrix}

vmatrix

\begin{vmatrix}
a & b\\
c & d
\end{vmatrix}

Output:

\begin{vmatrix}
a & b\\
c & d
\end{vmatrix}

Vmatrix

\begin{Vmatrix}
a & b\\
c & d
\end{Vmatrix}

Output:

\begin{Vmatrix}
a & b\\
c & d
\end{Vmatrix}

Post navigation

Previous Previous
Typing Test Paragraph Sample | Download Best Paragraph for Typing Test Practice
NextContinue
Tree Data Structure | Tree Terminologies | Tree Traversal
Search

Ad

Categories

  • C++ Programing
  • C++ Programs
  • Computer Graphics
  • Data Structures C++
  • JavaScript
  • Machine Learning
  • Numerical Techniques C++
  • Processor
  • Tech Updates
  • Typing Guide
  • Un Categorised

Recent Posts

  • NetSuite Cloud ERP Features
  • Is i7 Better Than i5
  • setTimeout vs setInterval JavaScript Methods
  • String Formatting In JavaScript

Ad


  • Home
  • Blog
  • Privacy Policy
  • Disclaimer
  • Sitemap

Copyright © 2023 Tech In Detail

  • Home
  • Blog
  • JavaScript
  • Machine Learning
  • Numerical Techniques C++
  • Data Structures C++
  • Typing Guide
Search