Jonathan Strange
Jonathan Strange

Reputation: 111

How do I add page breaks to epub with Pandoc?

I have created a .css file with these contents:

h1 { font-size: 120%; text-align: center;}
h2 {page-break-before: always; font-size: 120%; text-align: center;}

Using Pandoc I apply that style sheet with the --css flag. The css is present in the output file, and h1 and h2 headers are center aligned as expected, but there are only page breaks at h1 headers, which appears to be Pandoc's default. How do I get h2 headers to start on a new page as well?

Upvotes: 0

Views: 796

Answers (1)

tarleb
tarleb

Reputation: 22699

You're doing everything right. Ebook readers only implement a subset of CSS, and there is a good change that the one you are using doesn't support the page-break-before property. There might be better support for break-before. From what I've heard, some readers seem to hard-code the page-break behavior of heading elements with no option to override.

Upvotes: 1

Related Questions