# Short reference for LaTeX/MathJax commands

Some users are not familiar with the LaTeX notations, which is perfectly fine, but it would be better if we could have an FAQ/help page that explains the basic commands, in a similar way to the markdown edit-help.

We should have a short summary of basic LaTeX commands (and link to a more extensive list of commands, if needed).

– Raphael Mod
May 22, 2012 at 17:31
• Since this seems to be meant to serve as a canonical reference for using MathJax on this site, I've edited this question a bit to try and clean it up (e.g. so it's presented as a reference/guide, rather than a feature request). The question or answer(s) may still need further updates/improvement, but that's up to the community.
– V2Blast StaffMod
Aug 23, 2022 at 22:17

You can enclose LaTeX math code in $...$ for inline math, and $$...$$ resp. for indented equations.

MathJax supports essentially the commands native to $$\LaTeX$$ as well as those defined by amsmath and amssymb (with some exceptions in both directions). For a complete list, see the MathJax reference.

I have found these references to be useful:

Aside from that, my personal hints (and what I edit most):

• \mathbb{N} for the natural numbers; similar for other such sets.
• \mathcal{L} for calligraphic letters, e.g. languages
• If you prefer left-aligned non-inline formulae, use $\qquad \displaystyle ...$ (in an own paragraph) instead of $$...$$.
• \operatorname{name} for long operator names (non-italic letters and spacing).
• \mathrm{name} or \mathsf{name} for dedicated names, such as P and NP (non-italic letters).
• Parentheses around big stuff (e.g. fractions) are usually undersized. Use \left( ... \right) (similar for [ resp. ] and { resp. }) to have them adapt their size accordingly.
• Use \to, \iff and \implies instead of \rightarrow, \Leftrightarrow and \Rightarrow where appropriate (i.e. semantically fitting).
• You can define your own macros. They survive across multiple math environments, so take care not to destroy other posts.
• Use \text{...} when using English in formulae.
• Use \dots instead of ....

Be aware that the spoiler tag (!>) does not support multiple lines -- even inside math formulae! You'll have to write all of your formula in one line when using spoiler tags.

### Examples

Let $$a,b \in \mathbb{B}$$ and $$a \leq b$$. Then, $$a + b \geq b$$.

$$\sum\limits_{i=0}^n i = \frac{n(n+1)}{2}$$

$$\qquad\displaystyle \sum_{i=1}^n i = \frac{n(n+1)}{2}$$

$$\lim\limits_{n \to \infty} \frac{1}{n} = 0$$

$$\max_n f(x) = - \min_n (-f(n))$$

$$L = \{ \langle M, w \rangle \mid M \text{ is a TM and } M(w) = 1 \}$$

Quicksort runs in $$O(n\log n)$$ time on average, but in $$O(n^2)$$ time in the worst case.

\begin{align*} a_0 &= 1 \\ a_{n+1} &= 2 \cdot a_n + 3 \end{align*}

$$\chi_S(s) = \begin{cases} 1 &, s \in S \\ 0 &, s \notin S \end{cases}$$

$$\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix}$$

\begin{align*} S &\to (S)S \mid A \mid \varepsilon \\ A &\to aA \mid a \end{align*}

• There is a more elaborate post on meta.mathematics.SE.
– Raphael Mod
Apr 22, 2014 at 15:49
• Good and elegant help! Feb 8, 2015 at 20:36

You may use this online graphical tool to create Latex formulas:

http://www.codecogs.com/latex/eqneditor.php