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.

N⊂Z⊂Q⊂R⊂C\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}

Open this formula in the editor

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.

L(V,W)O(nlog⁡n)F\mathcal{L}(V, W) \qquad \mathcal{O}(n \log n) \qquad \mathscr{F}

Open this formula in the editor

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.

gsl2A\mathfrak{g} \qquad \mathfrak{sl}_2 \qquad \mathfrak{A}

Open this formula in the editor

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.

dxTxdiff\mathrm{d}x \qquad \mathsf{T} \qquad \mathtt{x} \qquad \mathit{diff}

Open this formula in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages