I have the following code in Overleaf:
\begin{align}
\frac{\partial\Lagr}{\partial x_{1}} &= x_{2} + 2x_{1}\lambda_{1} = 0 \\ \frac{\partial\Lagr}{\partial x_{2}} &= x_{1} + x_{3} + 2x_{2}\lambda_{1} + \lambda_{2} = 0\\
%
\frac{\partial\Lagr}{\partial x_{3}} &= x_{2} + \lambda_{2} = 0\\
%
\frac{\partial\Lagr}{\partial \lambda_{1}} &= x_{1}^2 + x_{2}^2 - 2 = 0 \\ \frac{\partial\Lagr}{\partial \lambda_{2}} &= x_{2} + x_{3} -2 = 0
\end{align}
Which generates this:
Which is what I want, however, later I do another one \begin{align}
in which I want the numbers of the equations to be reset, to start from 1 again, this has the following code:
\begin{align}
-2\cdot\alpha_{1} &= 0\\
2\cdot\alpha_{1} + \alpha_{2} &= 0\\
\alpha_{2} &= 0\\
\Rightarrow \alpha_{1} = \alpha_{2} &= 0
\end{align}
And this continues with the sequence of numbers:
Which is not what I want.
There I found commands like:
- \newcounter{foo}[counter]
- \setcounter{counter}{0}
And they don't work for me, or I don't know how to use them in these sections.
The command to reset a counter is
\setcounter{contador}{0}
. The trick is knowing what the counter you want to reset is called.In the case of equations, the counter is called
equation
, so just put the following line before the secondalign
:A different approach to the problem would be to use
{subequations}
Example:
Otherwise, and as a complement to abulafia's answer, you can use
etoolbox
to connect the start event of thealign
and restart the counter of these automaticallyExample: