Math & ScienceUsing numberwithin

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
notnek
Posts: 11
Joined: Mon Dec 07, 2009 5:09 pm

Using numberwithin

Post by notnek »

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.
Last edited by notnek on Mon Apr 04, 2011 3:18 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Using numberwithin

Post by Juanjo »

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.
notnek
Posts: 11
Joined: Mon Dec 07, 2009 5:09 pm

Re: Using numberwithin

Post by notnek »

That works great. Thank you!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Using numberwithin

Post by localghost »

notnek wrote:That works great. […]
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.


Thorsten
Post Reply