[Tex/LaTex] How to combine hyperref and eqref

alignhyperreflabels

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[colorlinks=true,linkcolor=green]{hyperref}
\begin{document}
\begin{align} \label{test}
a+b=c
\end{align}
\eqref{test}
\end{document}

How can I combine hyperref and eqref such that the braces () are also green and clickable and not only the 1?

Best Answer

\eqref uses \ref for the equation number, therefore \ref is the link, the surrounding parentheses are not part of the link. The following example redefines \eqref to include the parentheses into the link:

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[colorlinks=true,linkcolor=green]{hyperref}

\makeatletter
\renewcommand*{\eqref}[1]{%
  \hyperref[{#1}]{\textup{\tagform@{\ref*{#1}}}}%
}
\makeatother

\begin{document}
\begin{align} \label{test}
a+b=c
\end{align}
\eqref{test}
\end{document}

Result

BTW: Instead of "green" I would use something darker ("darkgreen", ...) for a better contrast to the usual white background.

Related Question