5

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.

5

Try

\documentclass{article}
    \usepackage{amsmath}

\newcounter{subeq}
\newcommand{\stags}{
\addtocounter{equation}{+1}
\setcounter{subeq}{0}
                    }
\newcommand{\stag}{%
    \addtocounter{subeq}{1}%
    \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.

enter image description here

  • Works like a charm, but any idea on how to reference the numbering without the 'a', 'b'? (I'll add an edit) – HericDenis Aug 9 '15 at 17:49
  • 1
    As I mentioned in my answer: with defining new counter. I will show this in edit of mine answer (later in evening). – Zarko Aug 9 '15 at 18:36
  • @HericDenis,I upgrade my first solution. Look, if it is what you looking for. – Zarko Aug 9 '15 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... – HericDenis Aug 9 '15 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. – HericDenis Aug 9 '15 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.