How can I have different colors for \ref{}
for figures and equations? My figures have label \label{fig:name}
whereas equations are just \label{name}
. Is there a way I can set the color to be different depending on whether the argument has a "fig:
"?
[Tex/LaTex] \ref different colors for figures, equations, etc
colorcross-referencing
Related Question
- [Tex/LaTex] cancel with different colors
- [Tex/LaTex] Distinguishing \ref and \cref through different colors
- [Tex/LaTex] Is it possible to customize the colors of TexStudio itself (menus, toolbars, etc)
- [Tex/LaTex] How to refer to a label in LaTeX
- [Tex/LaTex] Different link colors for citeauthor and cite commands
Best Answer
Please look for a non-
cleveref
version at the end of the answer.The
cleveref
package allows for versatile configurations of the cross-reference format, with\crefformat{figure}{#2#1#3}
where#2
and#3
are reserved for hyperanchor settings and should not be interchanged, whereas#1
contains the content to be typeset, so font switches or\color
commands are possible here.Version with the traditional
p@figure
etc. cross-reference format:The output is basically the same as in the screen shot from the other version, hyperlink frames are not shown in the image.