5

I have an equation and I would like to label it in order to refer to it later on in the text, say

\begin{equation}\label{eq1}
 f^\pm(x)=\ldots 
 \end{equation}

This labels the equation with, say, (1) and referring to this equation by

In the equation (\ref{eq1}), we have...

gives me something like

In the equation (1), we have...

But since the equation includes two different cases f^+ and f^-, I would like the label name to be (1\pm). How can I do that?

  • 1
    Welcome to TeX, SE. An equation can have only one label. If you like to distinguish two cases, than you need to write more equations. – Zarko Jul 23 at 10:28
4

Use \tag and manually step the equation counter.

Explanation: \begin{equation} steps up the counter; however \tag will cause the counter to be stepped down.

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\begin{document}

We have a double equation
\begin{equation}\label{double}
f^{\pm}(x)=\dots
\tag{\theequation$^{\pm}$}
\stepcounter{equation}
\end{equation}
We also have a normal equation
\begin{equation}\label{single}
g(x)=\dots
\end{equation}
We can reference equation~\eqref{double} and equation~\eqref{single}.

How about~{\let\pm=+\eqref{double}} and {\let\pm=-\eqref{double}}?

\end{document}

Note: twocolumn is just to make a smaller picture.

enter image description here

An abstracted version that also works with hyperref.

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{hyperref}

\protected\def\hpm{\ensuremath{^\pm}}
\newcommand{\pmnumber}{\tag{\theequation\hpm}\stepcounter{equation}}
\newcommand{\eqrefp}[1]{{\let\pm=+\eqref{#1}}}
\newcommand{\eqrefm}[1]{{\let\pm=-\eqref{#1}}}

\begin{document}

We have a double equation
\begin{equation}\label{double}\pmnumber
f^{\pm}(x)=\dots
\end{equation}
We also have a normal equation
\begin{equation}\label{single}
g(x)=\dots
\end{equation}
We can reference equation~\eqref{double} and equation~\eqref{single}.

How about~\eqrefp{double} and \eqrefm{double}?

\end{document}
  • Thats really nice, thank you! – Labelname Jul 23 at 11:36
2

You can cheat by redefining \pm while referencing:

\documentclass{article}

\usepackage{amsmath}

\newcommand*\tagpm{\stepcounter{equation}\tag{\theequation\(\pm\)}}
\newcommand*\eqrefp[1]{{\def\pm{+}\eqref{#1}}}
\newcommand*\eqrefm[1]{{\def\pm{-}\eqref{#1}}}

\begin{document}

\begin{equation}\label{eqi}\tagpm
  f^\pm(x)=\ldots 
\end{equation}

\eqref{eqi}

\eqrefp{eqi}

\eqrefm{eqi}

\end{document}

MWE output

0

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}


zzz
\begin{equation}\label{zzz}
 1=2
 \end{equation}

pm
\begin{equation}\label{pmcase}% dot use numbers in label
 f^\pm(x)=\ldots 
 \end{equation}

plus
\begin{equation}\label{+case}% dot use numbers in label
 f^+(x)=\ldots \tag{\theequation+}
 \end{equation}

pm
\begin{equation}\label{-case}% dot use numbers in label
 f^-(x)=\ldots  \tag{\theequation+}
 \end{equation}

see \eqref{+case} and \eqref{-case}
\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.