Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 09-15-2019, 09:05 AM   #1
Reader Bill
Junior Member
Reader Bill began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Sep 2019
Device: iPhone
Inserting Page Breaks At Chapters

I have several books that are in ePub format, but which lack chapters in the TOC. Also, the chapters in the text of the book do not begin on a new page. I have been able to add the chapters to the TOC by using the TOC editor, generating TOC from XPath and entering "Chapter" in the Value (new chapters all begin with the word Chapter). This gives me a list of the word chapter from which I can delete the spots where "chapter" appears in the text of the book and then mass renumber the rest. That seems to work fine. I can't however figure out how to make each chapter appear at the top of a new page. I'm thinking I should be able to edit the book and do a search and replace on "Chapter" inserting a page break (looking at each instance to make sure it was really the beginning of a chapter), but I can't figure out how to do that. Can anyone help? Also, is there an easier way to accomplish the TOC? A sample of the code at the point of chapter change is below...

<p> I walked stiffly through the house, through the kitchen to the backyard and my parked pickup truck. When I turned the ignition, I looked through the windshield and saw her watching me through the back screen, biting the comer of her lip as though her next option was just now presenting itself.</p>
<div class="newpage" id="page-69"></div>
<p id="toc_7"> CHAPTER</p>
<p> |t rained all that night. At false dawn a white ground fog rolled out of the swamp, and the cypress trees on the far bank of the bayou looked as black and hard as carved stone. Deep inside the fog you could hear bass flopping back in the bays. When the sun broke above the horizon, like a red diamond splintering apart between the tree trunks, Batist and I were still bailing out the rental boats with coffee cans. Then we heard a car on the road, and when we looked up we saw a purple Lincoln Continental, with Sabelle Crown in the passenger's seat, stop and back up by our concrete boat ramp.</p>
Reader Bill is offline   Reply With Quote
Old 09-15-2019, 10:23 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,801
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Use the Wizard that is part of Split at Multiple Locations (right click in the Text area) or manually Split using the Preview window (the Icon to engage the mode is 2 pages with green arrows. Where you place the Green line, then click is the Split location.

Joins are done in the File Browser list
Right-click Context menus are your friend (almost in any app)
theducks is offline   Reply With Quote
Old 09-16-2019, 12:22 AM   #3
Reader Bill
Junior Member
Reader Bill began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Sep 2019
Device: iPhone
I was hoping to be able to do this without splitting the files as there are a large number of chapters. Is it possible to do it with a search and replace with tags?
Reader Bill is offline   Reply With Quote
Old 09-16-2019, 06:08 AM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,801
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
from your code
Code:
<div class="newpage" id="page-69"></div>
Look in your CSS. at: .newpage {
there probably is a page-break-before: always; in there someplace.
make sure there are no syntax errors in your css as some device go into ignore CSS mode when it hits one,

And Why no splitting? That make thing simpler, load and run the section faster
theducks is offline   Reply With Quote
Old 09-16-2019, 08:44 AM   #5
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
@Reader Bill
Quote:
I was hoping to be able to do this without splitting the files as there are a large number of chapters.
Correcting the problem of not having chapters begin at the top of a page with lots of chapters is really tedious. I've done it. I now use a counter-intuitive trick that might be applied to your situation.
1) select all the files in the file browser that contain chapter content
2) right-click and select "merge selected text files"
3) after merging, right-click in that new file and follow the "split at multiple locations" wizard as theducks advised.

If I have understood your problem correctly, this will save a heap of work and all the chapters in your reader will begin where you expect them to begin.

Last edited by Brett Merkey; 09-16-2019 at 08:49 AM.
Brett Merkey is offline   Reply With Quote
Old 09-16-2019, 10:28 AM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,801
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Brett Merkey View Post
@Reader Bill

Correcting the problem of not having chapters begin at the top of a page with lots of chapters is really tedious. I've done it. I now use a counter-intuitive trick that might be applied to your situation.
1) select all the files in the file browser that contain chapter content
2) right-click and select "merge selected text files"
3) after merging, right-click in that new file and follow the "split at multiple locations" wizard as theducks advised.

