# 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

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

• 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 '19 at 10:28

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

\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}{{\let\pm=+\eqref{#1}}}
\newcommand{\eqrefm}{{\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}.

\end{document}

• Thats really nice, thank you! – Labelname Jul 23 '19 at 11:36

You can cheat by redefining \pm while referencing:

\documentclass{article}

\usepackage{amsmath}

\newcommand*\tagpm{\stepcounter{equation}\tag{\theequation$$\pm$$}}
\newcommand*\eqrefp{{\def\pm{+}\eqref{#1}}}
\newcommand*\eqrefm{{\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}  \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}