# MathJax basic tutorial and quick reference

+ 30 like - 0 dislike
30260 views
1. 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 will 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).

2. For inline formulas, enclose the formula in $...$. For displayed formulas, use $$...$$. These render differently: $\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$ (inline) or $$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}\tag{displayed}$$

3. For Greek letters, use \alpha, \beta, …, \omega: $\alpha, \beta, … \omega$. For uppercase, use \Gamma, \Delta, …, \Omega: $\Gamma, \Delta, …, \Omega$.

4. For superscripts and subscripts, use ^ and _. For example, x_i^2: $x_i^2$.

5. 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}$.

6. Parentheses Ordinary symbols ()[] make parentheses and brackets $(2+3)[4+4]$. Use \{ and \} for curly braces $\{\}$.

These do not scale with the formula in between, so if you write (\frac12) the parentheses will be too small: $(\frac12)$. Using \left(\right) will make the sizes adjust automatically to the formula they enclose: \left(\frac12\right) is $\left(\frac12\right)$.

\left and\right apply to all the following sorts of parentheses: ( and ) $(x)$, [ and ] $[x]$, \{ and \} $\lbrace x \rbrace$, | $|x|$, \langle and \rangle $\langle x \rangle$, \lceil and \rceil $\lceil x \rceil$, and \lfloor and \rfloor $\lfloor x \rfloor$. There are also invisible parentheses, denoted by .: \left.\frac12\right\rbrace is $\left.\frac12\right\rbrace$.

7. 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$.

8. 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}$.

9. 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}$.
10. 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.

11. 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}$$

