[Tex/LaTex] Customize the way eqref works with tags

amsmathcross-referencingequations

I'd like to have a version of \eqref that treats equations with a custom tag differently from the usual numbered equation. In particular, if I assign a tag to an equation, I'd like \eqref not to put parens around the reference. Below is an example.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
   \label{eq:normal}
   a = b
\end{equation}
\begin{equation}
   \label{eq:tagged}
   y = max\{1,x\} \tag{$P(x)$}
\end{equation}

Equations \eqref{eq:normal} will display as "(1)" (i.e., with parens)
and \eqeref{eq:tagged} will display as "$P(x)$" (i.e., without parens).

\end{document}

How would I modify the \eqref command?

Best Answer

don't use \eqref. just use \ref. the main purpose of \eqref is to put parens around tags in accordance with ams style. it also ensures that they're set in upright type, which is not done with \ref, so you may still want to apply \upshape or \textup, although that isn't a problem as long as you are explicitly treating the tag as math.

Addendum: you can just equate \myeqref to \ref so that references to the explicitly-tagged displays can easily be found:

\newcommand\myeqref[1]{\ref{#1}}

although it's possible to adapt the amsmath definition to do what you want, it's more than i have time to unravel just now, especially when there's a simpler approach.