Domanda

I've been editing a book in Pages and when I export it into an ePub document the line breaks I have inserted into the document seem to be ignored.

I've resigned messing with the formatting in Pages and have started editing the ePub with Sigil. What parameters do I need to edit to prevent orphan lines or to insert page breaks into my ePub document?

After researching the iBook documentation I found that inserting the css tag: page-break-before:always;

Specifically, I'm working on a cookbook and wanted to have each recipe on its own page. Using iWork I was not able to achieve the effect without a little tinkering. I opened the exported ePub document with calibre (Sigil seemed to mess the books formatting) after first creating a header tag for the first recipe and a separate header tag for the other recipes in the chapter. I then located the tag generated by iWork and added h1.s4 { page-break-before:always; } to the css file.

È stato utile?

Soluzione

Do you really mean "line breaks", not "page breaks"?

The only completely reliable way to enforce page breaks is to prepare separate XHTML files.

Beyond that, you're on your own. You've entered "iOS as the new IE6" hell. You'll find people telling you to put a page-break-before on the header tag, or page-break-after on the last bit of the previous page, or wrap everything to go one page in a block with the property display: inline-block. Any or all of these might or might not work depending on the reader, its version, or the time of day, and they might not work now and start working magically in the future, or work now and stop working magically in the future. My suggestion is to stop trying to reverse-engineer iBooks to see what works or doesn't, and just go to separate XHTML files.

Depending on your needs and skill level, you can write XSL-based tools which split apart XHTML files into separate files (perhaps based on a custom attribute such as myns:page-break='yes') to ensure you get those page breaks where you want them.

I strongly recommend against manual insertion of page-break-* properties to handle orphans. At some point, ebook readers will support the CSS orphans property. Until then, it's a fools errand. If you are so intent on obtaining the precise layout you want, you'll need to go to fixed-layout.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top