Question about the use of cleveref's \Crefrangeformat

I am trying to use the package cleveref to reference to a range of equations. I'd like to have the following result in the text:

Eqs. (1)-(5)

I want to be able to define the format once, using the command \Crefrangeformat, so, at the beginning of my document I have the following two lines:

\usepackage{cleveref}
\Crefrangeformat{eq}{#3(#1)#4-#5(#2)#6}


and in the text I type:

Eqs. \Crefrange{eq:eq_first}{eq:eq_last}


I'd expect the results to be:

Eqs. (1)-(5),

Eqs. Equations (1)–(5)

Now my question is: why does the word "Equations" appear despite the fact that I didn't include it in the format declaration? Is there something subtle I am missing here?

In \Crefrangeformat you have to refer to a valid counter, in your case equation and not eq.

Also, you can insert "eqs." inside it not to have to specify it every time.

Moreover, it is better to define \crefrangeformat and leave \Crefrangeformat undefined, so when you use \crefrange you get the non-capitalised version and when you use \Crefrange you get the capitalised version.

In other words, you can define it as follows

\crefrangeformat{equation}{eqs. #3(#1)#4--#5(#2)#6}


so that the following MWE

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

\crefrangeformat{equation}{eqs. #3(#1)#4--#5(#2)#6}

\begin{document}
\Crefrange{eq:eq_first}{eq:eq_last} and \crefrange{eq:eq_first}{eq:eq_last}

$$\label{eq:eq_first} a=b.$$

$$\label{eq:two} b=c.$$

$$\label{eq:three} c=d.$$

$$\label{eq:four} d=e.$$

$$\label{eq:eq_last} e=f.$$

\end{document}


yields

@karlkoeller and @Jubobs have already answered your question. @Jubobs is exactly right that you shouldn't be typing the "eqs." manually, but leaving cleveref to do that for you. (If you have exceptions in your document where you need the labels without the text, use \labelcref et al.)

Also, you shouldn't be using \Cref<x> (note the capitalisation) except at the beginning of sentences. If you want capitalised names, use the capitalise package option. (capitalize is also accepted, for my American friends who seem to consistently mis-spell it ;-) \Cref<x> don't only capitalise the text, they also use the full name instead of an abbreviation, as you shouldn't abbreviate words at the beginning of sentences in written English.

However, if all you want to do is change the text and the label formats, and nothing more fancy, then you're much better off using the high-level format customisation commands:

\crefname{equation}{eq.}{eqs.}
\creflabelformat{equation}{#3\textup{(#1)}#4--#5\textup{(#2)}#6}


(In fact, the first of these is not needed, as it's already the default definition unless you're using the noabbrev package option. Note also the double dash "--" in the \creflabelformat definition: numerical ranges should be separated by an en-dash in written English, not a hyphen. The \textup ensures the labels are always set in upright font, which I'm told is the correct style.)

The reason to avoid using the low-level formatting commands like \crefrangeformat is that, unless you're very careful (see the manual), you'll break support for things like babel and automatic theorem naming. You should use the high-level commands wherever possible (\crefname, \creflabelformat, etc.). It's rare that you'll actually ever need the low-level commands (\crefformat, \crefrangeformat, etc.).

Remember: it's always easier for people here to diagnose the problem if you post a minimal working example (MWE).

Hardcoding is evil

The beauty of cleveref is that it removes the need for hardcoding and it allows you to easily change cross-reference format at any stage. Imagine if you hardcoded Eqs everywhere in your input file, and then changed your mind as to how cross-references to equations should be typeset; say you'd know like to have

Equations (1)-(5)

Eqs. (1)-(5)

Well, that would require a lot of search & replace in your input file, which is tedious and error-prone. cleveref allows you to make a local change in the definition of a cross-reference format, which is then effected throughout the document. In conclusion: let cleveref do the job and don't hardcode anything.

An explanation of what's going wrong

See the cleveref manual (subsubsection 7.1.2):

The cross-reference type is usually the name of the counter for the environment (equation, chapter,section, etc.).

The cross-reference type of the equation environment is equation, not eq. Therefore, \Crefrangeformat{eq}{#3(#1)#4-#5(#2)#6} has no impact on how cross-references to equations are typeset and, when cleveref encounters \Crefrange{eq:eq_first}{eq:eq_last}, the default format for a cross-reference to range of equations is still going to be used. That's why you get

Eqs. Equations (1)-(5).

What you should do

I refer you to the answers by Toby Cubitt (the author of the cleveref package) and karkoeller.