# Math Help - Numbering within chapters

1. ## Numbering within chapters

How do you number equations, definitions, theorems etc within chapters?

Like every def, theorem, equation in chapter 2 for example would start with 2.1, 2.2 etc...

2. Originally Posted by Deadstar
How do you number equations, definitions, theorems etc within chapters?

Like every def, theorem, equation in chapter 2 for example would start with 2.1, 2.2 etc...
\numberwithin{equation}{section}
\renewcommand{\theequation}{\thesection.\arabic{eq uation}}

And similarly
\numberwithin{counter_here}{section}
\newtheorem{thm}[counter_here]{Theorem}

3. Hmm that didn't work...

I already have this in my report which defines styles of all theorems, lemmas, definitions, etc...

\newtheorem{lemma}{Lemma}
\newtheorem{theorem}[lemma]{Theorem}
\newtheorem{corollary}[lemma]{Corollary}
\theoremstyle{definition}
\newtheorem{definition}[lemma]{Definition}
\newtheorem{example}[lemma]{Example}

Remember EVERY definition, theorem, corollary and lemma is numbered. I would like it so they are numbered according to what chapter they are in.

4. Originally Posted by Deadstar
\newtheorem{lemma}{Lemma}[section]
\newtheorem{theorem}[lemma]{Theorem}
\newtheorem{corollary}[lemma]{Corollary}
\theoremstyle{definition}
\newtheorem{definition}[lemma]{Definition}
\newtheorem{example}[lemma]{Example}
Try that.

That should give you numbering such as 2.1.1, 2.1.2,... if you are in section 1 and chapter 2. If you just want it like 2.1, 2.2,... then use [chapter] instead of [section].

5. Perfect thanks a lot.

I've just given myself another problem in that some of my sections are numbered the same as my theorems... Like I have a section numbered 2.1 and an equation numbered 2.1 lol...

Also doing it the first way [section] works fine for the first two chapters but after that it goes in a mess and ends up with 9.0.50 as my last definition instead of 9.0.6... This is why I don't really like Latex that much, so hard to style it!

Might just not number the sections...

6. Originally Posted by Deadstar
Perfect thanks a lot.

I've just given myself another problem in that some of my sections are numbered the same as my theorems... Like I have a section numbered 2.1 and an equation numbered 2.1 lol...

Also doing it the first way [section] works fine for the first two chapters but after that it goes in a mess and ends up with 9.0.50 as my last definition instead of 9.0.6... This is why I don't really like Latex that much, so hard to style it!

Might just not number the sections...
I have no idea why it would number .50 at the end but the 0 indicates that you just have a chapter and not a section. You could number your equations according to the section and theorems according to chapter.

7. Not really sure what I'll do to be honest! I really like the chapter numbering way you showed me above (not so keen on the 1.2.3 style numbering). But It means that it looks odd when you number sections as they will have the same numbering as some formulas...

I think I need to go get a book or two and take note of how they number their parts. Then maybe come back for more advice...

Just for future reference, say I wanted to number all my corollarys (for example) by section what would I do?

Would it be
\newtheorem{corollary}[lemma]{Corollary}[section]

or ustj
\newtheorem{corollary}{Corollary}[section]

8. Originally Posted by Deadstar
Just for future reference, say I wanted to number all my corollarys (for example) by section what would I do?

Would it be
\newtheorem{corollary}[lemma]{Corollary}[section]

or ustj
\newtheorem{corollary}{Corollary}[section]
If you want equations numbered you use this format;

\numberwithin{equation}{section}
\renewcommand{\theequation}{\thesection.\arabic{eq uation}}

For theorems the format is;
\newtheorem{name}[counter]{printed name}[section]

If you leave out the [counter] (where "counter" is the name of the counter) then it will make a new one, so for example

\newtheorem{corollary}{Corollary}[section]
\newtheorem{def}[lemma]{Definition}

will give you, Corollary 2.1.1, Definition 2.1.2,... whereas

\newtheorem{corollary}{Corollary}[section]
\newtheorem{def}{Definition}[section]

will give Corollary 2.1.1, Definition 2.1.1, Corollary 2.1.2, Corollary 2.1.3, Definition 2.1.2,...

You can also manually set counters with \setcounter{counter}{value} if you want to solve the numbering problem manually.