Forum How do I...?

Resetting page counter AND counter style

gt
In the following code, I want to reset the page counter and also change the page counter style at the introduction. I can reset the counter, but can't work out how to change the counter style.

Will I have to create a new named page and new flow or can the style of the existing page counter flow be changed on the fly?

<style type="text/css">
@page {
  @bottom-center { content: flow(in_pdf_bottom_center); }
}
.in_pdfpagenum { content: counter(page, lower-roman); }
#in_pdf_bottom_center { flow: static(in_pdf_bottom_center); }

div#introduction { counter-reset: page 1 }
</style>

<body>
<div id='in_pdf_bottom_center'><p style="text-align: center;">Page: <span class='in_pdfpagenum'></span>&nbsp;</p></div>

... first couple of pages' worth of text ..., with page numbers going i, ii, iii, iv etc..

<div id="introduction"> blah ... blah .... blah ... with page numbers going 1, 2, 3 ....
</div>
</body>


Apologies if this has already been asked, but the forum search seems a bit wonky at the moment - I've had cursory manual browse through it but can't see anything that looks like it matches what I'm asking.

Thanks,
Gary.
mikeday
You will need to flow a new block with a different counter style to the footer, but there is no need to create a new named page. If your footer is this simple, you may not need to flow a block at all:
@page {
    @bottom {
        content: "Page: " counter(page)
    }
}
gt
Thanks Mike. That's helpful.

Unfortunately, we need to use indirect flows because we want to be able to style the content, so we can't take the simple route!

But it's no problem to put in a new flow.

Regards,
Gary.
_savage
I'm trying to achieve something similar: count the pages from the beginning of the document using roman numerals in the @top header, and then, starting with the TOC, reset the page counter and use latin numbers.
chapter#toc {
  counter-reset: page 1;
}
This resets the counter, but I can't quite follow the above approach of changing the page numbering style. Something like
counter-style: page latin;
would be nice to add to the above code to switch the style itself? Just as an override of the default style...

So question is (considering the thread here is about 4 years old)—how do I handle the above problem with the current version of the Prince?
mikeday
Use a different named page, so that you can override the @page @top rule and use a different counter style.
_savage
There are a number of
<chapter> .. </chapter>
in my document, the first handful of which ought to use roman numerals, and then the remaining ones ought to use latin numbers for their page numbers.

Not sure I understand you correctly, but you suggest to use
@page chapter-roman {
  @top { content: counter(page, lower-roman); }
}
@page chapter-latin {
  @top { content: counter(page); }
}
and then somehow tie this to the XHTML document, perhaps using a class for the tags?
XHTML:
<chapter class="roman"> .. </chapter>
...
<chapter class="latin"> .. </chapter>
...

CSS:
chapter.roman { page: chapter-roman auto; }
chapter.latin { page: chapter-roman auto; }
I guess that would work although I'm not sure if I tie structure and layout here too closely?
mikeday
Yes, that is what I am suggesting. If you don't want to use classes, you could use :nth-of-type selectors. But surely there must be some difference in structure between the two types of chapters, ie. the first few are frontmatter or introductory?

(By the way, the page property only takes one value, as mentioned in the other thread).
_savage
There isn't really much difference in their structure, but yes, they're mainly frontmatter and introduction. The :nth-of-type selector worked just great.

I tried this
@page chapter-roman:left {
  @top-left { content: counter(page, lower-roman); }
}
@page chapter-roman:right {
  @top-right { content: counter(page, lower-roman); }
}

chapter#cover, chapter#dedication, chapter#toc, chapter#preface {
  page: chapter-roman;
  prince-page-group: start;
}
and it seems to work; however, I have to duplicate previous @page:left and :right definitions completely. The named chapter @page doesn't inherit? I also do need to duplicate the handling of empty pages where I don't want headings to show at all.

There's no way I can enumerate like this?
@page:left, @page chapter-roman:left { .. }
and so forth, I actually need to duplicate?

Edited by _savage

jyasskin
One difficulty with this strategy is cross-references: if my ToC needs to refer to both introductory pages ("iv") and normal pages ("7"), I can't just use target-counter(attr(href), page, _anything_) to refer to them: I need to put an attribute on the ToC element saying which kind of page it's referring to.

I suspect http://www.w3.org/TR/css3-gcpm/ is just missing the technique to deal with this.