# Short and helpful advice on using MathJax on the site ...

The point of this question is to give people a chance to draft their best MathJax tips for new users. Perhaps this question will stand alone as one of the places to go. Perhaps the material in the answers will be edited into an introductory article. Perhaps it will flop. Who knows? But the whole idea is to pool knowledge and experience to help those who are learning.

• I think that the idea behind this questions is very good. I might alter the title a bit.Maybe something like "Short and helpful advice on using..."
– quid Mod
Feb 19, 2021 at 19:13
• @quid Thank you - I didn't think the title was right, but had to cook supper ... I don't mind so much if people don't think this is a question, except that I care a lot about how we make things easier for new users. I am an old hand now, but had never heard of MathJax when I first encountered the site, In those days I got help and direction from people who knew stuff. These days, competence is often assumed. It matters how we induct people more than how precious I am about my own reputation. Feb 19, 2021 at 19:43
• Perhaps we just keep directing people to the existing Q&A on using MathJax, and expect them to make an effort in writing their own question instead of doing it all for them?
– Nij
Feb 19, 2021 at 20:42
• @Nij For new people I think we need to be a little more welcoming that that - not so much "engage with Mathjax or else" as "Mathjax will format your question the way you want it" Feb 19, 2021 at 20:58
• So add an introduction to the MathJax guide. Add a section that gives information on the 8-10 most frequently used codes.
– Nij
Feb 19, 2021 at 22:16
• @Nij the MathJax guide is relatively big; depending on the device one uses rendering is an issue. A more lean version that exists separately would be better than adding to the large one.
– quid Mod
Feb 19, 2021 at 22:50
• there is already a very lean version here, (and I'll just link the full guide too,) but that doesn't look easy to change without mods or higher powers Feb 20, 2021 at 4:11
• @Nij The MathJax guide on meta is something that needs to exist, and people should be linked to it, but it has problems. It is not very well organized, and (as quid points out) it can take a long time to render. If someone had the time, it would be really nice if that thread were to be massively edited for organization, and to better fit the Q&A style of the site--something more like the how to ask a good question topic. Barring some massive rewrites, it is not a great place for beginners. :\
– Xander Henderson Mod
Feb 20, 2021 at 4:49
• Perhaps you should propose some small additions to How can I format mathematics here?, the existing brief introduction. Feb 20, 2021 at 17:20
• So I might understand closing this as a duplicate, but why are there 4 close votes as opinion based? Very puzzling. Feb 20, 2021 at 22:23
• @XanderHenderson I am busy next week, but after that I can take up a project on revamping the MathJax page. I just need more moderators to agree that this is the right thing to do. Feb 21, 2021 at 6:37
• I've began writing a tutorial that is aimed at covering the absolute basics. The most common pieces of syntax I'm going to cover are: numbers, arithmetic, basic operations, functions, limits, and integrals. If you think that there is something I have left out, please let me know. Do keep in mind however that I'm trying to cover the bare minimum needed to be competent in Mathjax. Aesthetic considerations such as how to align equations are unlikely to be covered, unless there is a strong consensus for me to include them in my answer.
– Joe
Feb 21, 2021 at 14:26
• @Joe First off, thank you for taking the time and mind for this. Maybe elementary set theory or basic discrete mathematics shall be included too Feb 21, 2021 at 17:05
• Since there seems to be a lot of interest in making the Mathjax tutorial more user friendly, I have voted to reopen. I can't understand why this post would be deemed 'opinion based'—it's just a list of which commands are the most frequently used on this site, organised in a way that would be helpful to new contributors.
– Joe
Feb 23, 2021 at 9:48
• There should also be a well publicized set of MathJax and LaTeX tips for old user who've been using LaTeX daily for at least of a couple of decades and still fill every paragraph with lots of crude solecisms that they would avoid if they knew some basics. This probably includes more than 70% of professors of mathematics. Feb 25, 2021 at 15:07

The goal of this post is to outline the absolute basics of how to typeset mathematics using MathJax, without any prior knowledge assumed.

Introduction: when asking and answering questions, it makes your writing much clearer if you typeset the mathematical notation using the markup language MathJax. Compare how the quadratic formula reads with and without it: $$\underbrace{x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}}_{\text{With MathJax}} \quad \underbrace{\text{x=-b+-sqrt(b^2-4ac)/2a}}_{\text{Without MathJax}}$$ This tutorial serves as a brief introduction to how MathJax works, and how you can use it. A more comprehensive overview of the subject can be found here.

