[Tex/LaTex] How to use the command \autoref to implement the same effect when use the command \eqref

cross-referencingequationshyperref

For example, the first equation of Section 1 in a tex file is numbered in the form (1.1), When we use the commands \autoref and \eqref for referring it, the compiled pdf file will show Equation 1.1 and (1.1), respectively.

Now the problem is that how can I just use the command \autoref to implement the same effect when use the command \eqref.

By the way, please do not use the package cleveref!

Best Answer

Macro \autoref of package hyperref calls \<counter>autorefname followed by a unbreakable space ~ and the number. Finally \null is appended (some inheritance from LaTeX). This can be used to define \equationautorefname as macro that catches the equation number in a parameter.

\documentclass{article}
\usepackage{amsmath,hyperref}
\hypersetup{colorlinks=true}

\def\equationautorefname~#1\null{%
  Equation~(#1)\null
}

\begin{document}
\begin{equation}\label{eq:pythagoras}
a^2+b^2=c^2\,.
\end{equation}
As may be seen in equation \eqref{eq:pythagoras} or, alternatively,
in \autoref{eq:pythagoras}, \ldots
\end{document}

Result with red links