- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Thu, 24 Jul 2008 09:59:59 -0500
- To: "Ludger Buenger" <ludger.buenger@realobjects.com>
- Cc: www-style@w3.org
- Message-ID: <dd0fbad0807240759p25cfb91dlb8d7b6c231c48931@mail.gmail.com>
On Thu, Jul 24, 2008 at 5:55 AM, Ludger Buenger < ludger.buenger@realobjects.com> wrote: > > Hello CSS counter folks. > > > Currently setting a css counter to a defined value is only possible using > the 'counter-reset' property. > However counter-reset has the sometimes undesired habit of forcing a new > scope (which is great for nesting counters but disturbing for e.g. chapter > counting). > > Therefore our question/suggestion: > > Is it/should it be possible to decouple the two abilities to 1) setting a > property to a defined value and 2) opening a new counter scope? > > The use case is the following: > > In print, one sometimes like to have number all the pages of a chapter and > restart numbering if a new chapter starts. > This is e.g. required in documents of the FDA conforming to their > specification found at http://www.fda.gov/cber/gdlns/m4ctdannex.htm or in > documents for the European commission. > > I.e. I'd expect something like the following to be possible: > > chapter { > page-break-before: always; > counter-reset: chapterPageCounter 1; > string-set: chapterName self; > } > > @page { > counter-increment: chapterPageCounter; > @bottom-right { > Content: "Page " counter(chapterPageCounter) "of section " open-quote > string(chapterName) close-quote; > } > } > > However due to the fact that counter-reset opens a new scope, this will not > lead the desired result because the relation of page margins content to > scopes is a) unspecified and b) unexpected. > > What is missing here is the ability to set a counter to a start value > inside a scope without opening the new scope for the counter. > > Something like e.g: > > chapter { > counter-set: chapterPageCounter 1; > } > > Maybe the folks have better suggestions how this could/should be done? > > I tried to evaluate other mechanisms to achieve this but did not find other > solutions, also not in the gcpm module. > > Maybe I missed something... I don't believe this is at all an issue with the counter-reset property, but rather an inherent issue with counter incrementing caused by the fact that the page progression runs parallel to the document progression, without an easy way to map between the two. If you want a counter that sits in "page space", you need to keep all of its rules within "page space", or else it appears that the behavior is undefined, as you discovered. In this case, you need the counter-reset to appear within a page rule. Since you want to reset on chapters, then, you need to utilize the power of named pages, and specifically you probably need named page lists (from GCPM [1]). Give the chapter element (or whatever you use to indicate a new chapter) a "page:chapter-start auto" property, then put the counter-reset in an "@page chapter-start" rule. (You need the page list rather than a plain page property in order to avoid page-breaking automatically after the element, unless you have a fortuitous setup.) [1]: http://www.w3.org/TR/css3-gcpm/#named3 ~TJ
Received on Thursday, 24 July 2008 15:00:37 UTC