Quick MathJax Tutorial

This tutorial is adapted from one I found on StackExchange.  To see how any of the formulas were made in any question or answer, including this one, use the “edit” link to view the complete source. To quickly see the source of a single expression, right-click on it and choose “Show Math As > TeX Commands”.

(Note that in some browsers, such as Firefox, the MathJaX right-click menu that contains this command may be obscured by the browser’s own right-click menu. Click somewhere outside the main browser canvas — such as in the address bar — to dismiss the browser menu and reveal the MathJaX one behind it).

  1. For inline formulas, enclose the formula in \(…\). For displayed formulas, use \[…\] . These render differently: \( \sum_{i=0}^n i = \frac{n^2+n}{2} \) (inline) or \[ \sum_{i=0}^n i = \frac{n^2+n}{2}\tag{displayed}\]
  2. For Greek letters, use \alpha, \beta, …, \omega: \( \alpha, \beta, … \omega \). For uppercase, use \Gamma, \Delta, …, \Omega: \( \Gamma, \Delta, …, \Omega \).
  3. For superscripts and subscripts, use ^ and _. For example, x_i^2: \( x_i^2 \).
  4. By default, superscripts, subscripts, and other operations apply only to the next “group”. A “group” is either a single symbol, or any formula surrounded by curly braces {…}. If you do 10^10, you will get a surprise: \( 10^10 \). But 10^{10} gives what you probably wanted: \( 10^{10} \). Use curly braces to delimit a formula to which a superscript or subscript applies: x^5^6 is an error; {x^y}^z is \( {x^y}^z \), and x^{y^z} is \( x^{y^z} \). Observe the difference between x_i^2 \( x_i^2 \) and x_{i^2} \( x_{i^2} \).
  5. Parentheses Ordinary symbols ()[] make parentheses and brackets \( (2+3)[4+4] \). These do not scale with the formula in between, so if you write (\frac12) the parentheses will be too small: \( (\frac12) \).
  6. Using \left(…\right) will make the sizes adjust automatically to the formula they enclose: \left(\frac12\right) is \( \left(\frac12\right) \).
  7. \left and\right apply to all the following sorts of parentheses: | \( |x| \), \langle and \rangle \( \langle x \rangle \), \{ and \} \( \lbrace x \rbrace \), \lceil and \rceil \( \lceil x \rceil \), and \lfloor and \rfloor \( \lfloor x \rfloor \).
  8. Sums and integrals \sum and \int; the subscript is the lower limit and the superscript is the upper limit, so for example \sum_1^n \( \sum_1^n \). Don’t forget {…} if the limits are more than a single symbol. For example, \sum_{i=0}^\infty i^2 is \( \sum_{i=0}^\infty i^2 \). Similarly, \prod \( \prod \), \int \( \int \), \bigcup \( \bigcup \), \bigcap \( \bigcap \), \iint \( \iint \).
  9. Fractions There are two ways to make these. \frac ab applies to the next two groups, and produces \( \frac ab \); for more complicated numerators and denominators use {…}: \frac{a+1}{b+1} is \( \frac{a+1}{b+1} \). If the numerator and denominator are complicated, you may prefer \over, which splits up the group that it is in: {a+1\over b+1} is \( {a+1\over b+1} \).
  10. Fonts
    • Use \mathbb or \Bbb for “blackboard bold”: \( \mathbb{CHNQRZ} \).
    • Use \mathbf for boldface: \( \mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \) \( \mathbf{abcdefghijklmnopqrstuvwxyz} \).
    • Use \mathtt for “typewriter” font: \( \mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \) \( \mathtt{abcdefghijklmnopqrstuvwxyz} \).
    • Use \mathrm for roman font: \( \mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \) \( \mathrm{abcdefghijklmnopqrstuvwxyz} \).
    • Use \mathcal for “calligraphic” letters: \( \mathcal{ ABCDEFGHIJKLMNOPQRSTUVWXYZ} \)
    • Use \mathscr for script letters: \( \mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \)
    • Use \mathfrak for “Fraktur” (old German style) letters: \( \mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \mathfrak{abcdefghijklmnopqrstuvwxyz} \).
  11. Radical signs Use sqrt, which adjusts to the size of its argument: \sqrt{x^3} \( \sqrt{x^3} \); \sqrt[3]{\frac xy} \( \sqrt[3]{\frac xy} \). For complicated expressions, consider using {…}^{1/2} instead.
  12. Some special functions such as “lim”, “sin”, “max”, “ln”, and so on are normally set in roman font instead of italic font. Use \lim, \sin, etc. to make these: \sin x \( \sin x \), not sin x \( sin x \). Use subscripts to attach a notation to \lim: \lim_{x\to 0} \( \)\lim_{x\to 0}\( \)
  13. There are a very large number of special symbols and notations, too many to list here; see this shorter listing, or this exhaustive listing. Some of the most common include:
    • \lt \gt \le \ge \neq \( \lt\, \gt\, \le\, \ge\, \neq \). You can use \not to put a slash through almost anything: \not\lt \( \not\lt \) but it often looks bad.
    • \times \div \pm \mp \( \times\, \div\, \pm\, \mp \). \cdot is a centered dot: \( x\cdot y \)
    • \cup \cap \setminus \subset \subseteq  \supset \in \notin \emptyset  \( \cup\, \cap\, \setminus\, \subset\, \subseteq  \,\supset\, \in\, \notin\, \emptyset \)
    • {n+1 \choose 2k} or \binom{n+1}{2k} \( {n+1 \choose 2k} \)
    • \to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto \( \to\, \rightarrow\, \leftarrow\, \Rightarrow\, \Leftarrow\, \mapsto \)
    • \land \lor \lnot \forall \exists \top \bot \vdash  \( \land\, \lor\, \lnot\, \forall\, \exists\, \top\, \bot\, \vdash \)
    • \star \ast \oplus \circ \bullet \( \star\, \ast\, \oplus\, \circ\, \bullet \)
    • \approx \sim \cong \equiv \prec \( \approx\, \sim \, \cong\, \equiv\, \prec \).
    • \infty \aleph_0 \( \infty\, \aleph_0 \) \nabla \partial \( \nabla\, \partial \) \Im \Re \( \Im\, \Re \)
    • For modular equivalence, use \pmod like this: a\equiv b\pmod n \( a\equiv b\pmod n \).
    • \ldots is the dots in \( a_1, a_2, \ldots ,a_n \) \cdots is the dots in \( a_1+a_2+\cdots+a_n \)
    • Some Greek letters have variant forms: \epsilon \varepsilon \( \epsilon\, \varepsilon \), \phi \varphi \( \phi\, \varphi \), and others. Script lowercase l is \ell \( \ell \).
  14. Spaces MathJaX usually decides for itself how to space formulas, using a complex set of rules. Putting extra literal spaces into formulas will not change the amount of space MathJaX puts in: a?b and a????b are both \( a b \). To add more space, use \, for a thin space \( a\,b \); \; for a wider space \( a\;b \). \quad and \qquad are large spaces: \( a\quad b \), \( a\qquad b \).
  15. To set plain text, use \text{…}: \( \{x\in s\mid x\text{ is extra large}\} \). You can nest \( … \) inside of \text{…}.
  16. Accents and diacritical marks Use \hat for a single symbol \( \hat x \), \widehat for a larger formula \( \widehat{xy} \). If you make it too wide, it will look silly. Similarly, there are \bar \( \bar x \) and \overline \( \overline{xyz} \), and \vec \( \vec x \) and \overrightarrow \( \overrightarrow{xy} \). For dots, as in \( \frac d{dx}x\dot x = \dot x^2 + x\ddot x \), use \dot and \ddot.

Leave a Reply