TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a paper where all equations are numbered, but I want to number equations only if they are actually referred to in the .tex file using \ref{}. How can I make that happen? Alternatively, how can I make all equations that have no \label next to them (because then I know I don't refer to them) not have a number? Do I have to use \nonumber separately for each such equation?

share|improve this question
See also this question – Lev Bishop Oct 31 '10 at 2:10
I hope you don't mind that I tried to enhance your question a bit. – Hendrik Vogt Oct 31 '10 at 7:11
It looks like wanting to number the equations with an internal reference only is not a good habit. It would be somehow similar to numbering specific pages only for personal reasons. Readers of your document may need to refer to an unnumbered equation which is very annoying. – pluton Oct 31 '10 at 21:21
@pluton: no more annoying, surely, than to refer to random lines of prose, or snippets of math inlined in the text? These arguments for “number all equations” always seem to me like they’re really arguments for “include line numbers throughout”. (And conversely, the main arguments against line numbering — clutter and distraction — seem equally to be arguments against numbering all equations; if anything more so, since the consistency of line numbers makes them comparatively unobtrusive.) – Peter LeFanu Lumsdaine Dec 20 '10 at 21:04

The mathtools package provides a switch showonlyrefs. You could use that to achieve that only those equations would be numbered which are referred to in the text.





or set it to false this way if desired.

share|improve this answer
Instead of using the switch the package can be loaded with the according option: \usepackage[showonlyrefs]{mathtools} – Thorsten Donig Oct 31 '10 at 9:40
@Thorsten: in which version does that syntax work? I tested it with v1.06 and it doesn't work that way. – Stefan Kottwitz Oct 31 '10 at 17:56
I once read (not in the manual) about "an option" for this setting without testing it. My bad. The information was wrong. There is neither a switch nor a package option. The setting has to be done as you wrote in your corrected answer. – Thorsten Donig Oct 31 '10 at 21:55
It is at least suggestive. At the moment the package seems only to accept the same options as »amsmath« to pass them. – Thorsten Donig Nov 1 '10 at 8:34
You should mention that this doesn't work with cleveref as per Torbjørn T. – LondonRob Oct 3 '14 at 14:31

mathtools with showonlyrefs will not work with the cleveref package, so if you rely on that package for your cross-references, it would be better to use autonum. If one wants to use hyperref as well, the loading order must be hyperref - cleveref - autonum, as described in the manual.


a = b \label{eq:a}

c = d \label{eq:b}

e = f \label{eq:c}

See \cref{eq:b}.

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.