24

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

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

3 Answers 3

24

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.

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

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.

3

In case one wants to do this only locally, and not for the whole document, use \labelcref{…} instead of \cref{…}.

(This is the same as using \ref{…}, except it can also benefit from cleveref's multi-reference functionality).

1
  • 1
    Thanks for this! This is exactly what I was looking for.
    – amzon-ex
    Commented Dec 14, 2023 at 15:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .