I am trying to adjust equation range numbering from (1.10)-(1.15) to (1.10-15).

By calling this in the preamble:


and then this in the document:


I have gotten the range in side the same brackets, i.e. (1.10-1.15), but I am having trouble stripping the section number from the second label in the range. Is there some way to adjust the {eq:1-15} label prior to calling \Crefrange (i.e. changing 1.15 to 15), and then change it back after the call? I need to change it back as in other locations I reference 1.15 individually and so need to retain the section number. Alternately can I strip the section number from the formatted text (#2) passed to \crefrangelabelformat?

Any help appreciated.

  • 1
    Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Jul 31, 2013 at 5:36
  • 2
    Is there a chance you'll need to cross-reference a range of equations across sections, e.g., something such as (1.15-2.5)?
    – Mico
    Jul 31, 2013 at 6:08

1 Answer 1


#1 and #2 of \crefrangelabelformat contains the formatted equation number. The following example expands them and stores them in \eq@ref@a and \eq@ref@b. Then both are analyzed, whether the equation numbers have a dot separator. If yes, then the first parts are compared and omitted in \eq@ref@b, if the first parts are equal.



\crefrange{eq:first}{eq:second} and \crefrange{eq:second}{eq:third}
\chapter{First chapter}
\chapter{Second chapter}


  • You may want to alert readers that this method assumes that a common prefix is terminated by a single . ("dot"). Taking your example and adding the instructions \usepackage{amsmath} \numberwithin{equation}{section} to the preamble (prior to loading cleveref, naturally) will create a cross-reference of the form eqs. (1.0.10--0.15) rather than eqs. (1.0.10-15). Put differently, 1. rather than 1.0. is recognized as the common prefix. Can your method be generalized to handle the case of equation numbers that are numbered by both chapter and section (or some similar scheme)?
    – Mico
    Nov 17, 2013 at 15:07
  • 1
    @Mico: Thanks, for the hint. Yes, the code uses the first dot as separator. Also more complex numbers (e.g. several dots) can be parsed with TeX. There are packages that help in the task of parsing, e.g. package xstring with \StrBefore, \StrBehind, \StrCut and other macros. Nov 18, 2013 at 15:40
  • Many thanks for this follow-up. Real quick: In tex.stackexchange.com/a/145356/5001, Toby Cubitt (the creator of cleveref) has provided a solution to a related question, on how to suppress the "equation prefix" in the second part of a cross-reference to a bunch of subequations. (E.g., if five equations are numbered 1a to 1e, the cross-reference will come out as (1a--e).) Toby's solution can, remarkably, handle the case of prefixes containing one or more "dots" as well.
    – Mico
    Nov 18, 2013 at 19:21
  • 1
    @Mico It's not particularly "remarkable", just straightforward TeX :) Heiko's answer was helpful in thinking through what to strip in general. My \crefstripprefix macro strips a common prefix, but only up to the final consecutive run of characters of the same 'type' (letters or digits). I think this will do the right thing in most cases, e.g. subequations, or subsections with arbitrary separators. Of course, you can still cook up unusual label formats that will break it if you try hard enough. I'll add the \crefstripprefix command to the next cleveref release, along with some examples. Nov 24, 2013 at 13:12

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.