LaTeX How to label equations in Latex?

  • Thread starter Thread starter epenguin
  • Start date Start date
  • Tags Tags
    Latex
AI Thread Summary
The discussion revolves around the challenges of numbering equations in forum posts using LaTeX. Users express a desire for a straightforward method to label equations without complicating the formatting. The AMS-LaTeX package is highlighted for its automatic equation numbering, which can be implemented with the \begin{equation} command. Users note that the numbering starts at 1 but increments with each edit, leading to confusion about resetting numbers. A solution discussed involves using the \tag command for fixed numbering, allowing users to label only significant equations. There is also mention of the LaTeX \nonumber option to suppress numbering for certain equations. The conversation touches on best practices for numbering equations in academic writing, emphasizing the importance of clarity for readers. Overall, the thread provides practical tips for effectively managing equation numbering in posts while acknowledging the limitations of the platform's LaTeX implementation.
epenguin
Science Advisor
Messages
3,637
Reaction score
1,013
I just want to label equations in a post I could make in the next hours if I knew.
Done 'by hand' it is always ugly.
I don't want anything fancy, stuff on the web is too fancy and useful for people writing books, I just want to put numbers on a handful of equations I don't need to give them names or anything like that

xyzabc ... (1)
uvwnmo ...(2)

and not spoil the look of it, with a minimum of effort..

I will like the one that works easy. :oldsmile:
 
Physics news on Phys.org
The AMS-LaTex package automatically numbers equations. It looks like these web pages do too.
See https://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics#Equation_numbering
Using this code:
Fortran:
\begin{equation}
f(x)=(x+a)(x+b)
\end{equation}
Gives:
\begin{equation}
f(x)=(x+a)(x+b)
\end{equation}

NOTE 1: When I started this post, the equation number started at 1. Each edit incremented it.
NOTE 2: I had to display the LaTex code as Fortran to keep the code from being parsed by LaTex.
 
Last edited:
  • Like
Likes epenguin
Thank you. That seems to be giving a good result so far except that ithappens exactly as in your note 1. My first equation is now (4). This will increase as I go along so there is no point in correcting it now, but when I have finished will I be able to reset the first equation as (1) and how?

Not too appears above my head and needs, I am just using mostly the PF latex primer which however doesn't have instructions for equation numbering.
 
I left the page and have come back. Now the equation number is 1. I bet that it resets that way. If you saw my post as equation 1, then that is what we want.

I just tested it. If you close the tab and come back, the numbering starts at 1. So that unwanted incrementing is only during the edit.
 
We can use \tag <nr> to add fixed tags:
$$f(x)=x+a \tag 1$$
 
  • Like
Likes epenguin and FactChecker
I like Serena said:
We can use \tag <nr> to add fixed tags:
$$f(x)=x+a \tag 1$$
Although auto-numbering is sometimes nice, these tags would be especially preferred if you only want to number the important equations. I think that would be most of the time.
 
Thank you FactChecker and Serena. I have now used FactChecker's suggestion and it has worked well. https://www.physicsforums.com/threa...ule-of-derivatives.924400/page-3#post-5837451 For my average post on here with a handful of equations the method given by Serena will no doubt be better, but for writing more complex work that of FactChecker would surely save a lot of work changing every number every time you changed a manuscript a little.

Serena's didn't actually work for me on a quick try but I wondered if her < >are the same as the inequalities signs on my keyboard, well they are looking the same; I will come back to this another day
 
Try
\tag{5}
 
  • Like
Likes epenguin
Sorry for that. I didn't intend for the angle brackets to be taken literally.
The code is:
Code:
f(x)=x+a \tag 1
f(x)=2x \tag{10}
$$f(x)=x+a \tag 1$$
$$f(x)=2x \tag{10}$$
And we need braces if the number is more than 1 digit, as @FactChecker suggested.
 
  • Like
Likes FactChecker and epenguin
  • #10
FactChecker said:
Although auto-numbering is sometimes nice, these tags would be especially preferred if you only want to number the important equations. I think that would be most of the time.

There's an essay (What's wrong with these equations?) by David Mermin about writing prose with equations embedded in it. One of the recommendations is to always number displayed equations. The reason is that equation numbers are there for anyone to refer to and not just you the author. You might know what equations you want to refer to but you don't know in advance what equations your readers (or referees) might want to refer to from your text. (Admittedly this is less of an issue for forum posts than research papers, since you can simply quote the parts of posts you want to refer to directly, but I still see lots of papers and project notes that don't consistently number equations.)
 
  • #11
I don't think that I would number intermediate equations as a rule. Scanning through books by some mathematicians that I admire, I see that there is some variation, even with the same book. In general, there are more numbered equations than I would have expected. Certainly the large majority are numbered.

I see that there is a LaTex \nonumber option to suppress numbers on certain equations.
 
Last edited:
  • #12
FactChecker said:
The AMS-LaTex package automatically numbers equations. It looks like these web pages do too.
See https://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics#Equation_numbering
Using this code:
Fortran:
\begin{equation}
f(x)=(x+a)(x+b)
\end{equation}

Gives:
\begin{equation}
f(x)=(x+a)(x+b)
\end{equation}

NOTE 1: When I started this post, the equation number started at 1. Each edit incremented it.
NOTE 2: I had to display the LaTex code as Fortran to keep the code from being parsed by LaTex.
The {equation} fields works for the entire document - i.e. this web page - such that its first use will be 1. Each added {equation} field will add 1 to the numbering, even if it is not in the same post. If your post falls on page 2, the numbering will reset to 1 (page 2 is a new HTML document).

You should note that in my quote, @FactChecker 's equation now have ##(2)## as the number and when I repeat it in my post, it increases to ##(3)##:
$$\begin{equation}
f(x)=(x+a)(x+b)
\end{equation}$$
Since the preview is part of this document, it also adds + 1 to the number the first time. I'm not sure why it adds one more every time you hit preview, but it has to do with how the DOM of the document is manipulated.
 
Last edited:
  • Like
Likes FactChecker

Similar threads

Replies
3
Views
2K
Replies
5
Views
2K
Replies
3
Views
2K
Replies
11
Views
5K
Replies
4
Views
2K
Replies
11
Views
2K
Replies
7
Views
3K
Replies
20
Views
3K
Replies
5
Views
5K
Back
Top