How to number equations within theorem-like environments

enter image description here

And produce something like

253k 70 70 gold badges 730 730 silver badges 796 796 bronze badges asked May 20, 2012 at 17:18 439 5 5 silver badges 11 11 bronze badges

Your code has some (easy to fix) errors and won't work. Please fix it. On your question, how would you number equations that appear outside a theorem?

Commented May 20, 2012 at 17:23

My purpose is enumerate equations only in the proofs; because outside I use an 'observation' environment or just $$ $$

Commented May 20, 2012 at 17:26 I've updated my answer providing a simpler solution. Commented May 20, 2012 at 17:46

2 Answers 2

Once amsmath has been loaded, you can use

\numberwithin

A complete example:

\documentclass[a4paper,10pt] \usepackage \newtheorem[section] \numberwithin \begin \section \begin \begin \label 1+1=2. \end \begin The proof of the equation~\eqref is left as an exercise. \end \end \end

enter image description here

answered May 20, 2012 at 17:26 Gonzalo Medina Gonzalo Medina 510k 71 71 gold badges 1.7k 1.7k silver badges 1.8k 1.8k bronze badges

If you're sure that you'll be using numbered equations only within theorem environments (and other theorem-like environments) and if you're loading the amsmath package, you could issue the command

\numberwithin

where theorem is the environment set up with a \newtheorem statement.

If you have several theorem-like environments, be sure to have them share the same counter. How to do this depends strongly on the theorem package that's in use. For the amsthm package, you'd force the lemma , corollary , etc environments to use the same counter as theorem environments do by issuing commands such as

\usepackage \newtheorem \newtheorem[theorem] \newtheorem[theorem] \numberwithin

By the way, don't use the deprecated $$ . $$ method to create unnumbered display-style equations. Instead, use something like \begin . \end . Among other good things, the spacing around displayed equations will become much better.