# Setting minimal number of references for cleveref's compression feature

I am using cleveref for cross-referencing. The default sort&compress option compresses three or more consecutive references into a range. I would like to get this compression already for two consecutive references:

\documentclass{article}

\usepackage{amsmath}

\newcommand*{\crefrangeconjunction}{--}    %% instead of the default ' to\nobreakspace'
\newcommand*{\crefpairconjunction}{, }     %% instead of the default ' and\nobreakspace'

\begin{document}
\begin{align}
a & = b \label{eq:1}\\
c & = d \label{eq:2}\\
e & = f \label{eq:3}\\
g & = h \label{eq:4}\\
i & = j \label{eq:5}
\end{align}

\cref{eq:1,eq:2,eq:4,eq:5} default behaviour

eqs. (1)--(2), (4)--(5) looks better, IMHO.
\end{document}

It's not possible to produce this formatting fully automatically without hacking cleveref internals. the closes you can get it to use

\def\creflastconjunction{, }

to suppress the conjunction before the final element of the enumeration, which will produce "eqs.~(1), (2), (4), (5)" in your MWE. (You might want to redefine \creflastgroupconjunction in this case, depending on what exactly you're trying to achieve.)

You can produce the formatting you want semi-manually, using

\def\crefpairconjunction{--}
\cref{eq1,eq2}, \labelcref{eq3,eq4}

(One can get too obsessed with trying to do everything automatically in LaTeX, when sometimes the best solution for one-off cases is to just write what you want directly in the document.)

However, good style dictates that cross-references should read as grammatical sentences. The formatting that you say 'looks better' reads as: "equations (1) to (2), (4) to (5)". This is both grammatically incorrect (it's missing an "and"), and prone to confusion. Readers will wonder if there's a mistake in the reference, or if something is missing; it's odd to write "(1) to (2)" when there's nothing in between (1) and (2). The format produced by \def\creflastconjunction{, } is equally ungrammatical, though less confusing.

Do you value 'looking better' over clarity in your writing?

There are good reasons cleveref doesn't use ranges for only two references, and inserts "and" between the final two elements of a list. So I'm very unlikely to spend the time needed to modify cleveref to allow what you want. If you want to produce your desired formatting fully automatically, I'm afraid you're on your own. (You're welcome to send me a patch, but I may well reject it on the above grounds.)

• As if this was not clear from my post: when I said "looks better" I meant "more readable", so yes, I had the reader in mind. Moreover, the conjunction in the enumeration is optional, is it is not grammatically wrong. I just thought that is unnecessarily hard to get the missing item from the range 1--5 when writing "(1), (2), (4) and (5)", and my proposal above was the best I came up with. – mafp Dec 27 '13 at 16:48
• Sorry, I understood "looks better" in your post to mean "looks aesthetically better" rather than "more readable" (so no, it wasn't clear to me). I'm not a grammar fascist. As I showed, it's simple to remove the final conjunction from enumerations. Nonetheless, adding a conjunction before the final element is the more common usage, so it's the default. – Toby Cubitt Jan 7 '14 at 15:28
• I can see your argument for using 2-element ranges in your specific case, though it's not the formatting I'd choose. But in general, automatically compressing 2-element ranges gives bizarre results. It seems unlikely it's something you'd want to enable globally, and not worth the significant effort of coding and maintaining it. So I'm unlikely to add this feature myself. However, you can get the formatting you want with \def\crefpairconjunction{--} in your preamble and "\cref{eq1,eq2}, \labelcref{eq4,eq5}" in the text. I've edited my answer to include this. – Toby Cubitt Jan 7 '14 at 15:31
• I totally agree that compressing 2-element ranges is a bad idea in general. My idea above is certainly just a corner case (in the real document where it popped up it was even more weird, something like "35, 36, 38, and 39"). But your manual workaround looks good to me, so: accepted. – mafp Jan 7 '14 at 22:15