14

How can I make cleveref output (1) instead of eq. (1) when referencing equations only?

  • Just use \eqref (needs amsmath). – egreg Jul 2 '13 at 20:42
  • 3
    Um..., I might want to change my style later, isn't that what cleveref is meant for? Just want to be consistent. Thanks. – drozzy Jul 2 '13 at 20:50
18

Use \crefformat (notice that the same formatting can be achieved simply using \eqref from amsmath):

\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}

\crefformat{equation}{(#2#1#3)}

\begin{document}
\ref{eq:test}\eqref{eq:test}\cref{eq:test}

\begin{equation}
\label{eq:test}
a=b.
\end{equation}

\end{document}

enter image description here

You might also want to use a similar formatting for a range:

\crefrangeformat{equation}{(#3#1#4) to~(#5#2#6)}

and for multiple references, with the "and" between them (e.g. (1), (2) and (3)).:

\crefmultiformat{equation}{(#2#1#3)}%
{ and~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}

NOTE: In crefmultiformat spaces are important.

Both examples were taken from official doc, and eq part simply removed.

  • Ah, great tip on range format. I missed that one. Thanks a bunch! – drozzy Jul 2 '13 at 20:57
  • 2
    Added crefmultiformat to your answer, hope you don't mind :-) – drozzy Jul 6 '13 at 1:14
  • @drozzy by no means :-) Thanks for the valuable addition. – Gonzalo Medina Jul 6 '13 at 3:39
14

Even simpler, just put

\crefname{equation}{}{}

in your preamble. Then all the formats get defined for you automatically. (No need to redefine all of \crefformat, \crefmultiformat, \crefrangeformat, \labelcrefformat!)

These days, cleveref is...clever enough to omit the usual non-breaking space after the cross-reference name if you define an empty name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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