2

This question is related to this thread but is not a duplicate of it.

I'd like to label my first equation as (1^+) and my third equation as (1^-). The first part is easy, but if I \label that first equation, then try to use the label inside a \tag when I number the third equation, my third equation label is (1^{+-}) which of course I don't want. So I need to be able to save the number part of the first equation, without its superscript, then include that saved number in the \tag for the third equation. Here's an MWE of what goes wrong.

\documentclass[reqno]{amsart}
\begin{document}
\begin{align}
\refstepcounter{equation}
\tag{\theequation$\empty^+$}
\label{label}
f^+   = 3 \\
g     = 4 \\
\tag{\ref{label}$\empty^-$}
f^-   = -3 
\end{align}
\end{document}

2 Answers 2

2

this is probably cheating, since it uses a plain tex command ...

\documentclass[reqno]{amsart}
\begin{document}
\setcounter{equation}{1}
\xdef\plusminuseq{\number\theequation}
\begin{align}
\tag{\plusminuseq$^{+}$}
\label{label1}
f^+   = 3 \\
g     = 4 \\
\tag{\plusminuseq$^{-}$}
\label{label2}
f^-   = -3 
\end{align}
now, references to \eqref{label1} and \eqref{label2}
\end{document}

enter image description here

the \xdef is needed to "freeze" the value of \theequation. (there's most likely an equivalent latex command to do this, but i don't remember, and don't have time to look it up.)

2
  • Call it "core TeX". Commented Dec 19, 2017 at 15:00
  • I accepted @barbara_beeton's answer because it's more general. Dont see why on earth it would be considered cheating to use core TeX. If anybody else is interested, I made it general with \newcommand{\saveEqNum}[1]{ \xdef\saveEqNumXdef{\number\theequation} \newcommand{#1}{\saveEqNumXdef} } so now I can put \saveEqNum{\thisEquationNum} anywhere in the document
    – Leo Simon
    Commented Dec 19, 2017 at 18:58
2

Here is one way to do it.

\documentclass[reqno]{amsart}

\newcommand{\myformat}[1]% #1 = counter name
{\ifcase\value{#1}\or-\or\or+\else\fi}

\begin{document}
\begin{subequations}
\renewcommand{\theequation}{$\theparentequation^{\myformat{equation}}$}
\begin{align}
f^+   &= 3 \\
g     &= 4 \\
f^-   &= -3 
\end{align}
\end{subequations}
\end{document}

demo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .