Forum How do I...?

How can I override margin-box styles for a specific document

johnstephens
Hi!

I'm working on the style-guide for an academic journal that uses Prince. I have an `@page :first {` rule that sets the margin-box content for all of the articles, which are separate PDF files. But the Table of Contents page has different margin-box content, and I want to override my `@page :first` settings on that specific document without forking my stylesheet. Is this possible?

I applied an `id` to the `html` element on that document, and tried a rule like this, but it isn't the correct way, and Prince couldn't parse it:

#toc @page :first {
	@top-left {
		/* my styles */
	}
}


I also tried this:
#toc {
	@page :first {
		@top-left {
			/* my styles */
		}
	}
}


This would work with other selectors, but not @selectors. What's the correct way to subordinate @page or margin-boxes to other elements in the cascade?
johnstephens
I'm crafting an alternate stylesheet for the Table of Contents doc for declarations specific to that document, using @import rule to pull in the default page styles.

  • If I don't add any @page rules, Prince parses it fine, but it gives me the default @page margin-box styles.
  • If I add @page rules to customize the style, those render, but Prince stops parsing the document.

Is there any solution to this conundrum?
oliof
if you wrap your TOC in a div, you can do this:

@page toc {
   margin: x y z a ; 
}

div.toc {
  page: toc ;
  …
}


That way you can change any page related properties.
johnstephens
Thanks! I shall keep this pattern in mind for next time. I wound up using an alternate stylesheet and importing the original.