[Tex/LaTex] Create \eqref* (\eqref without link, i.e. starred eqref)

amsmathcross-referencingequationshyperrefitalic

I want to create a command \eqref*, which is the same like \eqref, but without a clickable link.
There are similar commands for \ref (\ref*) and \autoref (\autoref*) which achieve this behaviour, but not for \eqref.

\newcommand{\myeqref}[1]{(\ref*{#1})}

Would work, but I don't like the naming, and there is an additional problem: \eqref writes numbers upright even in italic math environment, \ref doesn't do this.

Any help is appreciated.

[ Edit: for search engines: eqref, eqref*, eqrefstar, starred eqref, eqrefasterisk, asterisked eqref, eqref star, eqref asterisk ]

Best Answer

Here's a solution that borrows from Joseph Wright's LaTeX3 solution to Defining starred versions of commands (* macro)

% arara: pdflatex
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}

\let\oldeqref\eqref
\makeatletter
\RenewDocumentCommand\eqref{s m}{%
  \IfBooleanTF#1%
  {\textup{\tagform@{\ref*{#2}}}}% If a star is seen
  {\oldeqref{#2}}%                 If no star is seen
}
\makeatother

\usepackage{hyperref}
\begin{document}
\begin{equation}
a=b \label{1}
\end{equation}

\begin{itemize}
  \item starred version: \eqref*{1} 
  \item unstarred version: \eqref{1}
\end{itemize}

\end{document}
Related Question