autoref and braces around equation number
If you're not willing -- or allowed! -- to modify some lower-level TeX macros, you could still achieve your objective of getting parentheses placed automatically around cross-referenced equation numbers by (a) executing the following instruction in the preamble:
\usepackage[nameinlink,capitalize]{cleveref}
and (b) using \cref
instead of \autoref
to generate cross-references.
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink,capitalize]{cleveref}
\setlength\textwidth{3in} %% just for this example
\begin{document}
\begin{equation}\label{eq:pythag}
a^2+b^2=c^2
\end{equation}
A cross-reference to \cref{eq:pythag} via \verb+\cref+.
\end{document}
For more on various cross-referencing packages and, in particular, the capabilities of hyperref
and cleveref
in this regard, see the posting Cross-reference packages: which to use, which conflict?
Addendum: If you must use \autoref
and want parentheses placed around the cross-referenced equation numbers, it's necessary to redefine the macro \theequation
. Assuming you also use the amsmath
package, it's also necessary to modify the auxilliary macro \tagform@
. The following MWE shows how this may be done. (The directives \makeatletter
and \makeatother
are needed because some of the code involves the "special" character @
.)
A side remark: If the journal's guidelines prohibit the use of \def
in your document, using \renewcommand
is probably frowned upon as well. If that's the case, you should probably use \cref
instead of \autoref
to create cross-references to equations...
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\let\oldtheequation\theequation
\renewcommand\tagform@[1]{\maketag@@@{\ignorespaces#1\unskip\@@italiccorr}}
\renewcommand\theequation{(\oldtheequation)}
\makeatother
\usepackage[colorlinks]{hyperref}
\renewcommand{\equationautorefname}{Eq.}
\usepackage[nameinlink,capitalize]{cleveref}
%% Need to undo the effect of redefinition of "\theequation" to use \cref:
\creflabelformat{equation}{#2\textup{#1}#3} % No more parentheses around "#1"
\setlength\textwidth{3in} %% just for this example
\begin{document}
\begin{equation}\label{eq:pythag}
a^2+b^2=c^2
\end{equation}
A cross-reference to \autoref{eq:pythag} via \verb+\autoref+.
A cross-reference to Eq.~\eqref{eq:pythag} via \verb+\eqref+.
A cross-reference to \cref{eq:pythag} via \verb+\cref+.
\end{document}
The following example defines \myeqref
, which prepends the equation reference by Eq.~
and includes the prefix and the parentheses into the link. The prefix can be overwritten by the first optional argument.
The \autoref
name macros do not have access to the counter, thus the following definition of \equationautorefname
is just a dirty hack.
\documentclass[a5paper]{article}
\usepackage{amsmath}
\usepackage{hyperref}
\newcommand*{\myeqref}[2][Eq.~]{%
\hyperref[{#2}]{#1(\ref*{#2})}%
}
\def\equationautorefname#1#2\null{%
Eq.#1(#2\null)%
}
\begin{document}
\begin{equation}
\label{eq:einstein}
E=mc^2
\end{equation}
References: \myeqref{eq:einstein} and \myeqref[equation~]{eq:einstein}.\\
Reference: \autoref{eq:einstein}.
\end{document}