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

lockstep
  • 250,273
Paulo H
  • 439

2 Answers2

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

Gonzalo Medina
  • 505,128
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.

Mico
  • 506,678