I am trying to change the link color made with \eqref to be different from the other \ref links. I have this


But it only changes the color of the number in the equation. Could you help me with this?

Thank you!

closed as unclear what you're asking by user31729, Stefan Pinnow, Bobyandbob, Mensch, Andrew Dec 8 '17 at 23:28

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to TeX.se. Instead of posting code fragments, please put your fragment into a complete, compilable document that starts with \documentclass{...} and ends with \end{document} that shows the problem. – Alan Munn Nov 13 '17 at 2:35
  • 1
    I’ve not tested it, but I’d say that your code snippet changes the color of all equation numbers, not only when they appear as a reference. – GuM Nov 13 '17 at 2:54
  • I forgot: Welcome to TeX.SX! – GuM Nov 13 '17 at 3:01
  • have you tried applying the color to only the redefinition of \eqref? – barbara beeton Nov 13 '17 at 3:10
  • how do I do that @barbarabeeton ? – Natalia Nov 13 '17 at 4:10

If all parts of a reference should appear in a specific color, the command \color in a group in conjunction with \hypersetup for linkbordercolor comes into action.

Store the definition of \eqref first in, say, \@msm@th@ref, then use


in a redefined \eqref macro.

This will use violet as color for parentheses, reference value and link.

Another option is to use mathtools and \newtagform, this will change the number of the equation in place however. (This option is not shown here)

(About the usage of \leavevmode see the comment by egreg below. Thanks to him to point to this possible issue).





\section{Foo} \label{section::foo}
a \equiv a\label{eq::foo}

See the important \eqref{eq::foo} but look also at \ref{section::foo}

enter image description here

  • 1
    Just for safety, there should be \leavevmode before \color{violet}. – egreg Nov 13 '17 at 12:56
  • @egreg: Hm, I missed this feature so far. Doesn't \color work in \vmode? – user31729 Nov 13 '17 at 12:57
  • It can be issued in vertical mode, but when it's used for typesetting a specific piece of text, it's safer when a paragraph has already begun. – egreg Nov 13 '17 at 13:00
  • @egreg: Thanks, I added it with a reference to your explanation – user31729 Nov 13 '17 at 13:02
  • Neither of these options worked for me, looking at the error that I got: Undefined control sequence. <inserted text> ...r[]{page}\glsnumberformat\@nil I think It must have something to do with the \gls command in the glossaries package \usepackage{glossaries} – Natalia Nov 14 '17 at 0:07

You just redefine the \eqref command as mentioned below and insert the color as you want.






This is a text \eqref{eq1}
  • 3
    11 months, 44 answers. Congratulations. Unfortunately, you still have no clue how to mark up code and rely on others :-( – Johannes_B Nov 13 '17 at 6:15
  • Solution matters, formatting doesn't. :) – Saravanan Nov 13 '17 at 6:17
  • 2
    Wrong. Both matter. That is why we are using LaTeX (& Co.). – AlexG Nov 13 '17 at 8:12
  • 1
    Actually that only changes the color of the parenthesis, while leaving the color of the text inside the same of the other links – Natalia Nov 13 '17 at 8:20
  • @Natalia This answer answers the question you asked perfectly fine. What you did not mention, was the use of hyperref along with the colorlinks option. I was thinking that you might be speaking about this specifically, but it was not clear. Hence, i just left an upvote to this answer. – Johannes_B Nov 13 '17 at 17:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.