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`).
Werner
  • 603,163
gilgron31
  • 83
  • 1
  • 4

5 Answers5

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}
Zarko
  • 296,517
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 04 '16 at 21:10
  • 1
    This does require the use of \noindent\begin{tabularx} if you're using \textwidth or \linewidth... – Werner Feb 05 '16 at 00:07
  • @Werner: yes, you are right –  Feb 05 '16 at 05:17
  • @Werner Why is that? – A.Ellett Feb 05 '16 at 05: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 05 '16 at 06:04
  • @Werner Argh. Something must have been wrong with my eyes last night. I could have sworn that your comment had read something different. I managed to completely misunderstand it. I really should stop trying to think after a certain hour. Sigh. – A.Ellett Feb 05 '16 at 13:30
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

egreg
  • 1,121,712
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

Sigur
  • 37,330
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}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120