Typevia
Mathematical Typesetting

Understanding Mathematical Fonts in LaTeX

In LaTeX, mathematical notation is more than just text; it is a visual language where the style of a font conveys specific meaning. For example, a standard $x$ usually represents a variable, while a bold $\mathbf{x}$ often represents a vector, and a blackboard-bold $\mathbb{R}$ represents the set of real numbers.

By default, LaTeX uses a specific mathematical font (usually Computer Modern) and automatically italicizes variables. However, to produce professional-quality documents, you need to know how to switch between different font styles to follow mathematical conventions.


1. The Standard Math Font Styles

When you enter math mode (using $ ... $ or \[ ... \]), LaTeX assumes every letter is a variable and renders it in italics. However, there are times when you need upright text, bold text, or other variations.

The following commands are built into LaTeX or provided by the standard amsmath package:

CommandDescriptionExample Output
\mathnormal{...}Default math italic$abc$
\mathrm{...}Roman (Upright)$\mathrm{abc}$
\mathbf{...}Bold$\mathbf{abc}$
\mathsf{...}Sans Serif$\mathsf{abc}$
\mathtt{...}Typewriter$\mathtt{abc}$
\mathit{...}Math Italic (spacing differs from text)$\mathit{abc}$

Code Example: Comparing Font Styles

\documentclass{article}
\usepackage{amsmath}

\begin{document}

Standard variable: $x + y = z$

Using different styles in a formula:
\[
\mathbf{v} = \mathrm{constant} \cdot \mathit{variable}
\]

Typesetting a matrix name:
\[ \mathbf{A} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \]

\end{document}

Note: Use \mathrm for physical units (like $\mathrm{kg}$, $\mathrm{m}$) and for multi-letter descriptive subscripts, such as $x_{\mathrm{max}}$.


2. Specialized Mathematical Alphabets

Advanced mathematics often requires distinct alphabets to categorize different types of objects. To use these, you should include the amssymb and amsfonts packages in your preamble.

Calligraphic (\mathcal)

Commonly used for sets of sets, sheaves, or transforms (like the Laplace transform $\mathcal{L}$). Note: This usually only works for uppercase letters.

Blackboard Bold (\mathbb)

Essential for representing number systems like Integers ($\mathbb{Z}$), Reals ($\mathbb{R}$), and Complex numbers ($\mathbb{C}$).

Fraktur (\mathfrak)

Used in abstract algebra (for ideals) or Lie algebra.

Code Example: Using Special Alphabets

\documentclass{article}
\usepackage{amsmath, amssymb}

\begin{document}

The set of all real numbers is denoted by $\mathbb{R}$.

Let $\mathcal{P}$ be the power set of $\mathbb{S}$.

The Lie algebra is represented by $\mathfrak{g}$.

\[ \mathbb{C} \subset \mathbb{H} \]

\end{document}

3. Bold Symbols and Greek Letters

A common frustration for beginners is that \mathbf does not work on Greek letters. For example, $\mathbf{\alpha}$ will not produce a bold alpha in standard LaTeX.

To solve this, the recommended approach is to use the bm (Bold Math) package. This package provides the \bm command, which can make almost any mathematical symbol bold while preserving its shape (italic or upright).

Code Example: Bold Greek Letters

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm} % Load this after other math packages

\begin{document}

Standard: $\alpha + \beta = \gamma$

Bold with bm: $\bm{\alpha} + \bm{\beta} = \bm{\gamma}$

Bold summation: $\bm{\sum_{i=1}^n x_i}$

\end{document}

Tip: Always load the bm package last in your preamble list to ensure it can correctly detect and apply bold versions of all available fonts.


4. Text Inside Math Mode

Sometimes you need to insert a full word or phrase inside a mathematical expression. While \mathrm works for single words, it does not handle spaces correctly. For actual words or sentences, use the \text{...} command from the amsmath package.

Code Example: Text vs. Math Roman

\documentclass{article}
\usepackage{amsmath}

\begin{document}

Wrong (using mathrm):
\[ f(x) = \mathrm{if } x > 0 \]

Right (using text):
\[ f(x) = \text{if } x > 0 \]

\end{document}

In the "wrong" example, LaTeX ignores the space after "if" because math mode treats spaces as non-existent. The \text command temporarily "escapes" math mode, allowing for natural word spacing.


5. Best Practices and Common Pitfalls

Use Semantic Commands

Instead of manually typing \mathbb{R} every time, define a custom command in your preamble. This makes your code cleaner and easier to change later.

\newcommand{\R}{\mathbb{R}}
\newcommand{\vect}[1]{\mathbf{#1}}

% Usage:
$\R$ and $\vect{v}$

Distinguish Functions from Variables

Mathematical functions like "sin", "log", and "lim" should always be upright. LaTeX provides built-in commands for these (e.g., \sin, \log). If you need a custom function, use \DeclareMathOperator.

Common Pitfalls to Avoid:

  1. Using $text$ for words: Writing $total = cost + tax$ looks terrible because LaTeX treats "total" as $t \times o \times t \times a \times l$. Use $\text{total} = \dots$ instead.
  2. Overusing Bold: In mathematics, bold is usually reserved for vectors and matrices. Use it sparingly to maintain visual hierarchy.
  3. Forgetting amssymb: If \mathbb or \mathfrak are giving you errors, double-check that you have \usepackage{amssymb} in your preamble.

6. Summary Table

To wrap up, here is a quick reference for the most commonly used math font commands:

GoalCommandPackage Required
Set of Numbers\mathbb{R}amssymb
Vectors/Matrices\mathbf{v} or \bm{x}bm (for \bm)
Descriptive words\text{word}amsmath
Script/Calligraphy\mathcal{A}None (standard)
Upright constants\mathrm{'{'}e{'}'}None (standard)

By mastering these font commands, you can ensure your mathematical documents are not only accurate but also conform to the high typographic standards expected in scientific publishing.