# How to create two series of align equations in the same document?

This question is similar to a previous question about how to create two series of numbered equations in the same document. However, the proposed solution doesn't work for my question, because it increments the counter once in the environment. Instead, I need a solution that works with the align environment. So, how can I work with two series of equation numbers using the align environment?

For example I need environments alignA and alignB that allow me to write:

\begin{alignA}
x &= 2*y \\
&= 3*z
\end{alignA}

\begin{alignB}
u &= 4*v \\
&= 5*w
\end{alignB}


That outputs equation numbers A1, A2, B1 and B2.

• Welcome to TeX.SX!. Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Apr 26 '14 at 14:53
• Hi Christian, the problem is the same that linked previous question but using multiline equations with align. I think that a good working example is the solution proposed by Jared Lo. – Daniel Hernández Apr 27 '14 at 14:32
• Normally users should not have to derive anything from the start. – user31729 Apr 27 '14 at 14:35

Here is more structured option via environment declaration

\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}

\makeatletter
\newcounter{qrr@oldeq}
\newcounter{qrr@oldsubeq}
\newcounter{qrr@realeq}

\newcounter{Bqrr@oldeq}
\newcounter{Bqrr@oldsubeq}
\newcounter{Bqrr@realeq}

\newenvironment{AlignA*}{% Consecutive subequations A
\setcounter{qrr@realeq}{\value{equation}}%
\let\theparentequation\theequation%
\patchcmd{\theparentequation}{equation}{parentequation}{}{}%
\setcounter{parentequation}{\numexpr\value{qrr@oldeq}-1}%
\setcounter{equation}{\value{qrr@oldsubeq}}%
\def\theequation{A-\arabic{equation}}%
\refstepcounter{parentequation}%
\ignorespaces
}{%
\setcounter{qrr@oldeq}{\value{parentequation}}%
\setcounter{qrr@oldsubeq}{\value{equation}}%
\setcounter{equation}{\value{qrr@realeq}}%
\ignorespacesafterend
}

\newenvironment{AlignA}{% Non consecutive subequations A
\refstepcounter{equation}%
\protected@edef\theparentequation{\theequation}%
\setcounter{parentequation}{\value{equation}}%
\setcounter{equation}{0}%
\def\theequation{A-\arabic{equation}}%
\ignorespaces
}{%
\setcounter{qrr@oldeq}{\value{parentequation}}%
\setcounter{qrr@oldsubeq}{\value{equation}}%
\setcounter{equation}{\value{parentequation}}%
\ignorespacesafterend
}

\newenvironment{AlignB}{% Non consecutive subequations B
\refstepcounter{equation}%
\protected@edef\theparentequation{\theequation}%
\setcounter{parentequation}{\value{equation}}%
\setcounter{equation}{0}%
\def\theequation{B-\arabic{equation}}%
\ignorespaces
}{%
\setcounter{Bqrr@oldeq}{\value{parentequation}}%
\setcounter{Bqrr@oldsubeq}{\value{equation}}%
\setcounter{equation}{\value{parentequation}}%
\ignorespacesafterend
}

\newenvironment{AlignB*}{% Consecutive subequations B
\setcounter{Bqrr@realeq}{\value{equation}}%
\let\theparentequation\theequation%
\patchcmd{\theparentequation}{equation}{parentequation}{}{}%
\setcounter{parentequation}{\numexpr\value{Bqrr@oldeq}-1}%
\setcounter{equation}{\value{Bqrr@oldsubeq}}%
\def\theequation{B-\arabic{equation}}%
\refstepcounter{parentequation}%
\ignorespaces
}{%
\setcounter{Bqrr@oldeq}{\value{parentequation}}%
\setcounter{Bqrr@oldsubeq}{\value{equation}}%
\setcounter{equation}{\value{qrr@realeq}}%
\ignorespacesafterend
}

\makeatother

\begin{document}

The AlignA environment goes from A-1 to A-n and if you use it again eq. counter resets
\begin{AlignA}
\begin{align}
\alpha\\
\beta\\
\gamma\\
\delta
\end{align}
\end{AlignA}
%\thesubA
The AlignB environment goes from B-1 to B-n and if you use it again eq. counter resets
\begin{AlignB}
\begin{align}
\alpha\\
\beta\\
\gamma
\end{align}
\end{AlignB}
The AlignA* environment goes from A-n to A-n+m and if you use it again eq. counter stay
\begin{AlignA*}
\begin{align}
\alpha\\
\beta\\
\gamma
\end{align}
\end{AlignA*}
The AlignB* environment goes from B-n to B-n+m and if you use it again eq. counter stay
\begin{AlignB*}
\begin{align}
\alpha\\
\beta\\
\gamma
\end{align}
\end{AlignB*}
A normal Equation
\begin{equation}
\mbox{other equation}
\end{equation}

\end{document}


![enter image description here] : http://i.stack.imgur.com/cIr3G.png

• This is exactly that I need! Also it helps me to understand how to use counters. – Daniel Hernández Apr 27 '14 at 14:24
• @JaredLo: Why another solution? Couldn't you provide it in the same answer? – user31729 Apr 27 '14 at 14:36

As I understand you first need to declare de environments "AlingA" and "AlingB" and a counter to them with \renewcomand

or try this (load ams math package)

\begin{subequations}
\renewcommand{\theequation}{A-\arabic{equation}}
\begin{equation}
A=y
\end{equation}
\begin{equation}
y=2
\end{equation}
\end{subequations}
\setcounter{equation}{0} % reset to 0 equation counter
\begin{subequations}
\renewcommand{\theequation}{B-\arabic{equation}}
\begin{equation}
B=2y
\end{equation}
\begin{equation}
y=2
\end{equation}
\end{subequations}

• So you can't inter-mix equations in this case right? – Trefex Apr 26 '14 at 16:42