How to label equations in Latex?

  • Context: LaTeX 
  • Thread starter Thread starter epenguin
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary

Discussion Overview

The discussion revolves around how to label equations in LaTeX for forum posts, focusing on methods for numbering equations with minimal effort. Participants explore various approaches, including automatic numbering and manual tagging, while sharing their experiences and challenges with these methods.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses a desire for a simple method to label equations without making them look cluttered.
  • Another participant mentions that the AMS-LaTeX package automatically numbers equations and provides a link for reference.
  • A participant notes that the equation numbering increments with each edit and questions how to reset it back to (1).
  • Some participants suggest using the \tag command to create fixed tags for specific equations, highlighting its usefulness for numbering important equations.
  • There is a discussion about the necessity of numbering equations, with one participant referencing an essay that advocates for consistent numbering for reader reference.
  • Another participant shares their observation that not all intermediate equations are numbered, citing variability in practices among mathematicians.
  • One participant explains the behavior of the LaTeX code in relation to the document's structure and how it affects equation numbering.

Areas of Agreement / Disagreement

Participants express differing views on whether to number all equations or only significant ones. There is no consensus on the best approach, and the discussion includes various methods and personal preferences.

Contextual Notes

Participants mention limitations related to the LaTeX code behavior, such as the automatic incrementing of equation numbers during editing and the need for specific formatting to avoid parsing issues.

epenguin
Science Advisor
Messages
3,638
Reaction score
1,014
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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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
3K
  • · Replies 11 ·
Replies
11
Views
6K
  • · 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
7K