6

How can I number a set of equations separately from another set?

For example, if we have a file with this contents:

\documentclass{report}

\usepackage{amsmath}

\begin{document}

\begin{equation}
\label{Equation:1}
0+0=0
\end{equation}

\begin{equation}
\label{Result:1}
1*1=1
\end{equation} 

\begin{equation}
\label{Equation:2}
0+1=1
\end{equation}

\begin{equation}
\label{Result:2}
1*2=2
\end{equation}

Equation \ref{Equation:1} and Equation \ref{Equation:2}.
Result \ref{Result:1} and Result \ref{Result:2}.

\end{document}

How to number the Equations separately from the Results?

In this example the output is:

Equation 1 and Equation 3. Result 2 and Result 4.

but I would like:

Equation 1 and Equation 2. Result 1 and Result 2.

How can I do this?

What's the best way to do this?

egreg
  • 1,121,712
GarouDan
  • 3,291

2 Answers2

6

You can define an environment where the equation counter is replaced by the result counter.

\documentclass{report}
\usepackage{amsmath}
\newcounter{result}
%\renewcommand{\theresult}{R-\arabic{result}}

\makeatletter
\newcommand{\changeequationintoresult}{%
  \let\c@equation\c@result\let\theequation\theresult}
\makeatletter

\newenvironment{results}{\changeequationintoresult}{}

\begin{document}

\begin{equation}
\label{Equation:1}
0+0=0
\end{equation}

\begin{results}
\begin{equation}
\label{Result:1}
1*1=1
\end{equation} 
\end{results}

\begin{equation}
\label{Equation:2}
0+1=1
\end{equation}

\begin{results}
\begin{equation}
\label{Result:2}
1*2=2
\end{equation}
\end{results}

Equation \ref{Equation:1} and Equation \ref{Equation:2}.
Result \ref{Result:1} and Result \ref{Result:2}.

\end{document}

If you need only the equation environment, you can define a new environment, say requation:

\newenvironment{requation}
  {\changeequationintoresult\equation}
  {\endequation}

and say

\begin{requation}
\label{Result:1}
1*1=1
\end{requation} 

instead of the more complicated double environment. In a similar way also the other amsmath environment can be treated.

egreg
  • 1,121,712
  • This works fine. Very interesting, thx. Can you point a link to learn more about this enviroments and new commands? – GarouDan Nov 25 '11 at 23:20
4

The best way is to use subequations from amsmath.

\documentclass{report}

\usepackage{amsmath}

\begin{document}

\begin{subequations}
\begin{equation}
\label{eq:foo}
0+0=0
\end{equation}

\begin{equation}
\label{re:foo}
1*1=1
\end{equation}
\end{subequations}

\begin{subequations}
\begin{equation}
\label{eq:bar}
0+1=1
\end{equation}

\begin{equation}
\label{re:bar}
1*2=2
\end{equation}
\end{subequations}

Equation \ref{eq:foo} and Equation \ref{eq:bar}.
Result \ref{re:foo} and Result \ref{re:bar}.

\end{document}

It is different with your code. But will be useful.

Leo Liu
  • 77,365
  • Can we use the first set of equations without a and the second without b?

    This is because the first is my equations, but in my document I need call several results obtained before, so I'd like enumerate them. If I enumerate the main equations using this a will be strange. I think if we can use this subequations, but no putting this a and b and still keeping the order of equations and results will work fine.

    – GarouDan Nov 25 '11 at 22:41
  • @GarouDan: Yes, we can. Just redefine the \theequation which is explained in amsldoc. Personally I don't like ambigous numbers, so I didn't provide what you require on purpose. – Leo Liu Nov 26 '11 at 07:00