Zwei Beschriftungen auf derselben Gleichungslinie

Zwei Beschriftungen auf derselben Gleichungslinie

Ich hätte gerne einen kompakten Satz von zwei Gleichungen in derselben Zeile, jede beschriftet, wobei beide Beschriftungen ganz rechts stehen. Der Code würde etwa so aussehen:

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

(die Positionen der Beschriftungen innerhalb der Quellzeile wären nicht wichtig) und würden etwa so aussehen:

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.

Wenn Sie jedoch zwei davon \labelin die gleiche Zeile setzen, tritt ein `Paket-amsmath-Fehler auf:

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

Antwort1

Vielleicht suchen Sie nach so etwas:

Bildbeschreibung hier eingeben

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

Antwort2

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

Bildbeschreibung hier eingeben

Antwort3

Dies ist zu erwarten, da es nicht \labeldas ist, was die Gleichungsnummer generiert.

Wenn Sie unbedingt zwei nummerierte Gleichungen in derselben Zeile haben möchten (was ich nicht empfehlen möchte), können Sie auf Miniseiten zurückgreifen:

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

Bildbeschreibung hier eingeben

Antwort4

Amsmath kann in einer Gleichung ausdrücklich mehr als eine Funktion verbieten \label, aber das bedeutet nicht, dass man kein weiteres Makro erstellen kann, um dieselbe Aufgabe auszuführen. Hinweis: Diese Version ist nicht mit Hyperref kompatibel.

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

verwandte Informationen