# Reset equation line numbers in Lyx

In Lyx, how can I reset the line numbers between display-style equations?

For example, if I have the following setup:

Some text
Line of display-style equation
Another line of display-style equation
A third line of the same
More text
Line of a new display-style equation
Another line of the same new one
Text again


and activate MathNumber Whole Formula on both equations, the line numbers are (1) (2) (3) as expected for the first equation, but (4) (5) for the second. This is unexpected. I would like the numbers to be (1) (2) (3) for the first, then (1) (2) for the second.

I tried this, adding \@addtoreset{equation}{part} to my preamble (the equations happen to be in different parts, even though that's not always true), in the hope that equation numbering rules might also apply to line numbering rules, but to no avail.

How can I achieve this?

## 1 Answer

You can reset the numbering of equations by adding the following to your document preamble (Document > Settings... > LaTeX preamble):

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\let\old@start@align\start@align
\def\start@align{\setcounter{equation}{0}\old@start@align}
\makeatother


This patches the align-related macro used at the start of the environment to always reset your counter to 0 (counters are typically incremented before setting them). Your LyX display will resemble

but the output will be