Forum How do I...?

...remove @page properties from specific page

samuil
I'm trying to create book, divided into chapters. On every page there is chapter title on top. On the pages that contain chapter title I'd like @page {@top-center {...}} to be not shown. Adding property page to <h2> element (chapter title) creates unwanted page break after it. Is there method to avoid page break in this situation.

Regards, Samuil
mikeday
It is possible to do this with Prince 5.1, although the method is a little bit indirect. It involves taking the header from a named string, created using string-set on the chapter title, like this:
@page {
    @top { content: string(header, first) }
}

h2 { string-set: header content() }

This will take the first value of "header" that is set on the page and use it as text for the page header. So we need to explicitly clear the header before each chapter heading:
div.chapter { string-set: header "" }

<div class="chapter">
<h2>Chapter 1</h2>
...

This way the first value of "header" will be empty, leaving no page header for the first page of the chapter. However, subsequent pages will use the value that was set on the chapter title element.

As I said, somewhat indirect; we are planning to provide a more direct mechanism of disabling page headers in a future release of Prince, using the named page mechanism, eg. "@page chapter:first".

However, in Prince 5.1 this method can only be used to disable page headers on the first page of the document, not for the first page of each chapter, unless you place every chapter in a different named page. There is a clever trick you can use to make this easier: use one named page for even numbered chapters and a different named page for odd numbered chapters. This can be done like this:
@page {
    @top {
        content: "Page header! " string(header)
    }
}

@page chapter-odd:first { @top { content: none } }
@page chapter-even:first { @top { content: none } }

div.chapter:nth-of-type(odd) { page: chapter-odd }
div.chapter:nth-of-type(even) { page: chapter-even }

h2 { string-set: header content() }

Both of these methods will work today with Prince 5.1, but they are a little bit scary when you see them for the first time! We will make this a lot easier in a future release of Prince :)
samuil
Thanks for your help Mike. Now I see how can I achieve my goal, although I dislike both methods, as they require changing markup, and not only stylesheet -- I do not have chapters enclosed by div tags. Implementation of "@page chapter:first" also would not satisfy my needs.

I think it's a problem with CSS3 Paged Media Module, as my markup conforms ideas presented in XHTML 2.0 Structural Module (same-level headings, do not have to be enclosed by unneccessary sections).

Well -- they still aren't recommendations :).

Best Regards,
Samuil