9
$\begingroup$

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

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.

$\endgroup$
8
  • 1
    $\begingroup$ Use $$2x+y-3 \tag {1} $$ $\endgroup$ Commented Aug 5, 2017 at 22:02
  • 1
    $\begingroup$ 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.) $\endgroup$
    – Blue
    Commented Aug 5, 2017 at 22:08
  • $\begingroup$ @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. $\endgroup$
    – lucky1928
    Commented Aug 5, 2017 at 22:09
  • 2
    $\begingroup$ @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 ...) $\endgroup$
    – Blue
    Commented Aug 5, 2017 at 22:14
  • $\begingroup$ 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. $\endgroup$ Commented Aug 5, 2017 at 23:26
  • 4
    $\begingroup$ 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. $\endgroup$
    – hardmath
    Commented Aug 6, 2017 at 19:25
  • 2
    $\begingroup$ @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. $\endgroup$
    – Paramanand Singh Mod
    Commented Aug 7, 2017 at 7:50
  • $\begingroup$ 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.) $\endgroup$ Commented Aug 13, 2017 at 1:47

2 Answers 2

4
$\begingroup$

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.

$\endgroup$
7
  • $\begingroup$ 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. $\endgroup$
    – Mr. Brooks
    Commented Aug 8, 2017 at 22:33
  • $\begingroup$ @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? $\endgroup$ Commented Aug 8, 2017 at 23:23
  • $\begingroup$ 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. $\endgroup$
    – Mr. Brooks
    Commented Aug 10, 2017 at 21:48
  • $\begingroup$ @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? $\endgroup$ Commented Aug 10, 2017 at 23:38
  • $\begingroup$ 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. $\endgroup$
    – Mr. Brooks
    Commented Aug 14, 2017 at 21:24
  • $\begingroup$ 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. $\endgroup$ Commented Aug 15, 2017 at 3:52
  • $\begingroup$ Alright, I'm sorry for dragging us down this pointless and tiresome tangent. $\endgroup$
    – Mr. Brooks
    Commented Aug 15, 2017 at 22:00
2
$\begingroup$

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

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .