Forum How do I...?

Page names causing page breaks?

shiffman
Hello!

I'm using page names in order to have different page numbering for my front matter and regular content. i.e.

@page :left {
   @bottom-left {
    content: counter(page);
  }
}
@page frontmatter :left {
   @bottom-left {
    content: counter(page,lower-roman);
  }
}


I define the front matter with a div, i.e.

<div id ="frontmatter">
<h1>Front Matter</h1>
<p>
This is page 1.
</p>
</div>


with CSS:

div#frontmatter {
  page: frontmatter;
}


Whenever I do this, I get an extra page break. Am I missing something obvious (most likely)? Or is this a bug?

Full test HTML:

https://gist.github.com/4146422

Renders: test.pdf‎
  1. test.pdf28.5 kB
    Test PDF rendered
mikeday
Named pages will be preceded and followed by a page break, and the extra page break comes from the page-break-after: always on the following div.
shiffman
Yeah, I wish there was a way to turn off the page breaks as my book as my process would be a lot easier if I could just arbitrarily insert stuff like:

<div id="reset"> </div>


<div id="lowerroman"> </div>


and have whatever pages these divs happen to be on work the way I want them to without a page break, but I'm going back and doing this a different way now.
jerkob
Is there any way to override this behavior? Forcing a page break before and after greatly limits the use cases for named pages. I was trying to use named pages to display a different header on those pages (a good example of this use case is a book with a running page header that you don't want to show on the first page of a new chapter). I'm not sure how I can accomplish this now.
mikeday
Try something like this:
@page chapter:first { ... }

div.chapter {
    page: chapter;
    prince-page-group: start
}

Basically the whole chapter is inside a named page, and we start a new named page group at the beginning of each chapter element, and we can select the first page of each named page group.
jerkob
Ah, thank you. I think that should work. You should add something about the existence of prince-page-group to the "Paged Media" guides. There is no indication of it or what is possible with it in those guides.