I want to label equations in my document with (2.b.c) indicating the subsection b and equation c in chapter 2. For all of the other chapters, I would like (d.e) to indicate the chapter d and equation number e (there are no subsections in the other chapters).
Can someone help me with this? I can use \numberwithin{equation}{subsection} in the preamble but this labels equations like (a.b.c) for the whole document.
Math & Science ⇒ Using numberwithin
Using numberwithin
Last edited by notnek on Mon Apr 04, 2011 3:18 am, edited 1 time in total.
Using numberwithin
The chngcntr package provides the commands \counterwithin and \counterwithout, which have the same syntax as \numberwithin. The \counterwithin command behaves exactly as \numberwithin (use whichever you prefer of both). Likewise, \counterwithout undoes any counter subordination. There are also starred variants of both commands. After \counterwithin{equation}{section}, the equation counter is reset each time the section counter is increased. After \counterwithout{equation}{section}, the equation counter is released to its previous state, not dependent on sections. In your case, you may combine this commands at the beginning and the end of the problematic chapter.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Re: Using numberwithin
That works great. Thank you!
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Using numberwithin
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting). You are not new to the forum so you should know that. Please keep that in mind for the future so that further reminders will not be necessary.notnek wrote:That works great. […]
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10