12. 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 \subsetneq \supset \in \notin \emptyset \varnothing $\cup\, \cap\, \setminus\, \subset\, \subseteq \,\subsetneq \,\supset\, \in\, \notin\, \emptyset\, \varnothing$
• {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 \vDash $\land\, \lor\, \lnot\, \forall\, \exists\, \top\, \bot\, \vdash\, \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$.

Detexify lets you draw a symbol on a web page and then lists the $\TeX$ symbols that seem to resemble it. These are not guaranteed to work in MathJax but are a good place to start. To check that a command is supported, note that MathJax.org maintains a list of currently supported $\LaTeX$ commands, and one can also check Dr. Carol JVF Burns's page of $\TeX$ Commands Available in MathJax.

13. 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$.

To set plain text, use \text{…}: $\{x\in s\mid x\text{ is extra large}\}$. You can nest $…$ inside of \text{…}.

14. 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.

15. Special characters used for MathJax interpreting can be escaped using the \ character: \$$\$$, \{ \{, \_ \_, etc. (Tutorial ends here.) It is important that this note be reasonably short and not suffer from too much bloat. To include more topics, please create short addenda and post them as answers instead of inserting them into this post. This post imported from StackExchange Mathematics Meta at 2014-04-16 16:07 (UCT), posted by SE-user MJD asked Aug 28, 2012 retagged Apr 19, 2014 Most voted comments show all comments Some capital Greek letters are the same as the Roman equivalents, so they are not separated in \LaTeX. For a capital beta, one must use something like \mathrm{B}: \mathrm{B} This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user robjohn Most of the references to TeX or LaTeX in this and the answers ought to be to MathJaX (the exception that I can see being the output of Detexify). I know this is a bit pedantic, but would it be alright to correct this? This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user Andrew Stacey @AndrewStacey Thanks for pointing this out. Let's by all means be as correct as possible, particularly when there's no extra cost. This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user MJD @MJD Okay, I've had a go (also the answer about arrays). I wonder also whether or not it is worth a sentence at the end pointing out that whilst MathJaX does its best to emulate TeX, it isn't TeX and so while knowing how something is done in TeX gives you a starting point, it isn't a guarantee that the same thing works in MathJaX. (As a case in point, questions about MathJaX are generally off-topic over on TeX-SX.) This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user Andrew Stacey @AndrewStacey I wouldn't. They are close enough that it seems to me to be a needless refinement. I might even argue that MathJax is \TeX, although an alternative implementation. We're willing to accept that other programming languages (JavaScript, for example) that have slightly incompatible implementations are nevertheless the same language; why not in this case as well? This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user MJD Most recent comments show all comments I usually use \times (\times). This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user MJD What is the question? This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user Peter Mortensen ## 20 Answers + 7 like - 0 dislike # Big braces Use \left and \right to make braces - (round), [square] and {curly} - scale up to be the size of their arguments. Thus $$
f\left(
\left[
\frac{
1+\left\{x,y\right\}
}{
\left(
\frac{x}{y}+\frac{y}{x}
\right)
\left(u+1\right)
}+a
\right]^{3/2}
\right)
$$ renders as$$ f\left(\left[ \frac{1+\left\{x,y\right\}}{\left(\frac{x}{y}+\frac{y}{x}\right)\left(u+1\right)}+a\right]^{3/2}\right). $$Note that curly braces need to be escaped as \{ \}. If you start a big brace with \left and then need to match that to a \right brace that's on a different line, use the forms \right. and \left. to make "shadow" braces. Thus, $$
\begin{aligned}
a=&\left(1+2+3+  \cdots \right. \\
& \cdots+ \left. \infty-2+\infty-1+\infty\right)
\end{aligned}
$$ renders as$$ \begin{aligned} a=&\left(1+2+3+ \cdots \right. \\ & \cdots+ \left. \infty-2+\infty-1+\infty\right). \end{aligned} $$There is also a \middle construct which is useful when one has a mid-expression brace which must also scale up: $$
\left\langle
q
\middle\|
\frac{\frac{x}{y}}{\frac{u}{v}}
\middle|
p
\right\rangle
\dot{y}
$$ As in \dot{y} \equiv \frac{dy}{dt}  This post imported from StackExchange Mathematics Meta at 2014-04-16 16:09 (UCT), posted by SE-user BobStein-VisiBone answered Jul 8, 2013 by (0 points) I've added this (and the related \ddot) to section 14 of the main post. This post imported from StackExchange Mathematics Meta at 2014-04-16 16:09 (UCT), posted by SE-user MJD + 3 like - 0 dislike how do you get bigger parenthesis than just$$\Bigg(\Bigg)$$For example:$$\Bigg(\frac {1}{4\Big(\frac{\sqrt2}{2}+ i\frac{\sqrt2}{2}\Big)^3} + \frac {1}{\Big(\frac{\sqrt2}{2}+ i\frac{\sqrt2}{2}\Big)^3}\Bigg)$$The parenthesis on the end need to be bigger, what is the code for that? This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user Vishwa Iyer answered Apr 18, 2013 by (0 points) Use \left( and \right). For example, > \left(\frac {1}{4\Big(\frac{\sqrt2}{2}+ i\frac{\sqrt2}{2}\Big)^3} + \frac {1}{\Big(\frac{\sqrt2}{2}+ i\frac{\sqrt2}{2}\Big)^3}\right) is$$\left(\frac {1}{4\Big(\frac{\sqrt2}{2}+ i\frac{\sqrt2}{2}\Big)^3} + \frac {1}{\Big(\frac{\sqrt2}{2}+ i\frac{\sqrt2}{2}\Big)^3}\right)$$This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user MJD thanks man, you're very helpful This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user Vishwa Iyer @VishwaIyer: Or use \Bigg( render as:$$\Bigg ( $$This post imported from StackExchange Mathematics Meta at 2014-04-16 16:08 (UCT), posted by SE-user Mr.ØØ7 + 3 like - 0 dislike$$\alpha^{7} = \frac {3}{5} + 7 \cdot \left(\frac {3}{5}\right)^{5/7} + 21 \cdot \left(\frac {3}{5}\right)^{3/7} + 35 \cdot \left(\frac {3}{5}\right)^{1/7} + 35 \cdot \left(\frac {3}{5}\right)^{-1/7} + 21 \cdot \left(\frac {3}{5}\right)^{-3/7} + 7 \cdot \left(\frac {3}{5}\right)^{-5/7} + \left(\frac {3}{5}\right)^{-1}$$How would I change the following above so it looks neater? Latex code: $$\alpha^{7} = \frac {3}{5} + 7 \cdot \left(\frac {3}{5}\right)^{5/7} + 21 \cdot \left(\frac {3}{5}\right)^{3/7} + 35 \cdot \left(\frac {3}{5}\right)^{1/7} + 35 \cdot \left(\frac {3}{5}\right)^{-1/7} + 21 \cdot \left(\frac {3}{5}\right)^{-3/7} + 7 \cdot \left(\frac {3}{5}\right)^{-5/7} + \left(\frac {3}{5}\right)^{-1}$$ This post imported from StackExchange Mathematics Meta at 2014-04-16 16:09 (UCT), posted by SE-user Vishwa Iyer answered Jul 11, 2013 by (0 points)$$\alpha^{7} = \frac {3}{5} + 7\left(\!\frac {3}{5}\!\right)^{\!5/7}\! + 21\left(\!\frac {3}{5}\!\right)^{\!3/7}\! + 35\left(\!\frac {3}{5}\!\right)^{\!1/7}\! + 35\left(\!\frac {3}{5}\!\right)^{\!-1/7}\! + 21\left(\!\frac {3}{5}\!\right)^{\!-3/7}\! + 7\left(\!\frac {3}{5}\!\right)^{\!-5/7}\! + \left(\!\frac {3}{5}\!\right)^{\!-1}

This post imported from StackExchange Mathematics Meta at 2014-04-16 16:09 (UCT), posted by SE-user John Bentin
+ 3 like - 0 dislike

Another way to display the arrows for right and left implication instead of using

$\Rightarrow$ and $\Leftarrow$

which produces $\Rightarrow$ and $\Leftarrow$ respectively, you can use

$\implies$ for $\implies$ and $\impliedby$ for $\impliedby$

The latter of which produces longer arrows which may be more desirable to some.

This post imported from StackExchange Mathematics Meta at 2014-04-16 16:09 (UCT), posted by SE-user jnh
answered Apr 5, 2014 by (0 points)

 Please use answers only to (at least partly) answer questions. To comment, discuss, or ask for clarification, leave a comment instead. To mask links under text, please type your text, highlight it, and click the "link" button. You can then enter your link URL. Please consult the FAQ for as to how to format your post. This is the answer box; if you want to write a comment instead, please use the 'add comment' button. Live preview (may slow down editor)   Preview Your name to display (optional): Email me at this address if my answer is selected or commented on: Privacy: Your email address will only be used for sending these notifications. Anti-spam verification: If you are a human please identify the position of the character covered by the symbol $\varnothing$ in the following word:p$\hbar$ysicsOve$\varnothing$flowThen drag the red bullet below over the corresponding character of our banner. When you drop it there, the bullet changes to green (on slow internet connections after a few seconds). To avoid this verification in future, please log in or register.