Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
2  
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
5  
@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
add comment

2 Answers 2

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.

Usage:

\mathtoolsset{showonlyrefs}

or

\mathtoolsset{showonlyrefs=true}

or set it to false this way if desired.

share|improve this answer
7  
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
3  
@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
1  
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
    
@Thorsten: The option you suggested is meaningful and I guess that the mathtools package might support this in the future. –  Stefan Kottwitz Nov 1 '10 at 0:07
1  
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
add comment

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.

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{autonum}
\begin{document}

\begin{equation}
a = b \label{eq:a}
\end{equation}

\begin{equation}
c = d \label{eq:b}
\end{equation}

\begin{equation}
e = f \label{eq:c}
\end{equation}

See \cref{eq:b}.
\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

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.