Math fonts in LaTeX (mathbb, mathcal, mathfrak, mathrm)
A math alphabet changes the style of letters in a formula: \mathbb{R} gives blackboard bold, \mathcal{L} calligraphic, \mathfrak{g} Fraktur and \mathrm{d} upright letters. \mathbb and \mathfrak need the amssymb package.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{amssymb}
\usepackage{mathrsfs}Blackboard bold for number sets
\mathbb{...} comes from amssymb and has uppercase letters only.
\[
\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}
\]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.
Calligraphic and script letters
\mathcal{...} is part of LaTeX and has uppercase letters only. \mathscr{...} from the mathrsfs package is a second, more ornate script alphabet, also uppercase only.
\[
\mathcal{L}(V, W)
\qquad
\mathcal{O}(n \log n)
\qquad
\mathscr{F}
\]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.
Fraktur
\mathfrak{...} comes from amssymb and has uppercase and lowercase letters.
\[
\mathfrak{g}
\qquad
\mathfrak{sl}_2
\qquad
\mathfrak{A}
\]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.
Upright, sans serif, typewriter and italic
\mathrm, \mathsf, \mathtt and \mathit are part of LaTeX. \mathit{diff} sets a variable name of several letters as one word with the letter spacing of text; without it LaTeX spaces the letters as a product of d, i, f and f.
\[
\mathrm{d}x
\qquad
\mathsf{T}
\qquad
\mathtt{x}
\qquad
\mathit{diff}
\]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.
Pitfalls
\mathbbwithoutamssymbstops with Undefined control sequence.\mathbband\mathcalprint unrelated symbols for lowercase letters and digits. A blackboard bold 1 is\mathds{1}from thedsfontpackage or\mathbbm{1}frombbm.- Math alphabets ignore spaces. For words in a formula use
\text{...}, see Text in math mode in LaTeX.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
amssymb - Package
unicode-math - How-to Bold math symbols in LaTeX
- How-to Text in math mode in LaTeX
- Error Undefined control sequence