# How to number only labeled equations?

I'm writing all my equations with

$$...$$


so all of them are numbered but only some of them are labeled. I don't want all of them with numbers but only the labeled ones.

Since I have a real big document I don't wanna do this manually using * for all the others. How can I do this automatically?

-
Since it seems that the answer by Bernard wasn't useful to you, please provide a minimal (non-)working example (MWE) showing the issue. Only then we can really help you. –  yo' Aug 15 '14 at 0:37

You have a possibility, with the mathtools package (that loads amsmath, so it's useless to load the latter): write

\mathtoolsset{showonlyrefs,showmanualtags}


in your preamble, and only the referenced equations will be numbered (use \eqref). It's not exactly what you ask (number labelled equations), but you can try to make ‘fake references’ at the very end of your document.

-
Thanks for your answer. I tried that and equations are referred non of them have numbers –  David Aug 14 '14 at 23:38
You mean non-referred equations have no number, I suppose? Your comment isn't quite clear to me. –  Bernard Aug 14 '14 at 23:43
I mean, I have numbers in my text referring to equations but my equations don't have numbers anymore –  David Aug 14 '14 at 23:52
Could you post a Minimal Working Example? –  Bernard Aug 14 '14 at 23:55
Btw, did you think of using eqref rather than ref? –  Bernard Aug 15 '14 at 0:11

No warranty. ;-)

\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}

\makeatletter
\newif\ifdavid@number
\preto\equation{\david@numberfalse}
\preto\endequation{\ifdavid@number\else\notag\fi}
\patchcmd\label@in@display{\@empty}{\@empty\david@numbertrue}{}{}
\makeatother

\begin{document}
Text
$$\text{this has a number}\label{a}$$
text
$$\text{this hasn't}$$
\end{document}


-
This is awesome but it failed for 'aligns' and for some reason links in my document don't lead to the right places anymore (I'm using \usepackage{hyperref}) –  David Aug 14 '14 at 23:50
@David You just mentioned equation, didn't you? I can't guess what you're using in your document. Besides, do you really mean to number only the labeled equations in an align? –  egreg Aug 15 '14 at 9:21