# MathJax basic tutorial and quick reference

1. To see how any formulas was written in any question or answer, including this one, right-click on the expression it and choose "Show Math As > TeX Commands".

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. - 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} – robjohn Aug 28 '12 at 2:06 for a beginner I find this site very helpful – Monkey D. Luffy Aug 28 '12 at 4:35 Thanks for putting this all together! – Ｊ. Ｍ. Aug 28 '12 at 11:03 @Henning When I ranked features in my mind to decide whether to include them, \varphi and \varepsilon were very close to the threshhold for inclusion. Martin Sleziak has since added them, which I agree is a good idea. – MJD Aug 28 '12 at 16:33 A quick addition to point 11: If you want to use a \sin-like symbol that is not already defined, the command is \operatorname: e.g., \operatorname{Spec} A gives \operatorname{Spec} A. – Charles Staats Aug 28 '12 at 16:45 @CharlesStaats I considered putting that in, but I wasn't sure it met the threshold for frequently-usedness. Suppose someone wanted it, but didn't know about it. Then in the "worst" case their operator would appear in italics, which did not seem to me to be a serious problem, or one that would impede the person from completing their post. – MJD Aug 28 '12 at 16:48 It might be useful to mention hanging subscripts for things like _5C_3 _5C_3. You could also mention \frac vs \dfrac. – axblount Aug 29 '12 at 18:09 My basic idea is that if a beginner can express a formula clearly, then someone else can come in and clean up the typesetting afterwards. I am considering getting rid of the section about \big, \left, and \right for this reason, and trimming the section on spacing. – MJD Aug 30 '12 at 2:06 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? – Loop Space Sep 11 '12 at 14:13 @MJD Except that this is meant as a tutorial for those who aren't familiar with the distinction (and there really is a distinction: "slightly incompatible implementations" doesn't really fit the bill here). One thing tutorials often include is a "Where to find out more" section. This doesn't. Someone who doesn't know the distinction might be tempted to search for help on TeX or LaTeX instead and wonder why it doesn't work. – Loop Space Sep 11 '12 at 14:40 @axblount But that's precisely the wrong way around to think about it! The likelihood is that someone will look at this tutorial to figure out how to write something on the Maths-SX site: i.e., to use MathJaX. If they can't find help here, where do they go? If they have the idea that MathJaX is "just a javascript implementation of TeX" then they might think to look for help with TeX, but that is quite possibly not going to be helpful. – Loop Space Sep 11 '12 at 15:08 @axblount For a start, you've changed the goalposts: "LaTeX math expressions". LaTeX is so much more than just a way of typesetting maths! Second, I don't really know but it wouldn't take me long to cook one up. I don't use MathJaX so I haven't explored it. But I know, for example, that it can't handle catcode changes. Which means that I can't make ( and ) automatically resizeable. I can in LaTeX. – Loop Space Sep 11 '12 at 16:04 I wish I saw this post when I first joined. This post should be a main link on the home page. There should be a button under each box: NEW TO LATEX, CLICK HERE FOR EXAMPLES. This is extremely useful, concise. – user1527227 May 31 '13 at 18:09 @MJD: I use \mathrm in many places; e.g. \mathrm{d}x in integrals and derivatives and for operator names that don't need the full force of \operatorname. \mathrm was intended for roman symbols in math mode; \text was 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 \mathrm vs \text for math symbols. – robjohn Jun 10 '13 at 16:23 ## 20 Answers # Matrices 1. Use $$\begin{matrix}…\end{matrix}$$ In between the \begin and \end, put the matrix elements. End each matrix row with \\, and separate matrix elements with &. For example, $$
\begin{matrix}
1 & x & x^2 \\
1 & y & y^2 \\
1 & z & z^2 \\
\end{matrix}
$$ produces:$$ \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix} $$MathJax will adjust the sizes of the rows and columns so that everything fits. 2. To add brackets, either use \left…\right as in section 6 of the tutorial, or replace matrix with pmatrix \begin{pmatrix}1&2\\3&4\\ \end{pmatrix}, bmatrix \begin{bmatrix}1&2\\3&4\\ \end{bmatrix}, Bmatrix \begin{Bmatrix}1&2\\3&4\\ \end{Bmatrix}, vmatrix \begin{vmatrix}1&2\\3&4\\ \end{vmatrix}, Vmatrix \begin{Vmatrix}1&2\\3&4\\ \end{Vmatrix}. 3. Use \cdots \cdots \ddots \ddots vdots \vdots when you want to omit some of the entries:$$\begin{pmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^n \\ 1 & a_2 & a_2^2 & \cdots & a_2^n \\ \vdots & \vdots& \vdots & \ddots & \vdots \\ 1 & a_m & a_m^2 & \cdots & a_m^n \end{pmatrix}$$4. For "augmented" matrices, put parentheses or brackets around a suitably-formatted table; see arrays above for details. Here is an example:$$ \left[\begin{array}{cc|c} 1&2&3\\ 4&5&6 \end{array}\right] $$is produced by: $$ \left[
\begin{array}{cc|c}
1&2&3\\
4&5&6
\end{array}
\right]  The cc|c is the crucial part here; it says that there are three centered columns with a vertical bar between the second and third. 5. For small inline matrices use \bigl(\begin{smallmatrix} ... \end{smallmatrix}\bigr), e.g. \bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr) is produced by:  \bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)  - What about augmented matrices? – Michael Albanese Aug 25 '13 at 19:38 Added instructions for that. – MJD Aug 25 '13 at 22:34 Thanks, that's excellent. – Michael Albanese Aug 25 '13 at 22:40 This says "End each matrix row with \\". But there is no reason to end the LAST row of the matrix that way. The double backslash means: now go on to the next row. But there isn't any next row after the last one. – Michael Hardy Aug 28 at 5:15 # Aligned equations Often people want a series of equations where the equals signs are aligned. To get this, use \begin{align}…\end{align}. Each line should end with \\, and should contain an ampersand at the point to align at, typically immediately before the equals sign. For example,\begin{align} \sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\ & = \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \\ & = \sqrt{\frac{73^2}{12^2}}\sqrt{\frac{73^2-1}{73^2}} \\ & = \frac{73}{12}\sqrt{1 - \frac{1}{73^2}} \\ & \approx \frac{73}{12}\left(1 - \frac{1}{2\cdot73^2}\right) \end{align}$$is produced by $$\begin{align}
\sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\
& = \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \\
& = \sqrt{\frac{73^2}{12^2}}\sqrt{\frac{73^2-1}{73^2}} \\
& = \frac{73}{12}\sqrt{1 - \frac{1}{73^2}} \\
& \approx \frac{73}{12}\left(1 - \frac{1}{2\cdot73^2}\right)
\end{align} - The AMS's Short Math Guide recommends the align environment over eqnarray in LaTeX. In MathJax the spacing seems to be the same , but align requires one less ampersand per line. – Rahul Aug 28 '12 at 4:41 Thanks. I was not sure whether to discuss that. A detailed argument against eqnarray is in this article. – MJD Aug 28 '12 at 4:51 Would you mind if I changed your example to use align then? – Rahul Aug 28 '12 at 5:34 @Rahul: Please go ahead and change anything that seems good to change. This is all CW. – MJD Aug 28 '12 at 5:44 Also, if you think you have a better example, please use it; I used the first one I found. – MJD Aug 28 '12 at 5:49 ## Definitions by cases Use \begin{cases}…\end{cases}. End each case with a \\, and use & before parts that should be aligned. For example, you get this:f(n) = \begin{cases} n/2, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases}$$by writing this:  f(n) = \begin{cases} n/2, & \text{if n is even} \\ 3n+1, & \text{if n is odd} \end{cases}  The brace can be moved to the right:$$ \left. \begin{array}{l} \text{if $n$ is even:}&n/2\\ \text{if $n$ is odd:}&3n+1 \end{array} \right\} =f(n) $$by writing this: \left. \begin{array}{l} \text{if n is even:}&n/2\\ \text{if n is odd:}&3n+1 \end{array} \right\} =f(n)  To get a larger vertical space between cases we can use \\[2ex] instead of \\. For example, you get this:$$f(n) = \begin{cases} \frac{n}{2}, & \text{if $n$ is even} \\[2ex] 3n+1, & \text{if $n$ is odd} \end{cases}$$by writing this: f(n) = \begin{cases} \frac{n}{2}, & \text{if n is even} \\[2ex] 3n+1, & \text{if n is odd} \end{cases}  (An ‘ex’ is a length equal to the height of the letter x; 2ex here means the space should be two exes high.) - How to put only a \} on the right ? – Mahdi Khosravi Aug 21 '13 at 13:11 @MJD Do we have to use the additional instruction \displaystyle when the formulas displayed are more complex ? – jibe Jul 1 at 14:43 @jibs \displaystyle is enabled automatically in displays, for example between $$…. You should not ever have to use it. – MJD Jul 1 at 14:50 @jibe In general, the separate cases in this notation should be in text style unless they are very very complex (and then, the { notation is just wrong anyways). – tohecz Aug 25 at 9:53 ## Arrays It is often easier to read tables formatted in MathJax rather than plain text or a fixed width font. Arrays and tables are created with the array environment. Just after \begin{array} the format of each column should be listed, use c for a center aligned column, r for right aligned, l for left aligned and a | for a vertical line. Just as with matrices, cells are separated with & and rows are broken using \\. A horizontal line spanning the array can be placed before the current line with \hline. For example,\begin{array}{c|lcr} n & \text{Left} & \text{Center} & \text{Right} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \end{array} $$$$
\begin{array}{c|lcr}
n & \text{Left} & \text{Center} & \text{Right} \\
\hline
1 & 0.24 & 1 & 125 \\
2 & -1 & 189 & -8 \\
3 & -20 & 2000 & 1+10i
\end{array}
$$ Arrays can be nested to make an array of tables. For example,$$ % outer vertical array of arrays \begin{array}{c} % inner horizontal array of arrays \begin{array}{cc} % inner array of minimum values \begin{array}{c|cccc} \text{min} & 0 & 1 & 2 & 3\\ \hline 0 & 0 & 0 & 0 & 0\\ 1 & 0 & 1 & 1 & 1\\ 2 & 0 & 1 & 2 & 2\\ 3 & 0 & 1 & 2 & 3 \end{array} & % inner array of maximum values \begin{array}{c|cccc} \text{max}&0&1&2&3\\ \hline 0 & 0 & 1 & 2 & 3\\ 1 & 1 & 1 & 2 & 3\\ 2 & 2 & 2 & 2 & 3\\ 3 & 3 & 3 & 3 & 3 \end{array} \end{array} \\ % inner array of delta values \begin{array}{c|cccc} \Delta&0&1&2&3\\ \hline 0 & 0 & 1 & 2 & 3\\ 1 & 1 & 0 & 1 & 2\\ 2 & 2 & 1 & 0 & 1\\ 3 & 3 & 2 & 1 & 0 \end{array} \end{array} As the source for the preceding array is long, please right-click on one of the tables and choose \mathsf{Show\ Math\ As\ }\blacktriangleright\mathsf{\ TeX\ Commands}. - You'll have to wrap the contents of each cell in \text if you don't want all italics, weird-looking spacing, an' odd apostrophes. – Rahul Aug 29 '12 at 21:30 @RahulNarain: True. I used words just for illustration, but I guess the example was slightly misleading. If you'd like to modify it please go ahead. – axblount Aug 29 '12 at 22:00 Thanks! I like your numeric example better, since the widths of the entries are different enough that the alignment differences are visually clear. – MJD Aug 30 '12 at 1:37 @robjohn how do you use | while typing , i don't find it in my keyboard...... – Mr.ØØ7 Mar 28 '13 at 12:05 @exploringnet: on my keyboard, it is the shifted backslash. It may be in different places (or absent) depending on your keyboard. On my mobile device (iPhone), it is in the shifted numerics, to the right of the backslash. In mathmode, \vert gives \vert and \mid gives \mid, but neither works in the column spec for an array. If you cannot type it on your keyboard, you can alwaays copy and paste it from another document. – robjohn Mar 28 '13 at 17:39 It should perhaps be mentioned, that in nested arrays there seems to be no option to synchronize column-widths and/or row-heights over the top-level. I didn't find a solution such that if two arrays are stacked vertically one could make their column-widths matching/fit. – Gottfried Helms Aug 26 '13 at 9:16 This could also be convenient for some people, althought it destroys the joy of writing tables in \LaTeX by hand! – nullgeppetto Jun 3 at 14:18 ## Symbols In general, you have to search in long tables about a specific symbol you're looking for, things like \Psi, \delta, \zeta, \ge, \subseteq ... And it turns out that this operation can be frustrating and time consuming, which can cause the buddy to abandon writing the complete \LaTeX sentence in his answer, or in some cases, the complete answer itself. That's why the tool that I will present you in this post was conceived. Basically, it is a \LaTeX handwritten symbol recognition. Example in image: Here is the website: Detexify² No more frustration. - Amazing site!!! – Sush Oct 16 '13 at 3:30 Wow. Thanks! This really helped – Siyanda May 5 at 20:59 ## Fussy spacing issues These are issues that won't affect the correctness of formulas, but might make them look significantly better or worse. Beginners should feel free to ignore this advice; someone else will correct it for them, or more likely nobody will care. Don't use \frac in exponents or limits of integrals; it looks bad and can be confusing, which is why it is rarely done in professional mathematical typesetting. Write the fraction horizontally, with a slash:\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ e^{i\frac{\pi}2} \quad e^{\frac{i\pi}2}& e^{i\pi/2} \\ \int_{-\frac\pi2}^\frac\pi2 \sin x\,dx & \int_{-\pi/2}^{\pi/2}\sin x\,dx \\ \end{array}$$The | symbol has the wrong spacing when it is used as a divider, for example in set comprehensions. Use \mid instead:$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \{x|x^2\in\Bbb Z\} & \{x\mid x^2\in\Bbb Z\} \\ \end{array}$$For double and triple integrals, don't use \int\int or \int\int\int. Instead use the special forms \iint and \iiint:$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \int\int_S f(x)\,dy\,dx & \iint_S f(x)\,dy\,dx \\ \int\int\int_V f(x)\,dz\,dy\,dx & \iiint_V f(x)\,dz\,dy\,dx \end{array}$$Use \, to insert a thin space before differentials; without this \TeX will mash them together:$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \iiint_V f(x)dz dy dx & \iiint_V f(x)\,dz\,dy\,dx \end{array}$$- I think the first adjusted fraction looks better than the original, but I don't like the second. In any case, this minor spacing imbalance is too peripheral to belong in a basic MathJax tutorial IMO. Too likely to scare people away rather than make them feel helped. – Henning Makholm Aug 31 '12 at 21:05 @Henning Do you mean that the fraction example is too unimportant even to appear in an addendum on fussy spacing, or that the fussy spacing article is too unimportant to appear as an addendum to the tutorial? – MJD Aug 31 '12 at 23:57 I was talking specifically about the fraction example. Mostly I'm concerned that somebody will come away thinking, Eeek! Do I have to worry about THAT to use the site? But it's also arguable that the disclaimer at the top of the answer ought to take care of that. – Henning Makholm Sep 1 '12 at 21:13 @MJD I like the less space, but what if we want to list the bounds for multiple integrals? Like if we have say 3 integrals and we have 3 separate bounds for each how would we list each one? Or do we have to do \int_bound1^bound2\int_bound3^bound4\int_bound5^bound6?? – TheHopefulActuary Nov 19 '12 at 19:45 @Kyle I think that's exactly what you do in that case. – MJD Nov 19 '12 at 20:09 Worth nothing you can use \middle with | to get it to work with \left and \right, like \left\{x\middle | \frac{x^2}{2} \in \mathbb{z}\right\}: \left\{x\middle | \frac{x^2}{2} \in \mathbb{z}\right\} – asmeurer Jun 9 '13 at 22:49 Thanks very much! I wanted to do that, but didn't know how. – MJD Jun 10 '13 at 15:47 ## System of equations • Use \begin{array}…\end{array} and \left\{…\right.. For example, you get this:$$ \left\{ \begin{array}{c} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{array} \right. $$by writing this: $$
\left\{
\begin{array}{c}
a_1x+b_1y+c_1z=d_1 \\
a_2x+b_2y+c_2z=d_2 \\
a_3x+b_3y+c_3z=d_3
\end{array}
\right.
$$ • Alternatively we can use \begin{cases}…\end{cases}. The same system$$ \begin{cases} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{cases} $$is produced by the following code $$\begin{cases}
a_1x+b_1y+c_1z=d_1 \\
a_2x+b_2y+c_2z=d_2 \\
a_3x+b_3y+c_3z=d_3
\end{cases}
 • To align the = signs use \begin{aligned}...\end{aligned} and \left\{…\right. (see asmeurer's comment)\left\{\begin{aligned} a_1x+b_1y+c_1z&=d_1+e_1 \\ a_2x+b_2y&=d_2 \\ a_3x+b_3y+c_3z&=d_3 \end{aligned} \right. $$whose code is $$
\left\{
\begin{aligned}
a_1x+b_1y+c_1z &=d_1+e_1 \\
a_2x+b_2y&=d_2 \\
a_3x+b_3y+c_3z &=d_3
\end{aligned}
\right.
 • To align the = signs and the terms as in\left\{\begin{array}{ll}a_1x+b_1y+c_1z &=d_1+e_1 \\ a_2x+b_2y &=d_2 \\ a_3x+b_3y+c_3z &=d_3 \end{array} \right.use array with l (for "align left"; there are also c and r) parameters 
\left\{
\begin{array}{ll}
a_1x+b_1y+c_1z &=d_1+e_1 \\
a_2x+b_2y &=d_2 \\
a_3x+b_3y+c_3z &=d_3
\end{array}
\right.
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
$$ renders as$$ \left\langle q\middle\|\frac{\frac{x}{y}}{\frac{u}{v}} \middle| p \right\rangle. $$Note that constructs like \left\langle, \left| and \left\| are also possible. - ## Additional decorations \def\demo#1#2{#1{#2}\ #1{#2#2}\ #1{#2#2#2}} \overline: \demo\overline A \underline: \demo\underline B \widetilde: \demo\widetilde C \widehat: \demo\widehat D \fbox: \demo\fbox {E} \underleftarrow: \demo\underleftarrow{F} \underrightarrow: \demo\underrightarrow{G} \underleftrightarrow: \demo\underleftrightarrow{H} \overbrace: \overbrace{(n - 2) + \overbrace{(n - 1) + n + (n + 1)} + (n + 2)} \underbrace: (n \underbrace{- 2) + (n \underbrace{- 1) + n + (n +} 1) + (n +} 2) \overbrace and \underbrace accept a superscript or a subscript, respectively, to annotate the brace. For example, \underbrace{a\cdot a\cdots a}_{b\text{ times}} is$$\underbrace{a\cdot a\cdots a}_{b\text{ times}}$$Additional accents \check: \check{I} \acute: \acute{J} \grave: \grave{K} - # Tags & References For longer calculations (or referring to other post's results) it is convenient to use the tagging/labelling/referencing system. To tag an equation use \tag{yourtag}, and if you want to refer to that tag later on, add \label{somelabel} right after the \tag. It is not necessary that yourtag and somelabel are the same, but it usually is more convenient to do so: $$ a := x^2-y^3 \tag{*}\label{*} $$$$ a := x^2-y^3 \tag{*}\label{*} $$In order to refer to an equation, just use \eqref{somelabel} $$ a+y^3 \stackrel{\eqref{*}}= x^2 $$$$ a+y^3 \stackrel{\eqref{*}}= x^2 $$or \ref{somelabel} Equations are usually referred to as \eqref{*}, but you can also use \ref{*}.  Equations are usually referred to as \eqref{*}, but you can also use \ref{*}. As you can see, references are even turned into hyperlinks, which you can use externally as well, e.g. like this. Note that you can also reference labels in other posts as long as they appear on the same site, which is especially useful when referring to a question with multiple equations, or when commenting on a post. Due to a bug blocks containing a \label will break in preview, as a workaround you can put \def\label#1{} in your post while editing and remove that on submission - unfortunately this means you won't spot misspelled references before submitting... Just don't forget to remove that \def again - Also works in comments: \eqref{*} yields a clickable \eqref{*} – Tobias Kienzler Oct 31 '13 at 10:22 ## Limits To make a limit (like \lim \limits_{x \to 1} \frac{x^2-1}{x-1}), use this syntax: First, start off with \lim. This renders as \lim. The backslash is there to prevent things like lim, where the letters are slanted. Second, add \limits_{x \to 1} inside. The code now looks like \lim \limits_{x \to 1}, and renders as \lim \limits_{x \to 1}. The \to inside makes the right arrow, rendered as \to. The _ makes the x \to 1 go underneath the \lim. Finally, the pair of curly braces { } makes sure that x \to 1 is treated as a whole object, and not two separate things. Lastly, add the function you want to apply the limit to. To make the limit mentioned above, \lim \limits_{x \to 1} \frac{x^2-1}{x-1}, simply use \lim\limits_{x \to 1} \frac{x^2-1}{x-1}. And that is how you make a limit using MathJax. - Why not just \lim_{x\to 1}$$\lim_{x\to 1}?$$As I understand it \limits is only needed for operations that don't already understand limits, for example if you want to use + and get$$\mathop{+}\limits_{i=1}^k\text{ instead of }+_{i=1}^k$$When used inline, your suggestion will produce \lim\limits_{x\to 1} instead of the more compact form \lim_{x\to 1} that mathjax normally chooses. Are you sure this is good advice? – MJD Feb 26 at 14:10 @MJD \lim_{x\to 1} renders to \lim_{x\to 1}, and \lim\limits_{x\to 1 renders as lim\limits_{x\to 1}. Note how the x\to 1 is separated from the first limit, and not directly underneath. We do not write limits like that in real life, so we use \limits. – JChau Feb 26 at 16:19 I meant that the second limit renders to \lim \limits_{x \to 1} – JChau Feb 26 at 16:28 Limits are usually written that way in typeset materials like papers and books when the limit is inline, rather than a displayed formula, and that's why MathJax typesets it that way. – MJD Feb 26 at 16:41 The issue with this answer is that it is trying to "force" display mode on inline code. Doing so makes the text look less pretty. For example, see how the spacing between the lines change when I force display mode using \lim\limits_{x\mapsto 1}\dfrac1x: \lim\limits_{x\mapsto 1}\dfrac1x. On the other hand, when I let \TeX do what it wants to do, using \lim_{x\mapsto 1}\frac1x, the spacing between the lines stays the same, which is much neater: \lim_{x\mapsto 1}\frac1x. This is much easier on the eyes. If you want to make your math mode more prominent then take a new line using $$-$$ – user1729 Jul 17 at 12:30 The moral is: \TeX was written by a jolly clever chap. Let it do what it wants, because it does it for a reason! – user1729 Jul 17 at 12:35 # Arbitrary operators If an operator is not available as a built-in command, use \operatorname{…}. So for things like$$\operatorname{arsinh}(x)$$write \operatorname{arsinh}(x) since \arsinh(x) will give an error and arsinh(x) has wrong font and spacing: arsinh(x). This was already mentioned in a comment by Charles Staats. You might consider this an addition to the FAQ section on \lim, \sin and so on. - We can also use \verb*{\rm ...}*. For example, \verb*{\rm arsinh}* yields {\rm arsinh}. – Felix Marin Aug 12 at 0:27 @Felix: \rm will change the font but not the spacing. \operatorname{arsinh}x renders as “\operatorname{arsinh}x” while {\rm arsinh}x renders as “{\rm arsinh}x”. Notice the added space between operator and operand in the first example, which is missing in the second. On the whole, I'd say that operatorname is a lot more in the spirit of semantic markup, declaring what you want to write instead of how you want to write it, so I'd strongly suggest using this. – MvG Aug 13 at 11:27 Thanks. I didn't know there was a difference between them. I always avoided {\tt operatorname} because it was too long. – Felix Marin Aug 13 at 14:41 Thanks for this. I thought carefully about whether to put \operatorname in the main post, and decided to leave it out. The reason is simple: If a beginner omits \operatorname, the resulting formula will still be perfectly clear, and a more experienced user will have no trouble inserting the \operatorname where it is needed. So including it in the main post would not be a good use of space. – MJD Aug 16 at 6:28 ## Left and Right Implication Arrows Another way to display the arrows for right and left implication instead of using \Rightarrow, \Leftarrow and \Leftrightarrow which produces \Rightarrow, \Leftarrow and \Leftrightarrow respectively, you can use \implies for \implies, \impliedby for \impliedby and \iff for \iff The latter of which produces longer arrows which may be more desirable to some. - # Absolute values and norms The absolute value of some expression can be denoted as \lvert x\rvert or, more generally, as \left\lvert … \right\rvert. It renders as \lvert x\rvert. The norm of a vector (or similar) can be denoted as \lVert v\rVert or, more generally, as \left\lVert … \right\rVert. It renders as \lVert v\rVert. (You may also write \left\|…\right\| instead.) In both cases, the rendering is better than what you'd get from |x| or ||v||, which render with bars that don't descend low enough and sub-optimal spacing. At least on some browsers, so here is a screenshot how it looks for me, using Firefox 31 on OS X: And here is the same formula rendered by your browser:$$|x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\rVert$$It was typeset as $$|x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\rVert

-
You can use \|x\| instead of \lVert x \rVert; $\|x\|$ and $\lVert x \rVert$. (I don't think that there is a difference between them. I've tried [asking on SE](tex.stackexchange.com/questions/77767/whats-the-correct-way-to-write-norm).) –  Martin Sleziak Jun 24 at 8:48
On my browser |x| and \lvert x\rvert ($|x|$ and $\lvert x\rvert$) look identical, contrary to your claim. Perhaps you need to show an example more complicated than just 'x'? –  MJD Jun 24 at 12:39
@MJD: What's your browser? I included a screenshot to support my claim. –  MvG Aug 13 at 11:24
Usually various versions of Firefox on either Linux or Windows. I happen to have Windows 8 booted now, so here's a screenshot from there: a.pomf.se/jrujkq.PNG The bar height looks good on both pairs of symbols; the spacing is a little off for the || version. On Linux they looked the same. –  MJD Aug 13 at 17:02
Here's a screenshot with FF 31.0 under Linux: a.pomf.se/fhwmjo.png –  MJD Aug 16 at 6:23

## Commutative diagrams

$\require{AMScd}$
\begin{CD}
A @>a>> B\\
@V b V V\# @VV c V\\
C @>>d> D
\end{CD}


to get this diagram: $\require{AMScd}$ \begin{CD} A @>a>> B\\ @V b V V\# @VV c V\\ C @>>d> D \end{CD}

@>>> is used for arrow right

@<<< is used for arrow left

@VVV is used for arrow down

@AAA is used for arrow up

@= is used for horizontal double line

@| is used for vertical double line

@. is used for no arrow

Another example:

    \begin{CD}
A @>>> B @>{\text{very long label}}>> C \\
@. @AAA @| \\
D @= E @<<< F
\end{CD}


\begin{CD} A @>>> B @>{\text{very long label}}>> C \\ @. @AAA @| \\ D @= E @<<< F \end{CD}

Long labels increase the length of the arrow and in this version also automatically increase corresponding arrows.

-