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 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

share|improve this question
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? –  Gonzalo Medina May 20 '12 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 '12 at 17:26
1  
I've updated my answer providing a simpler solution. –  Gonzalo Medina May 20 '12 at 17:46
add comment

2 Answers

up vote 7 down vote accepted

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

share|improve this answer
add comment

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.

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.