8

I want to enumerate equations within theorem-like environments.

Example:

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath,amsthm}
\newtheorem{theo}{Theorem}[section]
%
\begin{document}
\section{Natural Numbers}
\begin{theo} 
\begin{equation} \label{eq:1}
1+1=2.
\end{equation}
\begin{proof}
The proof of the equation~\eqref{eq:1} is left as an exercise.
\end{proof}
\end{theo}
\end{document}

And produce something like

enter image description here

3
  • 1
    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? May 20, 2012 at 17:23
  • My purpose is enumerate equations only in the proofs; because outside I use an 'observation' environment or just $$ $$
    – Paulo H
    May 20, 2012 at 17:26
  • 1
    I've updated my answer providing a simpler solution. May 20, 2012 at 17:46

2 Answers 2

9

Once amsmath has been loaded, you can use

\numberwithin{equation}{theorem}

A complete example:

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath,amsthm}

\newtheorem{theo}{Theorem}[section]
\numberwithin{equation}{theo}

\begin{document}

\section{Natural Numbers}
\begin{theo} 
\begin{equation} \label{eq:1}
1+1=2.
\end{equation}
\begin{proof}
The proof of the equation~\eqref{eq:1} is left as an exercise.
\end{proof}
\end{theo}

\end{document}

enter image description here

6

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{equation}{theorem}

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{amsmath,amsthm}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corrolary}[theorem]{Corollary}
\numberwithin{equation}{theorem}

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

You must log in to answer this question.

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