Let’s discuss row vectors and learn how easily they can be created in LaTeX. Whether you are a student or someone interested in math, this will be helpful for you!
We often need to show data or numbers in a row format, and LaTeX provides an excellent way to do this in a neat and professional manner.
Syntax for Row Vector
In LaTeX, a row vector is created by listing elements in sequence, separated by special symbols.
Use the &
symbol to separate elements. For example, a row with four elements looks like this:
... & ... & ... & ... a_{1} & a_{2} & \cdots & a_{n}
Using the amsmath package for a row vector
The amsmath package is widely used in LaTeX for mathematical content. To create a row vector, use the bmatrix
environment, which places elements inside square brackets, a standard matrix notation.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ \begin{bmatrix}
a_{1} & a_{2} & \cdots & a_{n}
\end{bmatrix} \]
\end{document}
Output :
The &
symbol separates each element in the row
Using the mqty command from physics package
For a simpler way to write a row matrix, the physics
package offers the \mqty
command, allowing you to create a row matrix with minimal code.
\documentclass{article}
\usepackage{physics}
\begin{document}
\[ \mqty[a_{1} & a_{2} & \cdots & a_{n}] \]
\end{document}
Output :
The physics package is ideal for quick and simple code. It handles formatting automatically, so you don’t need to worry about brackets or alignment.