[Tex/LaTex] Numbering a set of horizontally distributed equations

alignamsmathnumbering

Having different horizontally distributed equations inside an align environment, only lines are numbered, but not individual equations.

How can the left equations be numbered using subequations? See also the question side-by-side equations, with equation numbers for each

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \begin{subequations}
    \begin{align} 
      %\label{a}
        a &= a ,&
      \label{b}
        b &= b ,\\
      %\label{c}
        c &= c ,&
      \label{d}
      d &= d .
    \end{align}
  \end{subequations}
\end{document}

enter image description here

The solution should be able to either:

  • attach a label to the left equations, or
  • modify the labels on the right to read (1a,b) and (1c,d)

I couldn't find anything in the documentation of amsmath or other packages.

Best Answer

You can define a custom nbytwosubequations environment to number subequations two by two, line by line.

Caution: this solution assumes that each line contains two subequations; the numbering will be wrong if one line contains only one subequation.

enter image description here

\documentclass{article}

\usepackage{amsmath}

\makeatletter
\newenvironment{nbytwosubequations}{%
  \refstepcounter{equation}%
  \protected@edef\theparentequation{\theequation}%
  \setcounter{parentequation}{\value{equation}}%
  \setcounter{equation}{0}%
  \def\theequation{%
    \theparentequation\alph{equation}%
    \addtocounter{equation}{1},\alph{equation}%
  }%
  \ignorespaces
}{%
  \setcounter{equation}{\value{parentequation}}%
  \ignorespacesafterend
}
\makeatother

\begin{document}

  \begin{nbytwosubequations}
    \begin{align} 
      a &= a,  &
      b &= b   \label{ab} \\
      c &= c,  &
      d &= d. \label{cd}
    \end{align}
  \end{nbytwosubequations}

\end{document}