# Add a $\pm$ to the label in order to distinguish two different cases

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

$$\label{eq1} f^\pm(x)=\ldots$$


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?

• 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

Use \tag and manually step the equation counter.

Explanation: 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
$$\label{double} f^{\pm}(x)=\dots \tag{\theequation^{\pm}} \stepcounter{equation}$$
We also have a normal equation
$$\label{single} g(x)=\dots$$
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.

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
$$\label{double}\pmnumber f^{\pm}(x)=\dots$$
We also have a normal equation
$$\label{single} g(x)=\dots$$
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

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}

$$\label{eqi}\tagpm f^\pm(x)=\ldots$$

\eqref{eqi}

\eqrefp{eqi}

\eqrefm{eqi}

\end{document}


\documentclass{article}

\usepackage{amsmath}

\begin{document}

zzz
$$\label{zzz} 1=2$$

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

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

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

see \eqref{+case} and \eqref{-case}
\end{document}