Math & ScienceReset number in eqnarray

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
anta40
Posts: 38
Joined: Thu Sep 11, 2008 2:36 pm

Reset number in eqnarray

Post by anta40 »

Using this script

Code: Select all

\documentclass{article}

\begin{document}

\begin{eqnarray}
a &=& b\\
c &=& d\\
d &=& e
\end{eqnarray}

\stepcounter{eqnarray}

\begin{eqnarray}
f &=& g\\
h &=& i\\
j &=& k
\end{eqnarray}

\end{document}
How to reset the counter, so the output would be:
a = b (1)
c = d (2)
d = e (3)
f = g (1)
h = i (2)
j = k (3)
The output would be:
a = b (1)
c = d (2)
d = e (3)
f = g (4)
h = i (5)
j = k (6)

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

olofos
Posts: 56
Joined: Tue Nov 24, 2009 10:37 pm

Reset number in eqnarray

Post by olofos »

The counter used by the eqnarray environment is called "equation". Also, you say that you want to reset the counter, not increase it by one, so sou need to use \setcounter instead of \stepcounter. Finally note that use of the eqnarray environment is generally discouraged.

In all, your example should look something like

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
a &= b\\
c &= d\\
d &= e
\end{align}

\setcounter{equation}{0}

\begin{align}
f &= g\\
h &= i\\
j &= k
\end{align}

\end{document}
hari_nathus
Posts: 1
Joined: Wed Sep 24, 2014 4:08 pm

Re: Reset number in eqnarray

Post by hari_nathus »

Very useful answer.
Post Reply