# Align equations with multiple subequation groups

I usually use the subequations environment with a nested alignso I can have nicely aligned equations with that neat 1a, 1b, 1c, etc. numbering and that's fine. But now I would want to still align those multiple equations but have different groups, like:

x = a + v     (1)
y = w + bc   (2a)
w = z^2 + g  (2b)
q = o + pq   (3a)
r = s^t      (3b)


I used just random stuff for the sake of this question. So, what I want to is align all this equations using the same technique (& characters) we use on align environment and keep that separate subequation groups. Is it possible?

EDIT

So with the help of @Zarko the alignment was solved (that's actually all I asked for) but, what about referencing the equations without the letters? I need something like this:

The equations \ref{eq:first} to \ref{eq:last} show something interesting:

\begin{align}
x &= a + v   \label{eq:first}               \\
y &= w + bc   \tag{\addtocounter{equation}{1}\theequation a}      \\
w &= z^2 + g  \tag{\theequation b}      \\
q &= o + pq \tag{\addtocounter{equation}{1}\theequation a} \label{eq:last}\\
r &= s^t \tag{\theequation b}
\end{align}


in this case, \ref{eq:last} will turn into !3aand I need just 3.

Try

\documentclass{article}
\usepackage{amsmath}

\newcounter{subeq}
\newcommand{\stags}{
\setcounter{subeq}{0}
}
\newcommand{\stag}{%
\theequation\alph{subeq}%
}

\begin{document}
\begin{align}
x &= a + v                       \label{eq:1}    \\
\stags
y &= w + bc     \tag{\stag}      \label{eq:2a}   \\
w &= z^2 + g    \tag{\stag}      \label{eq:2b}   \\
q &= o + pq                      \label{eq:3}    \\
\stags
y &= w + bc     \tag{\stag}      \label{eq:4a}   \\
w &= z^2 + g    \tag{\stag}      \label{eq:4b}

\end{align}
Test of referencing: \eqref{eq:1}, \eqref{eq:2a}, \eqref{eq:2b}, \eqref{eq:3}, \eqref{eq:4a} and \eqref{eq:4b}.
\end{document}


Edit: The first solution I upgrade with counter for sub equations and define some new commands which a bit simplify the writing of equations tag. Solution is still rude, but it works. Also works referencing ... but not as OP desired. It is (so far) not possible to use two tags nor two labels for one equation, so with this solution you can not references sub equations with common references.

Now I also further simplify the MWE.

• Works like a charm, but any idea on how to reference the numbering without the 'a', 'b'? (I'll add an edit) Aug 9, 2015 at 17:49
• As I mentioned in my answer: with defining new counter. I will show this in edit of mine answer (later in evening). Aug 9, 2015 at 18:36
• @HericDenis,I upgrade my first solution. Look, if it is what you looking for. Aug 9, 2015 at 21:01
• Not actually, I would like to reference equations 4a and 4b and just 4 as well, like when you make this: \begin{subequations} \label{eq:1} \begin{align} x&=y \label{eq:1a}\\ z&=w \label{eq:1b} \end{align}\end{subequations}. Then when I use \ref{eq:1} I get 1, \ref{1a} get 1a and so on... Aug 9, 2015 at 22:24
• I think the way to go is to create a hidden tag (which I don't know how to make) using only \theequation, which I believe is how subequations manage to do it. Aug 9, 2015 at 22:37