I can see that the posts on this site contain nicely displayed mathematical formulas. How can I get such formulas in my posts? What syntax is used to typeset them?

Note: This is an attempt to make at least brief overview of MathJax syntax available directly here on MO - as suggested some time ago in this answer: FAQ on typesetting of formulae hard to find. (Perhaps this post also supports the idea that something like this might be useful: Quickly Accessible MathJax Help.) The question and answers are community wiki in order to encourage collaborative editing. We should probably try to keep the tutorial simple and brief - with links to other resources, in case somebody needs more details.

$\begingroup$Maybe if at some points advice on formatting mathematics is added MathOverflow's Help Center, perhaps this could be a candidate to include there. (Other from the links it could possibly look like math.stackexchange.com/help/notation - but including directly in the help center a link which sends user to a meta site of a different site might be a bit confusing for the users. Which is why I think that a link to something on Mathematics Meta might be preferable.$\endgroup$
– Martin SleziakJun 13 '18 at 4:58

1

$\begingroup$Thank you for this and other efforts of yours to improve MathOverflow. Gerhard "Feels That It Needed Saying" Paseman, 2018.06.13.$\endgroup$
– Gerhard PasemanJun 13 '18 at 16:41

2 Answers
2

This site uses MathJax - which is a library which for displaying mathematics in web browsers. The syntax is basically LaTeX, so if you are already familiar with TeX or LaTeX you should be fine. (It is worth keeping in mind that only stuff that can be used inside math mode works in MathJax too.1)

It is useful to know that you can learn some parts of the syntax also from posts by other users. If you see a formula, right click gets you to MathJax context menu. By choosing "Show Math As > TeX Commands" you can see the source which you can use to typeset formulas.

The mathematical formulas are enclosed in dollars. If you want a centered formula, you can use double dollars. For example $a^2-b^2=(a-b)(a+b)$ and $$\frac{a^2-b^2}{a-b}=a+b$$ gives $a^2-b^2=(a-b)(a+b)$ and $$\frac{a^2-b^2}{a-b}=a+b$$

Here is an overview of some basic commands, mainly through examples. If you need more than what is listed in this very basic overview, you can consult some of the resources linked in another answer to this question.

Superscripts, indices: You can use ^ for superscripts and _ for subscripts. If it is supposed to contain more than one symbol, then you enclose the content between {..}. (The same is true in many other cases, not only here.) Examples: $(x_1+\dots+x_n)^2$ $(x_1+\dots+x_n)^2$, $a^{b+c}=a^b\cdot a^c$ $a^{b+c}=a^b\cdot a^c$ and $F_n=F_{n-1}+F_{n-2}$ $F_n=F_{n-1}+F_{n-2}$. This is how you get double subscripts/superscripts: $a^{b^c}$ $a^{b^c}$ and $x_{n_k}$ $x_{n_k}$.

Fractions, radicals. Again, if you are using more than one symbol, use {..} - they are not needed if there is only one symbol. (But you can still use them if you want. For example, $\frac\alpha2$ and $\frac{\alpha}{2}$ give the same result.) Examples: $\frac\alpha2\cdot\frac{2^2}{\alpha^2}$ $\frac\alpha2\cdot\frac{2^2}{\alpha^2}$, $\sqrt{x^2+y^2}$ $\sqrt{x^2+y^2}$, $\sqrt[3]5$ $\sqrt[3]5$, $\sqrt[n]n\ge\sqrt[n+1]{n+1}$ $\sqrt[n]n\ge\sqrt[n+1]{n+1}$.

It is sometimes useful to change size of brackets, if the content between them is large: $\left(1+\frac1x\right)^x$ $\left(1+\frac1x\right)^x$. The operators \left and \right work for other types of parenthesis, too.

You can find a very basic introduction to MathJax (LaTeX) syntax in the other answer. Here are links to some further resources that might be useful. (Some of them are not specifically about MathJax, but since MathJax and LaTeX syntax is very similar, they can still help. And they might be also useful if, for some reason, you decide to learn LaTeX.)