# Numbering a set of horizontally distributed equations

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}


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.

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.

\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}%
}%
\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}


You can use minipages:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\noindent\begin{subequations}
\begin{minipage}{.5\textwidth}
\begin{align}
\label{a}
a &= a, \\
\label{c}
c &= c ,
\end{align}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\begin{align}
\label{b}
b &= b ,\\
\label{d}
d &= d .
\end{align}
\end{minipage}
\end{subequations}

\end{document}


Here's another option, adapted from an example from mathmode; numbering now follows the desired sequence:

\documentclass{article}
\usepackage{amsmath}

\newcounter{mySubCounter}
\newcommand{\foureqn}[8]{%
\setcounter{mySubCounter}{0}
\let\OldTheEquation\theequation%
\renewcommand{\theequation}{\OldTheEquation\alph{mySubCounter}}%
\noindent%
\begin{minipage}{.5\textwidth}
\begin{align}
\refstepcounter{mySubCounter}
#1 &= #2 \label{sub\theequation}\\
#5 &= #6 \label{sub\theequation}
\end{align}
\end{minipage}%
\begin{minipage}{.49\textwidth}
\begin{align}
#3 &= #4 \label{sub\theequation} \\
#7 &= #8 \label{sub\theequation}
\end{align}
\end{minipage}\par\medskip%
\let\theequation\OldTheEquation}

\begin{document}

Some references: \eqref{sub1a}, \eqref{sub1b}, \eqref{sub1c}, and~\eqref{sub1d}

\foureqn{a}{a+b,}{b+c}{b,}{d+c+e}{c,}{d}{d.}

Some other references: \eqref{sub2a}, \eqref{sub2b}, \eqref{sub2c}, and~\eqref{sub2d}

\foureqn{p+q}{r,}{s+t+u}{v+w,}{x}{y+z,}{z}{z.}

\end{document}


Each subequation has an automatic assigned label for cross-referencing; the label is of the form sub<number>, where <number> is the string used to number the subequation.

• The numbering doesn't match. I think the OP wants the first two on the first line and the last two on the second line, which is a bit trickier. – jubobs May 6 '13 at 14:59
• Ok, haven't thought about minipage command. Nice solution. Still - as @Jubobs says - the numbering goes vertically first in your example instead of horizontally. I fear I can't simply modify your solution by using horizontal aligns, as then the vertical alignment is not maintained any more. Any ideas how to fix that?? – jjdb May 6 '13 at 15:03
• @jjdb I added another option to my answer. – Gonzalo Medina May 6 '13 at 15:17
• @jjdb new update. Alignment and numbering are now OK. – Gonzalo Medina May 6 '13 at 15:27
• @GonzaloMedina Thanks for the update. I see the labels are inside the command definition. Can your solution be used various times inside an document, or is it needed to introduce a new command for each subequations? – jjdb May 7 '13 at 13:28

Not straightforward input, but it seems to work; in the image I added a vertical rule to show the middle of the page. Not perfect, either, but in my opinion this is not so good an idea.

\documentclass{article}
\usepackage{amsmath,lipsum}

\makeatletter
\newcommand{\leftlabel}[1]{&&
\refstepcounter{equation}\ltx@label{#1}%
\tagform@{\theequation}&&}
\makeatletter

\begin{document}
\lipsum[2]
\begin{subequations}
\begin{flalign}
&&a &= a,\leftlabel{a} & b &= b \label{b} &&\\
&&c &= c,\leftlabel{c} & d &= d \label{d} &&
\end{flalign}
\end{subequations}

\end{document}


• Just to clarify: what does " this" refer to in "this is not so good an idea"? Your solution or the OP's desired output? – jubobs May 6 '13 at 15:42
• @Jubobs The OP's desired output: associating an equation to its number is not at all immediate. – egreg May 6 '13 at 15:45
• Yes, it's more difficult to parse than four subequations, each on its own line. – jubobs May 6 '13 at 15:46
• I agree on that. I actually favor the second requested solution, which has also been answered by @Jubobs – jjdb May 6 '13 at 16:21
• @jjdb Yes, it may not be problematic all the time; it's a case-by-case thing. My tip would just be: avoid any opportunity to confuse your readers :) – jubobs May 6 '13 at 21:17