![]() |
#1 |
Member
![]() Posts: 13
Karma: 10
Join Date: Dec 2023
Device: none
|
keep header with following text
Hi all,
There has to be a simple fix for this, right? Titles/headers at the bottom of the page with the text starting on the next. How to keep them together! I use CSS "page break: avoid" to little luck. Is there extra code that needs to be added? Or do we simply accept that ebooks are wonky? Thanks |
![]() |
![]() |
![]() |
#2 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,779
Karma: 6000000
Join Date: Nov 2009
Device: many
|
In epubs, you typically start each chapter in its own new file. Each file automatically starts on a new page so chapter title and headings all work. That still leaves subheadings. For sub headings, can wrap them in a div and set css widows and orphans properties for that block. You can also try setting css pagebreak options before. For graphics you can try figure and figcaption to keep them together or float text around them.
|
![]() |
![]() |
![]() |
#3 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,784
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
1. In your .css stylesheet: Code:
.noBreakAfter { -webkit-column-break-after: avoid; /* This is for epub3, epub2 ebooks will ignore it */ page-break-after: avoid; /* This is for epub2; epub3 ebooks will ignore it */ break-after: avoid; /* Also for epub3 */ } Code:
<h2 class="noBreakAfter">Your title here</h2> <p>Your following text here ... </p> Code:
h1, h2, h3, h4, h5, h6 { -webkit-column-break-after: avoid; page-break-after: avoid; break-after: avoid; } Last edited by RbnJrg; 07-24-2025 at 09:32 PM. |
|
![]() |
![]() |
![]() |
#4 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,106
Karma: 105211945
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Only starting a new file at a header works on everything.
Yes, real reflowable ebook formats are more limited than paper or PDF due to the combination of unknown screen size/resolution, user selected font size, user selected margins and line spacing and pagination rather than stupid endless scroll of web pages. |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,784
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Yes, of course. But there may be subheadings within a single chapter that, if they start on a new page, could disrupt the flow of the story. In these cases, it's helpful to have a way to avoid a page break immediately after those subheadings. ADE 2.x honors "page-break-after: avoid" since always and now ereaders based on webkit/readium finally gave support to "-webkit-column-break-after: avoid", so virtually any halfway decent e-reader can avoid a page break after a heading.
But there are still some "tricks" that allow you to avoid page breaks even without appealing to those properties, with simple CSS 2.0 declarations (that is 1998, the prehistory of CSS) that work on any e-reader that supports the margin and padding properties (and I find it hard to imagine that there is an e-reader that doesn't support them). |
![]() |
![]() |
![]() |
#6 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,106
Karma: 105211945
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
As ever ebook formats were initially only designed with novels in mind. Really most of the need for headings not starting on a new page is non-fiction, and even reflowable epub3 is still poor for scholarly works or textbooks, which is why those often use PDF.
I know about what you mention @RbnJrg, but fortunately it's only in notes / appendix of stuff I create that it would be needed and one option is to ignore it as long as the main content is OK ![]() |
![]() |
![]() |
![]() |
#7 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 324
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
|
I use break-after:avoid and it has never failed me. It works well both in epub and after the epub has been converted via calibre to pdf for printing. I use it on centered, bold one-liners of <div style="break-after:avoid">…</div>. This also works well if you want to keep top-caption always together with image below it. (I must admit top-captioned images are less common than images followed by bottom captions.) For the most part I find it more useful to have an image with a bottom AND top caption. I use break-after:avoid as a class and pop it into place with a calibre snippet.
|
![]() |
![]() |
![]() |
#8 | |||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,784
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Quote:
The interesting thing about this is that those screenshots are from an epub2 opened in KOReader! When the book doesn't have images and its design isn't too complicated (I mean, it doesn't have a dynamic layout that needs to change depending on the e-reader's screen size and the font size used by the user), the epub2 protocol can still compete with epub3, even for technical and non-fiction books. Quote:
|
|||
![]() |
![]() |
![]() |
#9 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,106
Karma: 105211945
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Or page breaks that are too annoying.
I think we are on the same page ![]() |
![]() |
![]() |
![]() |
Tags |
header text keep together |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change the header/footer text size. | bmcs | Calibre | 2 | 03-09-2020 06:13 AM |
Possible to remove header text? | eTIPS | Kindle Formats | 2 | 08-19-2015 06:33 AM |
Stripping a file from header text? | norweger | 8 | 03-11-2015 03:49 PM | |
Getting text length from mobi header. | mattst | Kindle Formats | 7 | 03-29-2012 06:31 AM |
PDF Conversion - Removing Header / Footer Text | heb | Sony Reader | 9 | 07-11-2010 11:02 PM |