LyXNumbering Equations by Theorem

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
Randolf
Posts: 2
Joined: Tue Jul 24, 2012 4:15 pm

Numbering Equations by Theorem

Post by Randolf »

Hey,

in LyX, I know how to insert numbered equations so that I have the number of the equation written in the marginal, like this:
equation-numbering-theorem.png
equation-numbering-theorem.png (16.15 KiB) Viewed 4047 times
As you can see, the number in the second theorem is (2) because I have already used the "numbered equation" once in my document. I want this counter to reset for each theorem. That is, in my example, both of the numbers should be (1).

ps. If possible, I'd prefer if this could be done purely by using the LyX interface.
Last edited by localghost on Tue Jul 24, 2012 5:25 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Numbering Equations by Theorem

Post by Stefan Kottwitz »

The package chngcntr supports such customization, besides low level LaTeX commands. You could write in your document preable, which you can modify via the LyX menu Document / Settings

Code: Select all

\usepackage{chngcntr}
\counterwithin*{equation}{theorem}
If your theorem counter had another name, use that one in the second line.

Note, that it's difficult to understand references, if you have several equations (1). It could be a good idea to label them together with the theorem number, such as (1.2.1) if at all - I would number then independently of theorems. Perhaps I would not number at all, if they are not referenced, just displayed in theorems.

Stefan
LaTeX.org admin
Randolf
Posts: 2
Joined: Tue Jul 24, 2012 4:15 pm

Numbering Equations by Theorem

Post by Randolf »

Thank you Stefan, what you said worked well.
Stefan_K wrote: Note, that it's difficult to understand references, if you have several equations (1). It could be a good idea to label them together with the theorem number, such as (1.2.1) if at all - I would number then independently of theorems. Perhaps I would not number at all, if they are not referenced, just displayed in theorems.
Stefan
Yes, I realised it wouldn't be easy to understand where I was referencing by say "equation (5)" if I had multiple equations labeled as (5).
However, I'm planning to use this numbering only to make it easier for the reader to follow my proofs. Say, if I wanted to prove the Pythagora's Theorem, I could label the equation as (1), and start my proof by "To prove the theorem, it suffices to show that (1) holds for all positive numbers."
Of course, in such simple case this this kind of numbering is unnecessary but I have found it helpful in cases that have lots of conditions and equations.
Post Reply