7

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
\begin{equation}
a = b \label{eqab} \quad \text{and} \quad c = d \label{eqcd}
\end{equation}
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`).
  • 1
    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
11

Maybe you looking for something like this:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\usepackage[a4paper,showframe]{geometry}

\begin{document}
We have:

    \noindent\begin{minipage}{0.4\textwidth}
\begin{equation}
a = b \label{eqab}
\end{equation} 
    \end{minipage}%
    \begin{minipage}{0.2\textwidth}\centering
    and 
    \end{minipage}%
    \begin{minipage}{0.4\textwidth}
\begin{equation}
c = d \label{eqcd}
\end{equation}
    \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}
\begin{equation}
a = b \label{eq:3a}
\end{equation}
    \end{minipage}%
    \begin{minipage}{0.2\textwidth}\centering
    and
    \end{minipage}%
    \begin{minipage}{0.4\textwidth}
\begin{equation}
c = d \label{eq:3b}
\end{equation}
    \end{minipage}\vskip1em
\end{subequations}

which are  \ref{eq:3a} and \ref{eq:3b}.
    \end{document}
4
\documentclass{article}
\usepackage{amsmath,tabularx}
\begin{document}
We have

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

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

enter image description here

  • Interesting that on a cell of tabularx we can use display \[ \]. – Sigur Feb 4 '16 at 21:10
  • 1
    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
  • 1
    @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
2

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}
\begin{equation}
a = b \label{eqab}
\end{equation}
\end{minipage}%
\hfill\hfill and\hfill
\begin{minipage}[b]{.3\textwidth}
\vspace{-\baselineskip}
\begin{equation}
c = d \label{eqcd}
\end{equation}
\end{minipage}
\end{center}
and equations \ref{eqab} and \ref{eqcd} are nice.
\end{document}

enter image description here

1

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
\begin{equation}
a=b \quad \text{and} \quad  c=d  \tag*{(1) and (2)}\label{1and2}
\end{equation}
and equations \ref{1and2} are nice.
\end{document}

enter image description here

1

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
\begin{equation}
a=b \quad \text{and} \quad c=d
\tag*{\steplabel{eqab}(\theequation) and \steplabel{eqcd}(\theequation)}
\end{equation}
and equations \eqref{eqab} and \eqref{eqcd} are nice.
\end{document}

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.