# Problem with ntheorem, mathtools and cleveref

I have two (related) problems.

I'm writing a project where the following is part of my preamble:

\documentclass[a4paper,11pt,oneside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage[amsmath,thmmarks]{ntheorem}
\usepackage{mathtools}
\usepackage{cleveref}
\mathtoolsset{showonlyrefs}


The first problem is that with the preamble above, the following example shows the reference to the second equation with the number '2' when it should be '1', and the tag is not shown next to the equation.

The second problem is that if I don't load the cleveref-package, the same example now shows the tag but the number is now '3'.

If I don't load the cleveref-package and if I remove the option thmmarks from the ntheorem-package, the example works well.

What do I do to correct this?

Here's the full example showing the problem:

\documentclass[a4paper,11pt,oneside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage[amsmath,thmmarks]{ntheorem}
\usepackage{mathtools}
\usepackage{cleveref}
\mathtoolsset{showonlyrefs}

\begin{document}
This is the first equation:
$$a^2 + b^2 = c^2\label{eq1}$$
This is the second equation:
$$\alpha^2 + \beta^2 = \gamma^2\label{eq2}$$
This line is referring to the second equation, \eqref{eq2}.
\end{document}


I might also want to point out I did the compiling on Windows with TeXLive 2010 when I wrote the post. I am now on Ubuntu with TeXLive 2009. The result is slightly different. With the preamble as it is, I now get ([equation][2][0]2) as the referring number, and no tag is shown.

(I apologize for the lack of example in the original post.)

-
What's the example? – egreg Apr 7 '11 at 18:03
Things I'm ready to conjecture without example: since ntheorem's thmmarks and mathtools' showonlyrefs both need to hook into end-equation handling, they'll be difficult to reconcile. Also, some aligned math constructs are evaluated twice, which might cause the extra stepping. Or you're just lacking another LaTeX run. It's hard to tell without example. – Ulrich Schwarz Apr 7 '11 at 19:23
cleveref is seemingly not compatible with the memoir class. Not loading cleveref and loading \usepackage[overload,ntheorem]{empheq} before ntheorem seems to fix the problem, cf. the mathtools manual p. 11 (v1.10, last revised 2011/02/12). – smlange Apr 9 '11 at 23:25
I'm curious. Should I answer my own question with the solution/workaround, edit the original post to include the solution/workaround or just leave it as it is with the comment explaining how to fix it? – smlange Apr 9 '11 at 23:33
Answer your own question, then after a delay you can accept the answer (to keep the site tidy) – Joseph Wright Apr 20 '11 at 10:48

It turned out to be a compatibility issue between cleveref and memoir. As the OP wrote: Not loading cleveref and loading \usepackage[overload,ntheorem]{empheq} before ntheorem fixed the problem. See the section 3.2.2 Showing only referenced tags p. 11 in the mathtools manual (v1.10, last revised 2011/02/12).