Forum Documentation

some more detail about page naming

tomjohnson1492
In reading the documentation, it seems like you name a page by adding this on the page:

<contents> 
        table of contents
    </contents>


Then you can control the style of that page in your CSS like this:

contents {
    display: block;
    page: table-of-contents;
    counter-reset: page 1
}


I'm a little confused about how you name the page. Do you always have to use
<contents>
tags? Does Prince look at each string inside the contents tags and use that as the page's name? Can I use any kind of tag, such as a div tag or something? Thanks.

Edited by tomjohnson1492

thomas.weigel
Based on the use of the 'page:' CSS, I assume you are talking about this bit of the documentation:

http://www.princexml.com/doc/page-selectors/ (the last section of the page)

For that kind of page naming, PrinceXML looks at the CSS for names, and then applies those names to any tags that the CSS applies to. For example:

h1 { page: chapter_start; }
@page chapter_start { border: 1mm solid red; }


This will take every page that an <h1> tag appears on, and wrap the page area in a red border.
tomjohnson1492
I'm trying to define different headers and footers for the frontmatter in my publication. For the cover, title page, and index, I don't want these pages numbered or for them to appear in the table of contents.

To accomplish this, I think I need to name the pages and then use the css techniques you mentioned to define the headers and footers for those pages.

When you say "PrinceXML looks at the CSS for names," do I just surround those pages with some kind of div tag? That part is still unclear to me. If I drop a little div tag on the page like this:

<div class="frontmatter"></div>


Then I could control the page headers and footers for that page with this in my css, right?

div.frontmatter {page: frontmatter;}
@page frontmatter { // stuff  }



Do I need to surround the whole page with this div tag, or just drop a little div tag on there without anything in it?

Edited by tomjohnson1492

thomas.weigel
Just drop the div tag on there, with or without anything in it.

It is useful to surround all of the front-matter content with the tag, however, so you don't accidentally miss a page. I'm working on a similar layout, and I have <article class="front_matter"><!-- all of the front matter--></article> in the HTML. But I've experimented with it both ways, and it works in either case.
tomjohnson1492
great. thanks!
tomjohnson1492
Sorry to come back to this thread so late. I had some other projects that took priority over the print formatting. Now that I've returned to configuring PDFs, I'm having trouble here. I'm getting weird page breaks (or blank pages) inserted before the pages that contain my custom header and footers.

Here's what I'm doing.

On the page where I don't want any footers or headers, I added this div class around all the content:

<div class="frontmatter"></div>


Then I added this in the stylesheet:

div.frontmatter { page: frontmatter }

@page frontmatter {
    @top-left {
        content: " ";
    }
    @top-right {
        content: " "

    }
    @bottom-right {
        content: " ";
    }
    @bottom-left {
        content: " ";
    }
}


When I generate the output, there is a blank page inserted before this page containing the frontmatter tag. The blank page that gets inserted contains the regular page headers as the other pages.

Maybe this is what's happening? I'm inserting the
<div class="frontmatter">
tag at the top of the body of the page. But the page itself has some other content before this div tag, such as a mini-Table of Contents and of course a bunch of tags in the head element.

Do I have to apply my frontmatter tag to the body element or something, so that nothing appears before it? How can I get rid of the unwanted page breaks?
tomjohnson1492
Ahhh, that was it. I needed to apply the class to the body element on the page. When I did this, I didn't get any of the weird or unintended blank pages that I referred to earlier.

I should note that I'm using Jekyll for my site, and some content is dynamically inserted on every page.