View Single Post
Old 06-12-2020, 04:09 PM   #2
retiredbiker
Evangelist
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 451
Karma: 3886916
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Kobo Forma
A pretty simple way I use is this: Load whatever text you want as your chapter into LO Writer. (I assume Writer since you're on Linux.) Style it so it is similar to your existing epub book. I say similar, because it will never be exact...you just want styles where you need them, like an h1 or h2 for the title, some sort of p for the paragraphs, maybe a no-indent, quotation, verse, center, whatever styles you need. Your goal here is to just get some unique style everywhere you need it.

[If you are starting with some horribly formatted old Word or web text, Ctrl-m (remove all ad-hoc formatting) is your friend in Writer.]

Save it as either .odt or .docx. Add it to Calibre as a new book. Convert to epub.

Don't worry about metadata or anything, just open it in the editor. Your new chapter text should be in a nice html file. (More than one if it is very, very long...unlikely.). Rename it to match the book you're adding to, say "mynewchapter.xhtml". Export it. Close the editor.

Now open your target book in the editor. Import the file you just exported. Drag it to the location in the file stack where you want it.[*] Then open the new file, and change the class coding to match the rest of the book. Unless it is a very complicated work, you should only have a few changes to make, mostly using search and replace. For example, you might have to search the new file for <p class="p-p3> (some paragraph type) and replace it with <p class="indent"> (how that paragraph type is coded in the rest of the target book). When you are done, the styling will be identical to the rest of the book...that's why you only needed to be approximate in the Writer styling.

If you have some unique style in your new chapter that does not exist in the target book, add it to the css. You can copy that from the temporary "book" you made.

When you're happy with it, delete the temporary "book" you converted.

It should work equally well in Calibre or Sigil--maybe just minor working details. Word can do the job as well as Writer, too, if you have it.

Edit:[*] a step I missed here: link the stylesheet to the new file (right-click on the file in the file browser, link is down at the bottom).

Last edited by retiredbiker; 06-12-2020 at 05:27 PM.
retiredbiker is offline   Reply With Quote