Bold math symbols in LaTeX (mathbf, bm)
\mathbf{x} sets Latin letters and digits bold and upright. For bold italic letters, Greek letters and other symbols use \bm{...} from the bm package.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{amsmath}
\usepackage{bm}Bold upright letters
\mathbf is part of LaTeX. It changes Latin letters, digits and uppercase Greek letters. Lowercase Greek letters and symbols such as + or \nabla stay unchanged.
\[
\mathbf{A}\mathbf{x} = \mathbf{b}
\qquad
\mathbf{0}
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Bold italic letters, Greek letters and symbols
\bm{...} makes its argument bold and keeps the shape: italic letters stay italic, and Greek letters and operators get their bold form.
\[
\bm{\alpha} + \bm{x} = \bm{\nabla} f
\qquad
\bm{A}\bm{x} = \bm{b}
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Without the bm package
amsmath has \boldsymbol{...}, which also keeps the shape of the symbol. When bm is loaded, \boldsymbol becomes another name for \bm.
\[
\boldsymbol{\beta} = (\beta_1, \dots, \beta_n)
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
A whole formula in bold
\textbf does not change a formula inside its argument. \boldmath switches every following formula to bold; it has to stand outside math mode, and braces limit its range.
\textbf{Result: {\boldmath $x = \alpha + 1$}}Pitfalls
\mathbfin normal text stops with \mathbf allowed only in math mode. Bold text is\textbf{...}.\boldmathinside a formula has no effect; the log shows the warning "Command \boldmath invalid in math mode".- The old form
{\bf x}cannot be combined with other font attributes, and the KOMA-Script classes reject it with "undefined old font command". Use\mathbfin formulas and\textbfin text.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
bm - Package
amsmath - How-to Vectors in LaTeX
- How-to Math fonts in LaTeX
- Error \mathbf allowed only in math mode