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?

  • 4
    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
  • 4
    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
  • 9
    @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.

| improve this answer | |

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

| improve this answer | |

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.