In my document, I reference a string of sections within a sentence. A representative example would be:
I am referencing Sections \ref{A}, \ref{B}, \ref{C}.
This then comes out t something like:
I am referencing Sections 6.1, 6.2, 6.3.
How can I get it to display:
I am referencing Sections 6.1-3
without hard-coding it?
Best Answer
Using the
cleveref
package you can compress a range and using\crefstripprefix
(recent versions of the package), you can remove the common prefixes from reference range:Using
\crefrangelabelformat
you can customize the format for a range of references. It has the syntax:The first argument specifies the
<type>
of references that will be customized; for the second argument, thecleveref
documentation explains:\crefstripprefix
simply removes the prefix (the chapter number, in this case) from the second part of the range.Here's an enhanced example in which the prefix has been stripped out for cross-references to ranges of sections, subsections and equations: