# How to write math equation with auto numbers

I can write a math equation as below: $$\begin{cases} 2x+y-3=0 .... (1) \\ 3x-5y+7=0 .... (2) \end{cases}$$

In this example, the equation number is added manually, is it possible to generate automatically? then if I have multiple equations, it can be numbered automatically.

• Use $$2x+y-3 \tag {1}$$ – hamam_Abdallah Aug 5 '17 at 22:02
• If you're asking how to auto-number here, on Math.SE using MathJax, then (I think) the answer is: you can't. However, in a true $\TeX$ word processor (TeXShop, etc), you would get numbering for free. (By the way, as @Salahamam_Fatima notes, you should use \tag{} for your equation numbers, as in \tag{1}, \tag{2}, etc. The parenthesized numbers will appear aligned at the far right; no need for separating dots.) – Blue Aug 5 '17 at 22:08
• @Salahamam_Fatima \tag sounds like tag the whole equation array as one number, if I add it to two equation one by one, it will report "multiple tag" error. – lucky1928 Aug 5 '17 at 22:09
• @lucky1928: It seems a little hacky, but you can get tag to work inside of cases, if you wrap the equations in an additional align. For instance, \begin{cases} \begin{align}2x+\phantom{5}y-3&=0\tag{1}\\ 3x-5y+7&=0 \tag{2}\end{align}\end{cases} yields \begin{cases} \begin{align} 2x+\phantom{5}y-3&=0\tag{1} \\ 3x-5y+7&=0 \tag{2} \end{align} \end{cases} (But now, the brace is a bit too far to the left. Hmmm ...) – Blue Aug 5 '17 at 22:14
• In LaTeX (as opposed to MathJax, which is what is used here) there are control sequences that will cause these to be generated by the software. That way if you have $50$ of them and you want to insert another after the $20\text{th}$ one, you don't have to manually re-number the ones that come after that. But sometimes you have to run LaTeX twice on the same file to get this result. That's because the first time it runs, it stores information in an auxiliary file and then uses that the second time it runs. – Michael Hardy Aug 5 '17 at 23:26
• It appears that the MathJax folks added an autonumber feature in v.2.0. See the new features write-up here, and scroll down to the section on Automatic Equation Numbering (about 15% down the page). They note that the feature is turned off by default. – hardmath Aug 6 '17 at 19:25
• @hardmath: if this is turned on for this site then will the numbering be for entire page or for each post on a page (this is what we need)? Perhaps this can be experimentally tested by moderators. – Paramanand Singh Aug 7 '17 at 7:50
• Not a direct answer, but a note on semantics of displayed math: A brace signifies a single logical equation that happens to consist of two or more equations. Either the brace should get one single number, or--if each equation deserves its own number--the brace should go. ;) (Separately, I myself would lean against auto-numbering in web content, because cutting-and-pasting MathJaX source might break cross references. That, however, is more a matter of opinion than the issue with braces and multiple numbers.) – Andrew D. Hwang Aug 13 '17 at 1:47

In LaTeX (as opposed to MathJax, which is what is used here) there are control sequences that will cause these to be generated by the software. That way if you have $50$ of them and you want to insert another after the $20\text{th}$ one, you don't have to manually re-number the ones that come after that. But sometimes you have to run LaTeX twice on the same file to get this result. That's because the first time it runs, it stores information in an auxiliary file and then uses that the second time it runs.

• I think TeXworks gives one the option to delete auxiliary files. I think also one can do that through the operating system without causing any problems for TeXworks. Of course that doesn't help Mr. Lucky here. – Mr. Brooks Aug 8 '17 at 22:33
• @Mr.Brooks : The relevance of your comment escapes me. What would be done differently if an auxiliary file were deleted, in a way that is relevant to what we're talking about here? – Michael Hardy Aug 8 '17 at 23:23
• It's relevant only because you mentioned LaTeX "as opposed to MathJax," Mr. Hardy. Otherwise I wouldn't even have thought about auxiliary files at all. – Mr. Brooks Aug 10 '17 at 21:48
• @Mr.Brooks : Your comments relevance still escapes me. Is deleting the auxiliary file something that you would do for some purpose? What would that be? – Michael Hardy Aug 10 '17 at 23:38
• After getting an error, if I fix the error in the source file but don't delete the aux files compilation might still fail. I thought I mentioned I brought this up only because you mentioned LaTeX. – Mr. Brooks Aug 14 '17 at 21:24
• You did say that you brought up deletion of aux files only because I mentioned MathJax. But only in your most recent comment did you mention some reason for deleting the aux file. – Michael Hardy Aug 15 '17 at 3:52
• Alright, I'm sorry for dragging us down this pointless and tiresome tangent. – Mr. Brooks Aug 15 '17 at 22:00

mathjax now supports auto numbering line, but turn off by default.

## Usage

<script>
window.MathJax = {
tex: {
tags: "ams"
}
};
</script>
<script
type="text/javascript"
id="MathJax-script"
async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
></script>


Now all equations will have auto numbering tag.

Related doc:

Automatic Equation Numbering