8

I'm writing all my equations with

\begin{equation} ... \end{equation}

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?

1
  • 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'
    Commented Aug 15, 2014 at 0:37

2 Answers 2

9

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.

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

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
\begin{equation}
\text{this has a number}\label{a}
\end{equation}
text
\begin{equation}
\text{this hasn't}
\end{equation}
\end{document}

enter image description here

2
  • 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
    Commented Aug 14, 2014 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
    Commented Aug 15, 2014 at 9:21

You must log in to answer this question.

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