If I have understood your problem correctly, this will save a heap of work and all the chapters in your reader will begin where you expect them to begin.
You don't even need to do the initial join.
After the bulk split, check for orphans in the file browser. they will not have the additions to their file name (and they won't USUALLY be the first files if you started with more because the used the old keep it under 260K rule of thumb). You should only have a few of these to fix, even when doing a BIG book
theducks is offline   Reply With Quote
Old 09-16-2019, 05:53 PM   #7
Reader Bill
Junior Member
Reader Bill began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Sep 2019
Device: iPhone
Figured another approach to the table of contents. I changed all the chapter tags from <p> to <h2>. That allows me to easily generate a TOC from "Generate TOC From All Headings". It also makes the chapters much more obvious which helps with readability. With the <h2> tags in place, will that allow me to insert page breaks for my new pages without having to split files? I was under the impression that the conversion process is able to read the <h2> tag. Code at chapter change now looks like...

<p>You'll have a set of orders in two weeks."</p>
<div class="newpage" id="page-268"></div>
<h2 id="toc_3"> 20 The Legend and the Man</h2>
<p> As the summer weather cooled to fall, the hardwood forests that surround the Quantico rifle ranges</p>

The "newpage" class doesn't work as that tag appears extensively in between chapters, but now I have a <h2> tag as well as a id="toc_x to work with.
Reader Bill is offline   Reply With Quote
Old 09-16-2019, 06:23 PM   #8
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,801
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
FWIW don't get in the habit of STYLING by use of Headings that is really coding

CSS is the modern way to do that. Even a P tag can look the same as a default H tag with a bit of CSS
theducks is offline   Reply With Quote
Old 09-16-2019, 08:16 PM   #9
Reader Bill
Junior Member
Reader Bill began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Sep 2019
Device: iPhone
Thanks TheDucks and all others for your help.

I played around with it a bit, and with the h2 tags in I was able to put a...

h2 {

page-break-before: always;

}

in my CSS stylesheet and now I have exactly what I want. Has improved the readability tremendously.

Thanks again.
Reader Bill is offline   Reply With Quote
Old 09-20-2019, 08:29 AM   #10
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Your solution is one alternative, Reader Bill, but if you use the class "chapter" for every chapter title, and then convert the file, Calibre Convert will automatically place each chapter at the beginning of a new page (without having to enter the "page-break-before" code). You can also use the Generate TOC from Xpath function to create the TOC by pasting the following in the Level 1 TOC line (before opening the Wizard--my macro for the following line is ctrl-alt-T).

//h[re:test(@class, "chapter", "i")] (The beginning of this line should be / / h : p -- or -- / / h : h 1 --without the spaces.)

Here is the coding for chapter titles:

<p class="chapter">Chapter 1</p>

If you learn how to use classes for all the sections in a book and place the codes for each class in the CSS file, it will be much easier for you to configure how you want each section, as compared to using only <p> for everything.

Here's a sample coding for "chapter" in the CSS file:

.chapter {
display: block;
font-size: 1.4em;
font-weight: bold;
text-align: center;
margin-bottom: 2em;
margin-left: 0;
margin-right: 0;
margin-top: 3em;
}

Last edited by deback; 09-20-2019 at 08:40 AM.
deback is offline   Reply With Quote
Reply

Tags
chapter, epub, html, page break


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ebook-convert (docx->html) inserting too many page breaks xanguera Conversion 3 07-31-2015 08:05 PM
inserting a "ruled Line" /chapter and page breaks tscamera Calibre 3 01-05-2011 04:47 PM
Kindle inserting page breaks? december Calibre 8 07-15-2010 09:47 AM
Pocketbook: No page breaks between chapters. Oxford-eBooks PocketBook 20 05-12-2010 12:53 AM
Chapters and page breaks in TXT files scarab1 Ectaco jetBook 0 03-06-2010 02:08 PM


All times are GMT -4. The time now is 02:57 PM.


MobileRead.com is a privately owned, operated and funded community.