Typesetting mathematics

This blog post is a short introduction to how to type mathematical expressions using LaTeX commands. On the blogging platform we are using, this is achieved by MathJax. Some documentations can be found here.

If you have a mathematical expression to type, you may start by entering “$latex” (remove quotation marks), writing the corresponding LaTeX commands, and then closing with another “$” (again, no quotation marks). Note that on your regular LaTeX editor (or Overleaf), you only need to enclose mathematical expressions by a pair of dollar signs.

Example:  The less-than-or-equal relation on real numbers is given by R=\{ (x,y) \in \mathbb{R}^2 \mid x \leq y \} ($latex R=\{ (x,y) \in \mathbb{R}^2 \mid x \leq y \}$)

Most of the commands are pretty intuitive:

Most stuff: Just type them! For example, 1+2=3 ($latex 1+2=3$) and f(x) ($latex f(x)$)

Exponents: Use ^{exponent}; remember to enclose the entire exponent in a pair of curly brackets. For example, e^{-2x} (e^{-2x}, but not e^-2x, because the latter will produce e^-2x)

Subscripts: Use _{subscript}. This is very similar to exponents. For example, A_{0} (A_{0}) or a_{10} (a_{10}, but not a_10, because the latter will produce a_10)

Functions: Use \colon instead of “:” and use \to for the arrow. For example, f \colon \mathbb{R} \to \mathbb{R} (f \colon \mathbb{R} \to \mathbb{R})

Sets: If you want to type curly brackets, use \{ and \}. Use \mid instead of “|” in the set builder notation. For example, S = \{ n^2 \mid n \in \mathbb{Z} \} (S = \{ n^2 \mid n \in \mathbb{Z})

Element-containment and subsets: Here are a few commonly-used notations when it comes to sets: x \in X (x \in X), y \notin X (x \notin X), and A \subseteq B (A \subseteq B).

Equivalence relations: Here are a few commonly-used symbols for equivalence relations: \sim (\sim), \nsim (\nsim), \simeq (\simeq), \cong (\cong), and \asymp (\asymp)

Congruence: Use \equiv for the congruence symbol; use \pmod{n} for the integer n in a congruence relation. For example, 29\equiv 5 \pmod{12} (29\equiv 5 \pmod{12})

Special symbols: If you want to type a symbol but don’t know its LaTeX command, consult Detexify.

Common mistakes:

  • Forgetting to include “latex” after the opening dollar sign: $f(x)$ [This is unique to Mathjax on CampusPress]
  • Forgetting to close a brace or dollar sign: $\sqrt{x^2 + e^x + \ln(2x)$
  • Using (parentheses) instead of {curly brackets} for arguments to commands: e^(-x^2) vs e^{-x^2}
  • Exponents without braces surrounding them: e^-x^2 vs e^{-x^2}
  • Misspelling a command

Shuyi Weng

Leave a Reply

Your email address will not be published. Required fields are marked *