1. Getting started
2. Understanding MathJax syntax
3. Numbers and arithmetic
4. Functions
5. Chaining syntax together
6. Miscellaneous commands

1. Getting started: in the body of your post, you can typeset formulas by putting two dollar signs $$ before the formula, and after the formula: Be careful not to leave an empty line between the formula and the dollar signs. In the above example, the formula is displayed on a new line. This is known as a 'block formula' or 'displayed formula'. It is possible to write out multiple lines of equations. Each time you want to go onto a new line, you have to indicate this by typing two back-slashes \\: 2x + 7 = 15 \\ 2x = 8 \\ x = 4  Notice that the final line does not require two back-slashes. If you enclose the above code using dollar signs, then it renders as $$2x + 7 = 15 \\ 2x = 8 \\ x = 4$$ It is also possible to display the formula on the same line as the text: This is known as an 'inline formula'. Rather than enclosing the formula with two dollar signs, you should only use a single  at the start and end of the formula. You can also use inline formulas in the title of your post (but not block formulas). 2. Understanding MathJax syntax: since MathJax is a markup language, there is a syntax that you have to follow. Simply enclosing x=-b+-sqrt(b^2-4ac)/2a with dollar signs does not do the trick: $$x=-b+-sqrt(b^2-4ac)/2a$$ Instead, there are a set of commands that have to followed in order to typeset the equations nicely. The rest of this post will focus on the most common ones; a more comprehensive list can be found in the main tutorial. In general, if you want to see how a formula was rendered, then right-click on it, and press 'Show Math As', then 'TeX Commands': If you're wondering how to type a specific symbol, then Detexify is the tool for you. It allows you to draw a symbol, and finds the closest matching command for it. (These commands are not guaranteed to work in MathJax, but they are likely to.) 3. Numbers and arithmetic: to write out equations such as $$4+7=11$$, you simply have to enclose them using with dollar signs (no special commands are needed). Easy-peasy! 4+7=11 renders as $$4+7=11$$. For multiplication and division, there are a number of options: • $$5 \times 7 = 35$$ is rendered using 5 \times 7 = 35. If you want to indicate multiplication using a dot, as in $$5 \cdot 7 = 35$$, you can write 5 \cdot 7 = 35. • $$12 \div 6 = 2$$ is rendered using 12 \div 6 = 2. It is more common to indicate division using fractions: $$\frac{3x+7}{2}$$ is produced by \frac{3x+7}{2}. Notice how the \frac command has to be accompanied by two sets of curly braces. The numerator goes in the first set of curly braces, and the denominator goes in the second set of curly braces. Finally, you can also indicate division simply by using a forward slash: 1/3 produces $$1/3$$. For exponents, you have to use a superscript ^. For instance, $$2^4=16$$ is rendered using 2^4=16. If the exponent has more than one character, then you have to enclose it using curly braces. For instance, $$2^{10}=1024$$ is rendered using 2^{10}=1024, not 2^10=1024. Square roots are typeset using the command \sqrt: $$\sqrt{64}$$ is produced by \sqrt{64}. Confusingly, cube roots can also be typeset using the \sqrt command: $$\sqrt[3]{64}$$ is produced by \sqrt[3]{64}. $$n$$-th roots can be handled similarly. Inequalities such as $$5>4$$ can be written as 5>4. If you need to use a 'greater than or equal to' sign, then use \geq: $$5 \geq 4$$ is produced by 5 \geq 4. The 'less than or equal to' sign is \leq. The 'not equal to' sign is \neq. 4. Functions: to write out a function such as $$\sin(x)$$, you have to use a backlash: \sin(x). You can also omit the parentheses by using curly braces instead: \sin{x} renders as $$\sin{x}$$. Alternatively, you can leave a space between the function and the argument: \sin x also renders as $$\sin x$$. Other functions such as $$\ln x$$ and $$\arctan x$$ can be typeset in much the same way. Again, if you are unsure about what the command for a function is, then right-click on it, and press 'Show Math As', then 'TeX Commands'. You can often guess the MathJax command for a function: it is no surprise that \exp renders as $$\exp$$. To indicate the base of a logarithm, use an underscore _ and curly braces where needed. \log_{10}x renders as $$\log_{10}x$$. In general, the subscript of an expression can be typeset with _, and the superscript with ^. For instance, \sin^2 x produces $$\sin^2{x}$$ and x_1 produces $$x_1$$. You can even use both a _ and ^ in the same expression: x_1^2 produces $$x_1^2$$, although this can be written more cleanly using parentheses: (x_1)^2 produces $$(x_1)^2$$. Finally, if you want to define a function yourself, then something like f(x)=2x+7 renders as $$f(x)=2x+7$$. 5. Chaining syntax together: more complicated-looking formulas in MathJax are often built from simpler ones. The formula $$\frac{1}{x}\sqrt{\frac{1+x}{1-x}}\ln(\frac{2x^2+2x+1}{2x^2-2x+1})$$ looks unpleasant to typeset, but is actually simply composed of three simple expressions: \frac{1}{x} \sqrt{\frac{1+x}{1-x}} \ln (\frac{2x^2+2x+1}{2x^2-2x+1})  Notice that the MathJax editor has no problem with putting a fraction inside of a square root, for example. One aesthetic issue with the above formula is the odd sizing of the parentheses in $$\ln(\frac{2x^2+2x+1}{2x^2-2x+1})$$ This can be remedied by replacing ( with \left( and ) with \right). If we change the code to \ln\left(\frac{2x^2+2x+1}{2x^2-2x+1}\right)  it displays as $$\ln\left(\frac{2x^2+2x+1}{2x^2-2x+1}\right)$$ which is more pleasant to look at, though not strictly necessary. If you want to include text in formulas, then use \text. For instance, \text{speed} = \frac{\text{distance}}{\text{time}}  renders as $$\text{speed} = \frac{\text{distance}}{\text{time}}$$ 6. Miscellaneous commands: • Greek letters: simply type the name of the Greek letter. \pi renders as $$\pi$$. If you want uppercase, then begin the command with a capital letter: \Gamma renders as $$\Gamma$$. • For set membership, the commands \mathbb and \in come in handy: $$x \in \mathbb{R}$$ is rendered by x \in \mathbb{R}. The complete list of fonts can be found in the main tutorial. • For logical implication, \implies and \iff are useful: $$x = 5 \implies x^2 = 25 \\ x^2 = 25 \iff x = 5 \text{ or } x = -5$$ is rendered by x = 5 \implies x^2 = 25 \\ x^2 = 25 \iff x = 5 \text{ or } x = -5  • Helpful, +1. If there's a revamp of the MathJax tutorial page as we thought on a recent chat, I would consider your opinion worthy on any edits we make there, following this answer. Thank you. Feb 21, 2021 at 10:20 • @TeresaLisbon: Thank you Teresa; I am very hopeful that the Mathjax tutorial will become more user-friendly for beginners. – Joe Feb 21, 2021 at 15:18 • I am actually busy this week, but next week I am planning to start the revamp. I will.ask the moderators about this prior to doing so. I expect to merely "act" and not think since that is my strength, so I will need great guidance(orders?)from moderators and you. Feb 21, 2021 at 15:45 • This is great. One thing I was wondering when I asked the question was whether it was better to do a few shorter posts of this kind on different topics, rather than longer and more comprehensive ones. This hits the kind of level I was thinking might be helpful. Feb 21, 2021 at 17:13 • @MarkBennet: I was hoping that this post could stay as one, since the individual sections aren't really self-contained. So thanks for confirming that this was the right 'level'. It's still not exactly clear what will become of the Mathjax tutorial, but hopefully the end product will not be as messy as before. I do find it rather ironic that the 'basic tutorial' has pages upon pages about how to use the software. Perhaps this thread could be turned into the 'basic' tutorial, and the old one be turned into the 'comprehensive' tutorial. – Joe Feb 21, 2021 at 19:08 • @MarkBennet My feeling is that the best format is a Q&A. The "question" should contain the basic idea "We use MathJax here... how does that work?", and each answer should contain some useful information which addresses a basic problem. The question should have an index of those answers. – Xander Henderson Mod Feb 22, 2021 at 18:42 • @XanderHenderson: Would you suggest then that this answer should be broken into smaller pieces? – Joe Feb 22, 2021 at 18:56 • @Joe I am typically more of a "splitter" than a "lumper" (e.g. I would prefer to prove four or five short lemmata before getting to main theorem, rather than prove the main theorem all at once). As such, I generally err on the side of smaller, more digestible chunks. However, I don't have the time or energy to take on this project, so I am not sure that my opinion counts for very much (which won't prevent me from giving it, but...). – Xander Henderson Mod Feb 22, 2021 at 19:28 • I think the thing about "Show Math as" in point 2 could also be extracted as a separate point (since the aim is pedagogical and basic I don't think repetition is too much of a problem). I seem to remember that I learned a lot by using this simple function on questions and topics that interested me to answer "well how did they do that then?" Feb 22, 2021 at 21:25 • @MarkBennet: Where do you suggest the 'Show Math As' section should go? Do you mean I should post a separate answer with the same information, just so that it is impossible to miss? – Joe Feb 23, 2021 at 9:45 • @Joe If there were several short articles a "How did they do that ..." or "How do I learn from what other people have done ..." piece as stand alone would work. Then with the other pieces there could be "as you get more engaged with the site you can explore how other people have formatted their posts" section near the beginning. I am just trying to think how people who are learning will best be helped. Feb 23, 2021 at 10:49 • @MarkBennet: Sounds good. Perhaps if more people post answers it will be clearer how exactly to format things, but having a sort of directory with that information is a good idea. By the way, have you voted to reopen your own post? (Apparently you can do that.) – Joe Feb 23, 2021 at 21:43 • @TeresaLisbon: Hi Teresa. Have you began the revamp of the Mathjax tutorial yet? – Joe Mar 4, 2021 at 19:57 • @Joe No, some personal tasks have taken over my time on MSE a little bit, so I have not been able to dedicate to meta MSE, let alone the MathJax tutorial page. I cannot set a time frame, but I am actually working from home currently and will shift back to hostel in some time which gives me more time to work. So I will start this activity once I get back, hopefully next week. Thank you for asking! Mar 5, 2021 at 2:31 • @Joe I've been using this page , over the usual MathJax page, for beginner reference for the past few months. It's been mighty helpful, and on a few occasions I've been given positive feedback. Just wanted to say thanks once again. Dec 6, 2021 at 12:44 Some Dos and Don'ts based on a little time in the review queues Do type each equation inside a single pair of dollar signs ..., or $$...$$. This is both easier than the alternative, and correct: instead of x=y+z$$x$$=$$y$$+$$z$$, you should write x=y+z$$x=y+z$$. Do type all mathematics inside Mathjax, even if you don't need a special symbol like $$\aleph$$ or $$\beta$$ e.g. $$1 = 9 - 8$$, instead of 1= 9-8. Do check the preview to see if what you typed is indeed what you wanted to say! • If you do not catch the errors, then you may get answers to a question you didn't want to ask. Do edit your current post to include Mathjax when someone sends you to this page, instead of asking a new question or posting a new answer. • Also make sure your question (if you are asking one) has context: using Mathjax is not enough to prevent close votes and downvotes. Don't rely on Unicode characters! • They don't always 𝕡𝕝𝕒𝕪 𝕟𝕚𝕔𝕖. Mathjax is not only a way to put fancy symbols on the page. Mathjax is easy to read and consistent on any device. Don't upload pictures of maths that can be easily typed! • See discussion here. It's more understandable if you are sharing a larger part of a document, but do consider if you really need to share it as less people will read long posts! Don't use \dfrac,\limits and \displaystyle too often. • It makes your post messy and unprofessional. If you need to make mathematics on the site appear bigger to you, you can adjust your Mathjax preferences (see instructions here). Also, using them in titles makes them much larger than other titles, which is discouraged. • Not sure if this is what you're going for, but lets see the votes I get on this...suggestions welcome of course Feb 27, 2021 at 8:57 • I hadn't thought about the learning from reviewing angle - but since the goal would be to help people when they need it most, that is a very useful perspective. I also like the way you have put it as Dos and Don'ts - there is something about inducting people into the culture of these things as well as the technical aspects - and that arises not so much from the questions of the learner, but from sometimes mysterious and unstated conventions. Thank you! Feb 27, 2021 at 9:39 • Nice answer. I have added it to the table of contents. – Joe Feb 27, 2021 at 10:55 • +1 nice idea. Perhaps the existence of the MathJax chatroom should be mentioned too, in case someone have doubts about how to type. Feb 27, 2021 at 16:15 • @veronika That’s very good to mention but I’m not sure it is the most useful for absolute beginners as chat rooms in SE require you to have a little bit of rep first...! Feb 27, 2021 at 21:26 • @CalvinKhor Yes, you need 20 of reputation. Feb 28, 2021 at 4:12 • IIRC I think I once read a Martin's (post? or comment?) that the 20 of reputation can be from another site, so you could have zero of reputation (actually not even having an account! :) and yet, comment on chat. May 26, 2021 at 6:01 • @VerónicaRmz. I believe you are right. This is why your reputation in chat is not the same as the reputation on Math.SE; it is the combined reputation on all SE sites (ie excluding SO, MO, and Meta.SE iirc) Still an issue for completely new users of SE, but not every new user of Math.SE May 26, 2021 at 6:23 This answer focuses on calculus notation. I have broken this section off from the beginners tutorial because I'm not convinced that it is essential for new contributors to be aware of the following commands. Personally, I have no issue with a beginner writing "how do I integrate $$x^2$$" as opposed to "evaluate $$\int x^2 \, dx$$". Calculus notation: this section briefly covers some of the most commonly used notations in calculus, namely series, limits, derivatives, and integrals. To begin with, a series such as the one below can be written using the following commands: 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \dots = \infty  $$1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \dots = \infty$$ The above line of code uses the commands \dots and \infty, which are both useful to be aware of. The same series can be written using sigma notation. \sum_{n=0}^{\infty}\frac{1}{n} = \infty  $$\sum_{n=1}^{\infty}\frac{1}{n} = \infty$$ This is another example of when you need to use both an underscore _ (for the lower bound) and a superscript ^ (for the upper bound) to properly format the sum. Integrals follow the same pattern: \int_{0}^{\infty}\frac{\sin x}{x} \, dx = \frac{\pi}{2}  (It's good style to leave a thin space \, between the integrand and the $$dx$$, but again this is not necessary.) $$\int_{0}^{\infty}\frac{\sin x}{x} \, dx = \frac{\pi}{2}$$ With both sums and integrals, you can also omit the upper and lower bounds: \text{mean} = \frac{1}{n}\sum{x_i} \\ \int \sec x \, dx = \log\left|\sec x + \tan x\right|+ C  $$\text{mean} = \frac{1}{n}\sum{x_i} \\ \int \sec x \, dx = \log\left|\sec x + \tan x\right|+ C$$ Derivatives are a lot easier to typeset than integrals. Leibnizian notation can be handled using \frac commands: \frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}  $$\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$$ Lagrange's prime notation can also be typeset fairly easily: (f \circ g)'(x) = f'(g(x))g'(x)  The command \circ is sometimes used to indicate the composition of functions: $$(f \circ g)'(x) = f'(g(x))g'(x)$$ To indicate that one number is approaching number, you can use \to. The sentence 'as $$x \to \infty$$, $$\frac{\ln x}{x} \to 0$$' is rendered by as $$x \to \infty$$, $$\frac{\ln x}{x} \to 0$$  Limits can be typeset using \lim and are usually accompanied by an expression that indicates the value that is being approached. Again, you have to use an underscore so that things are positioned correctly. \lim_{x \to 0}\frac{\sin x}{x}=1  renders as $$\lim_{x \to 0}\frac{\sin x}{x}=1$$ • Notice the conspicuous typographical difference between \log|\sec x + \tan x| and \log\left|\sec x + \tan x\right|.$$ \begin{align} {} \\ & \log|\sec x + \tan x| \\ \text{versus} \\ & \log\left|\sec x + \tan x\right| \\ {} \end{align}  Feb 25, 2021 at 15:09
• @MichaelHardy: would you suggest that I change it to \left| and \right| then?
– Joe
Feb 25, 2021 at 15:18
• Yes. That's what I do when this happens. $\qquad$ Feb 25, 2021 at 18:22
• @MichaelHardy: Okay, I've fixed it now.
– Joe
Feb 26, 2021 at 9:58
• This is more like LaTeX 201 than LaTeX 101, but getting absolute value bars and norm double bars right (especially when they surround something large) are a massive pain-in-the-ass to get right (which I don't think I do.) If someone wrote up a short and sweet answer for that it would certainly help me. Feb 27, 2021 at 23:05
• How about $\log \mid \sec x + \tan x \mid$. Mar 1, 2021 at 3:24
• @StevenAlexisGregory this is very late, but the correct way to fix this, even in $\rm\LaTeX$, is to use \lvert (and you might as well pair with \rvert): \log\lvert\sec x+\tan x\rvert gives $\log\lvert\sec x+\tan x\rvert$. For other delimiters, see (\lim \lVert \lim \lbrack \lim \lbrace \lim $(\lim \lVert \lim \lbrack \lim \lbrace \lim$ Oct 7, 2022 at 2:19
• IThanks, I'm at that age where I can't remember where I put that list of Mathjax expressions I can't remember. And now I need to make that list larger. Oct 11, 2022 at 3:31