(Deutsch: MathJax: LaTeX Basic Tutorial und Referenz)
To see how any formula was written in any question or answer, including this one, right-click on the expression and choose "Show Math As > TeX Commands". (When you do this, the '$' will not display. Make sure you add these. See the next point. There are also other possibilities how to view the code for the formula or the whole post.)
For inline formulas, enclose the formula in
$...$. For displayed formulas, use$$...$$.
These render differently. For example, type
$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$
to show $\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$ (which is inline mode) or type
$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$
to show $$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$ (which is display mode).For Greek letters, use
\alpha,\beta, …,\omega: $\alpha, \beta, … \omega$. For uppercase, use\Gamma,\Delta, …,\Omega: $\Gamma, \Delta, …, \Omega$. Some Greek letters have variant forms:\epsilon \varepsilon$\epsilon$, $\varepsilon$,\phi \varphi$\phi$, $\varphi$, and others.For superscripts and subscripts, use
^and_. For example,x_i^2: $x_i^2$,\log_2 x: $\log_2 x$.Groups. 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 do10^10, you will get a surprise: $10^10$. But10^{10}gives what you probably wanted: $10^{10}$. Use curly braces to delimit a formula to which a superscript or subscript applies:x^5^6is an error;{x^y}^zis ${x^y}^z$, andx^{y^z}is $x^{y^z}$. Observe the difference betweenx_i^2$x_i^2$ andx_{i^2}$x_{i^2}$.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
(\frac{\sqrt x}{y^3})the parentheses will be too small: $(\frac{\sqrt x}{y^3})$. Using\left(…\right)will make the sizes adjust automatically to the formula they enclose:\left(\frac{\sqrt x}{y^3}\right)is $\left(\frac{\sqrt x}{y^3}\right)$.\leftand\rightapply to all the following sorts of parentheses:(and)$(x)$,[and]$[x]$,\{and\}$\{ x \}$,|$|x|$,\vert$\vert x \vert$,\Vert$\Vert x \Vert$,\langleand\rangle$\langle x \rangle$,\lceiland\rceil$\lceil x \rceil$, and\lfloorand\rfloor$\lfloor x \rfloor$.\middlecan be used to add additional dividers. There are also invisible parentheses, denoted by.:\left.\frac12\right\rbraceis $\left.\frac12\right\rbrace$.If manual size adjustments are required:
\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)gives $\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$.Sums and integrals
\sumand\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^2is $\sum_{i=0}^\infty i^2$. Similarly,\prod$\prod$,\int$\int$,\bigcup$\bigcup$,\bigcap$\bigcap$,\iint$\iint$,\iiint$\iiint$,\idotsint$\idotsint$.Fractions There are three ways to make these.
\frac abapplies 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}$. Using\cfrac{a}{b}command is useful for continued fractions $\cfrac{a}{b}$, more details for which are given in this sub-article.Fonts
- Use
\mathbbor\Bbbfor "blackboard bold": $\mathbb{CHNQRZ}$. - Use
\mathbffor boldface: $\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathbf{abcdefghijklmnopqrstuvwxyz}$.- For expression based characters, use
\boldsymbolinstead: $\boldsymbol{\alpha}$
- For expression based characters, use
- Use
\mathitfor italics: $\mathit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathit{abcdefghijklmnopqrstuvwxyz}$. - Use
\pmbfor boldfaced italics: $\pmb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\pmb{abcdefghijklmnopqrstuvwxyz}$. - Use
\mathttfor "typewriter" font: $\mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathtt{abcdefghijklmnopqrstuvwxyz}$. - Use
\mathrmfor roman font: $\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathrm{abcdefghijklmnopqrstuvwxyz}$. - Use
\mathsffor sans-serif font: $\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathsf{abcdefghijklmnopqrstuvwxyz}$. - Use
\mathcalfor "calligraphic" letters: $\mathcal{ ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathcal{abcdefghijklmnopqrstuvwxyz}$ - Use
\mathscrfor script letters: $\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathscr{abcdefghijklmnopqrstuvwxyz}$ - Use
\mathfrakfor "Fraktur" (old German style) letters: $\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \mathfrak{abcdefghijklmnopqrstuvwxyz}$.
Radical signs / roots 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.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$, notsin x$sin x$. Use subscripts to attach a notation to\lim:\lim_{x\to 0}$$\lim_{x\to 0}$$ Nonstandard function names can be set with\operatorname{foo}(x)$\operatorname{foo}(x)$.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 \leq \leqq \leqslant \ge \geq \geqq \geqslant \neq$\lt$, $\gt$, $\le$, $\leq$, $\leqq$, $\leqslant$, $\ge$, $\geq$, $\geqq$, $\geqslant$, $\neq$. You can use\notto put a slash through almost anything:\not\lt$\not\lt$ but it often looks bad.\times \div \pm \mp$\times$, $\div$, $\pm$, $\mp$.\cdotis 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 \simeq \cong \equiv \prec \lhd \therefore$\approx$, $\sim $, $\simeq$, $\cong$, $\equiv$, $\prec$, $\lhd$, $\therefore$\infty \aleph_0$\infty\, \aleph_0$\nabla \partial$\nabla$, $\partial$\Im \Re$\Im$, $\Re$- For modular equivalence, use
\pmodlike this:a\equiv b\pmod n$a\equiv b\pmod n$. - For the binary mod operator, use
\bmodlike this:a\bmod 17$a\bmod 17$. - Avoid using
\mod, as it produces extra space: compare the above witha\mod 17$a\mod 17$. \ldotsis the dots in $a_1, a_2, \ldots ,a_n$\cdotsis the dots in $a_1+a_2+\cdots+a_n$- 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.
- 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␣banda␣␣␣␣bare both $a b$. To add more space, use\,for a thin space $a\,b$;\;for a wider space $a\;b$.\quadand\qquadare 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{…}, for example to access spaces.
Accents and diacritical marks Use
\hatfor a single symbol $\hat x$,\widehatfor 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}$ and\overleftrightarrow$\overleftrightarrow{xy}$. For dots, as in $\frac d{dx}x\dot x = \dot x^2 + x\ddot x$, use\dotand\ddot.Special characters used for MathJax interpreting can be escaped using the
\character:\\\$$\$$,\{$\{$,\_$\_$, etc. If you want\itself, you should use\backslash(symbol) or\setminus(binary operation) for $\backslash$, because\\is for a new line.
(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.
Contents
Alphabetical list of links to To MathJax Topics, by title:
- Absolute values and norms • Additional symbolic decorations • Aligning Equations
- Alternative Ways of Writing in LaTeX • Annotations of reasoning • Arbitrary operators
- Arrays • Big braces • Colors
- Commutative diagrams • Continued fractions • Crossing things out
- Definitions by cases (piecewise functions) • Degree symbol • Display style
- Equation numbering • Fussy spacing issues • Highlighting expressions
- Left and right arrows • Limits • Linear programming
- Long division • Math Programming • Matrices
- Markov Chains • Mixing code and MathJax formatting on lines • The \newcommand function
- Numbering Equations • Overlaying Symbols • Packs of cards
- Symbols • System of equations • Tables
- Tags and references • Tensor indices • Units
- Vertical spacing


\mathrm{B}: $\mathrm{B}$ $\endgroup$ – robjohn♦ Aug 28 '12 at 2:06\operatorname: e.g.,\operatorname{Spec} Agives $\operatorname{Spec} A$. $\endgroup$ – Charles Staats Aug 28 '12 at 16:45_5C_3$_5C_3$. You could also mention\fracvs\dfrac. $\endgroup$ – axblount Aug 29 '12 at 18:09\big,\left, and\rightfor this reason, and trimming the section on spacing. $\endgroup$ – MJD Aug 30 '12 at 2:06(and)automatically resizeable. I can in LaTeX. $\endgroup$ – Andrew Stacey Sep 11 '12 at 16:04\mathrmin many places; e.g. $\mathrm{d}x$ in integrals and derivatives and for operator names that don't need the full force of\operatorname.\mathrmwas intended for roman symbols in math mode;\textwas intended for text because of the way it spaces things. See this TEX thread. Since I don't believe we can use preambles in MathJax, we can't use\DeclareMathOperator, though we can use\newcommand, but that is orthogonal to the use of\mathrmvs\textfor math symbols. $\endgroup$ – robjohn♦ Jun 10 '13 at 16:23