LaTeX How to label equations in Latex?

  • Thread starter Thread starter epenguin
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary
SUMMARY

This discussion focuses on labeling equations in LaTeX, specifically using the AMS-LaTeX package for automatic numbering. Users can utilize the \begin{equation} and \end{equation} commands to create numbered equations, while the \tag command allows for custom numbering. The conversation highlights the importance of consistent equation numbering for clarity in mathematical writing, referencing resources such as the Wikibooks page on LaTeX. Additionally, it notes that equation numbering resets with each new page in a document.

PREREQUISITES
  • Familiarity with LaTeX syntax and commands
  • Understanding of the AMS-LaTeX package
  • Knowledge of the \begin{equation} and \end{equation} commands
  • Basic concepts of document structure in LaTeX
NEXT STEPS
  • Explore the use of the \tag command for custom equation numbering
  • Learn about the \nonumber option to suppress numbering on specific equations
  • Research best practices for numbering equations in academic writing
  • Review the Wikibooks resource on LaTeX for advanced mathematics
USEFUL FOR

Mathematicians, researchers, and students who need to format equations in LaTeX for clarity and consistency in their documents.

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 ·
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K