How to Typeset Vectors and Matrices Beautifully in LaTeX
Vectors and matrices form the backbone of linear algebra, physics, and engineering. LaTeX offers multiple conventions for vector notation — arrows, bold, and hats — and flexible matrix environments for every bracket style. Bibby AI provides instant rendering of matrix environments so you can see your matrices take shape as you type, unlike Overleaf where you must recompile to check alignment.
Vector Notation Styles
Choose from arrow notation (\vec), bold notation (\mathbf), or hat notation (\hat) depending on your field's convention:
\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\begin{document}
% Arrow notation (common in physics)
$\vec{v} = \vec{a} + \vec{b}$
% Bold notation (common in engineering/CS)
$\mathbf{v} = \mathbf{a} + \mathbf{b}$
% Bold with Greek letters
$\bm{\alpha} = \bm{\beta} + \bm{\gamma}$
% Unit vector with hat
$\hat{e}_1, \hat{e}_2, \hat{e}_3$
\end{document}Matrix Environments
Use different matrix environments for different bracket styles — pmatrix for parentheses, bmatrix for square brackets, vmatrix for determinants, and Bmatrix for curly braces:
% Parentheses matrix
\[
\mathbf{A} = \begin{pmatrix}
a_{11} & a_{12} \\
a_{21} & a_{22}
\end{pmatrix}
\]
% Square bracket matrix
\[
\mathbf{B} = \begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix}
\]
% Determinant
\[
\det(\mathbf{A}) = \begin{vmatrix}
a & b \\
c & d
\end{vmatrix} = ad - bc
\]Column Vectors and Dot Products
Write column vectors and express operations like dot products and matrix-vector multiplication:
% Column vector
\[
\mathbf{x} = \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix}
\]
% Dot product
\[
\mathbf{a} \cdot \mathbf{b} = \begin{pmatrix} a_1 \\ a_2 \end{pmatrix}^{\!\top}
\begin{pmatrix} b_1 \\ b_2 \end{pmatrix}
= a_1 b_1 + a_2 b_2
\]💡 Tips
- •Use \bm{} from the bm package for bold Greek vectors — \mathbf only works on Latin letters.
- •For large matrices with ellipses, use \cdots (horizontal), \vdots (vertical), and \ddots (diagonal).
- •The smallmatrix environment lets you write inline matrices: $\left(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\right)$.
- •Bibby AI highlights matching matrix delimiters in real time, making it easy to spot missing rows or columns.
Try This in Bibby AI
Write LaTeX faster with AI auto-complete and instant compilation.
Start Writing Free