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.

This question already has an answer here:

There are lots of theorems and lemmas in my thesis which are being numbered continuously from start to end. I want the numbering to be like Theorem <>.<>. Same for lemmas and corollaries. I am using amsthm and the environments are defined like

\newtheorem{definition}{Definition}
\newtheorem{lemma}{Lemma}

Is there any simple way to get chapter-wise numbering?

share|improve this question

marked as duplicate by Charles Stewart, Martin Schröder, Jesse, Peter Jansson, Svend Tveskæg Jan 30 at 8:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Related: Numbering theorems within chapters –  Papiro Jan 30 at 6:53
    
@Papiro The linked answer doesn't answer this question. –  karlkoeller Jan 30 at 7:30
add comment

2 Answers 2

up vote 3 down vote accepted

Just to show another possibility in case.... (We like hard ways ;)...)

This can also be done with chngcntr package.

\documentclass{book}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\newtheorem{definition}{Definition}
\newtheorem{lemma}{Lemma}

\usepackage{chngcntr}
\counterwithin{theorem}{chapter}
\counterwithin{definition}{chapter}
\counterwithin{lemma}{chapter}
\begin{document}

\chapter{1st chapter}

\begin{theorem}
  A theorem
\end{theorem}

\begin{definition}
  A definition.
\end{definition}

\begin{lemma}
  A lemma.
\end{lemma}

\chapter{2nd chapter}

\begin{theorem}
  A theorem
\end{theorem}

\begin{definition}
  Another definition.
\end{definition}

\begin{lemma}
  Another lemma.
\end{lemma}

\end{document}

enter image description here

share|improve this answer
    
One should go Karl's way though :) –  Harish Kumar Jan 30 at 8:19
    
Thanks a lot. It works fine for environments except theorem, which is an inbuilt environment. When I add \counterwithin{theorem}{chapter} to my preamble, I get error saying theorem is not a counter. –  Barman Jan 30 at 9:25
    
@Barman It works for theorems too. See the edit. :) –  Harish Kumar Jan 30 at 9:52
add comment

If I understand correctly, you want your theorem-like environments to be numbered within chapters.

To do this, you have to add the optional parameter chapter to your theorem definitions, for example:

\newtheorem{definition}{Definition}[chapter]
\newtheorem{lemma}{Lemma}[chapter]

In this way their number contains the chapter number and the numeration is reset at every chapter.

MWE:

\documentclass{book}
\usepackage{amsthm}

\newtheorem{definition}{Definition}[chapter]
\newtheorem{lemma}{Lemma}[chapter]

\begin{document}

\chapter{1st chapter}

\begin{definition}
  A definition.
\end{definition}

\begin{lemma}
  A lemma.
\end{lemma}

\chapter{2nd chapter}

\begin{definition}
  Another definition.
\end{definition}

\begin{lemma}
  Another lemma.
\end{lemma}

\end{document} 

Output:

enter image description here

share|improve this answer
    
Thanks, but I want it for theorem like environments and theorems as well. How do I do it for the theorem environment which is already defined? –  Barman Jan 30 at 9:27
    
@Barman, something like \newtheorem{theorem}{Theorem}[chapter] –  karlkoeller Jan 30 at 9:29
    
\newtheorem{theorem}{Theorem} says the environment is already defined and gives error. The same problem with @Harish's answer as well. –  Barman Jan 30 at 9:38
    
Can you please add a MWE in your question? –  karlkoeller Jan 30 at 9:41
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.