Maybe this is a good time to go over the page breaks capabilities in CSS and what iBooks supports. While they don't give absolute control over where elements appear on a page, they have an enormous influence on how professional the page looks. (Note the design of these pages is bare-bones, the emphasis is on page breaks.)
The three CSS properties are
page-break-before
, page-break-after
, and page-break-inside
. Each one can take values of auto
, always
, and avoid
, and the first two also accept left
and right
, though iBooks does not yet support those values.If you want a title to appear alone on a page, you could use
.title {
page-break-before: always;
page-break-after: always;
}
but note that if that is the first page in your EPUB, iBooks will show a blank page at the beginning (since it creates a page break before your title). In which case, you should only use:
.title {
page-break-after: always;
}
In order to make a header always start at the top of the page (together with the content that follows it), use:
.header {
page-break-before: always;
page-break-after: avoid;
}
And if you want to keep a photograph with its caption, you could use
.group {
page-break-inside: avoid;
}
assuming that you've got a div with class="group" that contains both the image and the caption.
It would be really, really nice if iBooks would support the CSS
widows
and orphans
properties. But it doesn't yet. (NOOK does, yay.)
Liz are you using the group option from with in InDesign 5.5 to apply your break options, or hard coding. I find I can use the feature inside of InDesign, but have noticed in the Article's panel that sometimes the order of image, caption, photographer may not stay in the order expected. Just curious if you and/or others have noted this.
ReplyDeleteHi Doug. InDesign doesn't export any of the Keep options to EPUB, unfortunately. So, these examples shown above are all hard-coded. When you say "I find I can use the feature inside of InDesign" what do you mean? Which feature are you talking about? And are you also saying that ID sometimes exports in an order that's not what you have specified in the Articles panel? Even when you've chosen Same as Articles Panel in the Export Options box?
ReplyDeleteI can group the image with the caption text and drag it to the article panel for exporting. I've noticed if you expand the group indicator in the article panel that sometimes the caption shows out order, causing the caption, then the image to show up in the export in reverse order. I am not positive if ID is doing this or if it has to do with the way I group the objects. I normally select the image first,so would expect it to show up first.
ReplyDeleteAlso in ID's export to EPUB there's are some break controls listed under the Image options: like [] Insert Page Break Before Image (or after, or both); with []Settings Apply to Anchored Objects. I haven't experimented enough to discover if these options provide good enough results, or are more apt to cause problems. I am curious to what extent using IN 5.5 is a plus to creating EPUBs versus having to just hard code.
I'm curious too. Been doing lots and lots and lots of tests. Should have results and a report this week :)
ReplyDeleteI cannot get headings with "page-break-after: avoid" to move to next page when there's too little space for a line of following text. Depending on the type size, they can regularly get left behind. I've tried removing any anchors in the heading2s, fiddling with margins, removing borders, but they can be left behind even when they are in plainest vanilla format.
ReplyDeleteI can bump them over with page-break before, but that's sometimes awkward looking.
I wonder if it could be connected to the other font-size problems in iBooks?
I've gotten so frustrated with not being able to control page breaks consistently and predictably that I've gotten into the habit of placing stand-alone section/chapter heads, stand-alone images, new chapters/sections, etc. in separate xhtml files. I don't find that the page-break-before/after style properties work predictably enough to be worth playing with--especially when I'm going to be porting a book over to the Kindle. (However, page-break-inside:avoid seems to work consistently, thank goodness.) This is a drag, because, obviously, it would be nice to be able to handle this in a style sheet rather than hard-coded into the ebook so that global changes can be made easily.
ReplyDeleteHi
DeleteGreat post because it addresses the most common problems with ebook readers! However, the page-break-inside:avoid property along with div tags does not work at any of the Kindle readers I tested it on :( I have made many different sample codes but neighter of them made the text flow together with the image :(
We had some pages in which we had used divs with display:inline-block to control breaks. In a later iteration of CSS development, we had added page-break-inside:avoid to a div containing an image and caption. The recent update by Apple made the pages go weird on us. Investigation showed an interaction between use of the display:inline-block and page-break-inside:avoid seemed like the cause of the issues we were seeing (which looked like page-break-inside:avoid had quit working, as we saw images breaking across screens).
ReplyDeleteWe removed the display:inline-block we were using to keep outer div content together and used just page-break-inside:avoid and the problems cleared up. Your mileage may vary. I can't post an example because it's customer content.
Weird thing ...
ReplyDeleteI added pagebreaks after and before images with the epub code and it worked fine on the Kobo reader when I have only one html file (document option ID). When I use the book feature of ID, though, the Kobo reader ignores all pagebreaks. Is there a fix? The breaks work on ADE and firefox e-reader.
Thanks
For whatever reason but it works fine when not using the book feature and thanks to the picture options pagebreaks before and after and the paragraph style pagebreaks, I still get the format.
ReplyDeleteI was concerned that the html file would get too big but ID breaks them up now. Go ID.
Liz - I just took Anne-Marie's Lynda course and know just enough to get myself into trouble. I sat down to try to format my manuscript for a .mobi export and realized, to the shorting out of my brain, that the inDesign mobi export doesn't have a nice check box for page breaks before that certain paragraph style designation. So what is a .mobi person supposed to do if she's exporting directly to mobi rather than exporting an epub and then converting?
ReplyDeleteExport to EPUB and then use Kindle Previewer to convert.
DeleteWell, that kind of seems obvious, then. It's just so much to take in all at once. I'm a writer of stories, not so much code. Though I do love code. Thanks Liz. It's like getting an answer from a rock star, actually.
ReplyDelete:) thankfully Kindle Previewer doesn't make you look at the code.
DeleteOkay - here's how you do it (thank you Anne): First of all, I had hard page breaks in my Word (mac 2007 or 3 or whatever) .rtf file. And they came over quite nicely. But you go into the layout menu and click on TOC styles. That's where you can designate the paragraph style that will show up in the TOC - worked beautifully. But now I run aground, because - okay, did the pages break because of the imported page breaks, or because of the effects of the TOC. I'll have to look at this Monday and play with it some more. Sorry. Thought I had it all figured out.
DeleteI am new to all of this and I created a epub for ibook (out from indesign cs5.5) that looked perfect in proofer and all the page breaks were working (some of them were new HTML files and some CSS). And after the three week approval process the one that went on sale did not respect any of the CSS coded breaks—using the same code you have above. Any insight? I am baffled.
ReplyDeleteHi Kat,
DeleteYou say it's on sale - how are you looking at your content? Is it by any chance on Apple iBookstore by downloading a free sample?
The reason I ask is that I have noticed that my breaks get ignored in Apple's free sample, but when I download the whole book (i.e. pay), the breaks are there. Weird. One way to avoid this is to supply your own free sample - choose some of your content and make a mini epub for Apple as a free sample.
Make sense?
Liz: I am a long-time designer just getting into converting InDesign pubs into the ePUB format. I have done much reading but still have trouble understanding why an ePUB needs to 2 Tables of Content. Just seems redundant (even confusing). Can you explain? Thanks. John
ReplyDeleteThanks so much for tips on page breaks. I used them in my book “Knee Deep in Pain” on Kindle. I was able to get chapters to start on fresh pages. It made a huge difference in the layout.
ReplyDeleteMany thanks and regards.
Dear all!
ReplyDeleteI have been working on a page break problem for a long time now...
There are some images which take basically the whole screen on some readers. I have not managed to get the caption on the same page, i.e. to have the image resized automatically so that the caption fits onto the page. Neither a div container, nor working with pagebreak avoid / inline block is working on Kindle reader...
Does anyone have a solution?
Ooh - To the Anonymous post directly above (14th Oct '12), I'm having the same issue. Applying page-break-inside:avoid; to divs containing an image+caption works... UNLESS the image has a taller aspect ratio And native height than the eReader page. In these cases, iBooks (can't vouch for Kindle, yet) forces the caption to split from the image. I have the query posted out on another forum so will post back here if I have any joy.
ReplyDelete@Doug N Washington (I realise yours is an old post but I'll chip in anyway): I was having this problem too. As far as I can tell, when you group objects, InDesign uses layer order to determine which object appears first in Articles. If your images and captions are on separate layers, ensure your image layer is above captions. When you group, the image will appear first in Articles.
@Mark and @Anonymous, same with me. I usually use images with width:100% / height:100% and many portrait format images - as Mark said which are taller than native eReader size - are split from the caption.
ReplyDeleteI'd be very glad to read a good post/article about that problem!
Hello!
ReplyDeleteI am curious...I am using this to add a page break before an image in my epub:
div.frame-7 {
margin:0px auto 0px auto;
page-break-before:always;
text-align:center;
}
Works fine on my ipad and no worries with epub check or iTunes producer's own validation but I have a ticket saying the page break is being ignored. Any ideas why this might be occuring?
Thanks,
Ben
Hi Liz,
ReplyDeleteI have also been having issues with captions displaying above images when using InDesign's Export for Kindle plugin. I found that this occurs when the caption is wider than the image. I solved it by making the frame around my graphics at least as wide as the frame around my captions. Then, I group those items (choosing the image first), cut them, paste them into the text, and center them using the Anchor function.
I struggled with this for a while, and I hope this helps folks out! Heather