Two labels on the same equation line

I would like to have a compact set of two equations on the same line, each one labeled, with both labels on the far right. The code would be something like:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
We have
$$a = b \label{eqab} \quad \text{and} \quad c = d \label{eqcd}$$
and equations \ref{eqab} and \ref{eqcd} are nice.
\end{document}


(the positions of the labels within the source line would not matter), and would appear something like:

We have\vspace{3ex}

\hfill $a=b \quad \text{and} \quad c=d$ \hfill (1) and (2)\vspace{3ex}

and equations (1) and (2) are nice.


But putting two \label on the same line results in a Package amsmath Error:

Multiple \label... (the same for \tag).

• Welcome to SE! The result is expected. It is not allowed to have two labels for one equation. From your example I see, that you like to label two equation on one line. Why you not split them into two equations? How to do this has been showed many times on SE. – Zarko Feb 4 '16 at 18:10
• It's not \label that generates the equation number; so you'll get just one number and of course one \label suffices. – egreg Feb 4 '16 at 19:08

Maybe you looking for something like this:

\documentclass{article}
\usepackage{amsmath}

\usepackage[a4paper,showframe]{geometry}

\begin{document}
We have:

\noindent\begin{minipage}{0.4\textwidth}
$$a = b \label{eqab}$$
\end{minipage}%
\begin{minipage}{0.2\textwidth}\centering
and
\end{minipage}%
\begin{minipage}{0.4\textwidth}
$$c = d \label{eqcd}$$
\end{minipage}\vskip1em

Equations \ref{eqab} and \ref{eqcd} are nice. The same is valid for the next two:

\begin{subequations}\label{eq:3}
\noindent\begin{minipage}{0.4\textwidth}
$$a = b \label{eq:3a}$$
\end{minipage}%
\begin{minipage}{0.2\textwidth}\centering
and
\end{minipage}%
\begin{minipage}{0.4\textwidth}
$$c = d \label{eq:3b}$$
\end{minipage}\vskip1em
\end{subequations}

which are  \ref{eq:3a} and \ref{eq:3b}.
\end{document}

\documentclass{article}
\usepackage{amsmath,tabularx}
\begin{document}
We have

\noindent
\begin{tabularx}{\linewidth}{XXX}
$$a = b \label{eqab}$$
& $\text{and}$ &
$$c = d \label{eqcd}$$
\end{tabularx}

and equations \ref{eqab} and \ref{eqcd} are nice.
\end{document}


• Interesting that on a cell of tabularx we can use display . – Sigur Feb 4 '16 at 21:10
• This does require the use of \noindent\begin{tabularx} if you're using \textwidth or \linewidth... – Werner Feb 5 '16 at 0:07
• @Werner: yes, you are right – user2478 Feb 5 '16 at 5:17
• @Werner Why is that? – A.Ellett Feb 5 '16 at 5:41
• @A.Ellett: A tabular is like a block that starts a paragraph which is typically accompanied by a \parindent. Setting a block with a paragraph indent that has width \textwidth or \linewidth will be wider than the text block. Hence the use of \noindent. – Werner Feb 5 '16 at 6:04

This is expected, because it's not \label that generates the equation number.

If you really want two numbered equations on the same line, which I'd like to discourage, you can resort to minipages:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
We have
\begin{center}
\begin{minipage}[b]{.3\textwidth}
\vspace{-\baselineskip}
$$a = b \label{eqab}$$
\end{minipage}%
\hfill\hfill and\hfill
\begin{minipage}[b]{.3\textwidth}
\vspace{-\baselineskip}
$$c = d \label{eqcd}$$
\end{minipage}
\end{center}
and equations \ref{eqab} and \ref{eqcd} are nice.
\end{document}


If the label will always be (1) and (2) and if you will refer always both then you can make it a single label.

\documentclass{report}
\usepackage{amsmath}

\begin{document}
We have
$$a=b \quad \text{and} \quad c=d \tag*{(1) and (2)}\label{1and2}$$
and equations \ref{1and2} are nice.
\end{document}


Amsmath may specifically forbid more than one \label in an equation, but that doesn't mean one can't create another macro to perform the same task. Note: this version is not compatible with hyperref.

\documentclass{report}
\usepackage{amsmath}

\makeatletter
\newcommand{\steplabel}[1]% #1 = label name
{\refstepcounter{equation}%
\protected@write\@auxout{}{\string\newlabel{#1}{{\theequation}{\thepage}}}}
\makeatother

\begin{document}
We have
$$a=b \quad \text{and} \quad c=d \tag*{\steplabel{eqab}(\theequation) and \steplabel{eqcd}(\theequation)}$$
and equations \eqref{eqab} and \eqref{eqcd} are nice.
\end{document}