# Customized cleveref

How can I customize the cleveref package such that when I type

$$A = B \label{eqn:test}$$

\cref{eqn:test}


then the output is

Eq. (1)

where Eq. is black and (1) is blue with hyperlink?

For those that like colourful links etc. ;-)

Label formats for individual counter types can be changed with \creflabelformat{counter type}{#2Y#3} where Y stands for some formatting code with should contain the parameter #1

#2 and #3 are used by the hyperanchors and must appear in this order -- do not change or remove this!

As can be detected from the screen shot the cross-reference format for the table counter is not affected by this.

\documentclass{article}

\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{hyperref}

\usepackage{cleveref}

\creflabelformat{equation}{#2{\color{blue}(#1)}#3}

\begin{document}

$$A = B \label{eqn:test}$$
\begin{table}
\caption{Foo} \label{foolabel}
\end{table}
\clearpage

\cref{eqn:test} or \Cref{eqn:test} but \cref{foolabel}\dots
\end{document}


• It's probably a good idea to pass the options colorlinks=true and linkcolor=blue directly to the hyperref package. – Mico Sep 8 '16 at 15:08
• @Mico: That's what I had in mind, but it would change any links then, wouldn't it? I suspect that the table reference is blue too then... – user31729 Sep 8 '16 at 15:09
• Indeed, the linkcolor option pertains to all cross-references, not just to cross-references to equations. But then, I certainly believe it's good practice to use only one color for all cross-references n a document -- unless one is going for either a "holiday card" or a "ransom note" look... – Mico Sep 8 '16 at 15:43
• @Mico: I can do this ... but the customer's always right, isn't he/she? ;-) – user31729 Sep 8 '16 at 15:56
• @Mico: Well, the customer asked for the equation reference, and that's he just got ... anything else will cost extra fee ;-) – user31729 Sep 9 '16 at 10:09