I have been using the breqn and cleveref packages independently, and I think they are both excellent packages; but recently I have tried using them together, but it appears that cleveref cannot identify the dmath environment so that all my references to equations reference the containing section. Is there a way to make these package work together?

Here's a MWE illustrating the problem:






enter image description here

  • Please provide a "Minimal Working Example" (MWE) of your code.
    – Mico
    Commented Sep 15, 2011 at 18:16
  • Please, as Mico suggested, post a MWE of your code. I did it for you in my edit (for the sake of the quality of the question) but you are free to roll back or add an MWE of your own if you want to. Commented Sep 15, 2011 at 18:28

3 Answers 3


An alternative answer, which allows you to use \label as normal:

The problem is caused by the fact that cleveref relies on redefining \refstepcounter, while breqn doesn't actually use this to advance the equation counter. Fortunately the cleveref code for dealing with footnotes, which don't use \refstepcounter either, provides a basis for dealing with dmaths as another special case by adding some code to \eq@setnumber:


Including this code in the preamble yields the correct result for the MWE.

  • This works perfectly! Thanks for the quick response Ant!
    – Craig
    Commented Sep 15, 2011 at 22:18

I used to use Ant's makeatletter method, but with the packages contained in the Feb 2014 MikTex 2.9 installation:

Package: cleveref 2013/12/28 v0.19 Intelligent cross-referencing
Package: breqn 2012/05/10 v0.98b Breaking equations

this starts causing:

TeX capacity exceeded, sorry [input stack size=5000]


It also seems like dmath and cleverref now play together well by default, so upgrading the latex packages now appears to be a viable solution.


Not ideal, but a workaround is to add an optional argument equation to each label:

  • it may not be ideal, but it's probably the best you are going to achieve. (the author of cleveref could in principle read all packages and identify labellable envs that they introduce so as to program round them, but it's not likely to happen, is it?) Commented Sep 15, 2011 at 21:52
  • Fortunately not every environment needs to be dealt with individually. If the environment number is incremented with \refstepcounter then cleveref should work automagically. If not, you can insert the patch of \refstepcounter into whatever command is used instead by hand - see my other answer.
    – Ant
    Commented Sep 15, 2011 at 22:02
  • This doesn't work for me. The dmath displays as equation, but the counters aren't right. Your other answer appears to be required. Commented Feb 11, 2013 at 15:05
  • This doesn't work, the argument to \label becomes just the opening bracket [. I guess options to \label require a special package?
    – Ben Voigt
    Commented Apr 28, 2015 at 22:51

You must log in to answer this question.

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