10-16-2020, 05:38 AM | #1 |
Connoisseur
Posts: 70
Karma: 2119794
Join Date: Feb 2020
Location: Colorado
Device: Kobo Libra H20
|
Where do displayed chapter titles come from?
I have some text file renderings of books that I'm running through a python script to break up into chapters and generate epubs. I'm just getting started, but so far, I break it up and format the content into chapter html files, generate container.xml and content.opf, then zip it up along with a standard css file. Still to do is to generate a table of contents and add a cover image.
When I load the epub (using calibre, which is converting to kepub) onto my Kobo Libra, it looks great, except that the chapter titles shown are the actual html filenames. In each hmtl file I have a <title> tag in the header (with "Chapter One", "Chapter Two", etc.), which is where I assumed it would get this data, but apparently not. My content.opf is pretty simple, along with headers and metadata, it looks like: Code:
<manifest> <item href="chapter00.html" id="chapter00" media-type="application/xhtml+xml"/> <item href="chapter01.html" id="chapter01" media-type="application/xhtml+xml"/> </manifest> <spine> <itemref idref="chapter00"/> <itemref idref="chapter01"/> </spine Last edited by JJ Johnson; 10-16-2020 at 05:51 AM. |
10-16-2020, 08:34 AM | #2 |
Grand Sorcerer
Posts: 6,496
Karma: 84420419
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
Technically your book has no chapters so calibre is creating its own from the file names.
For EPUB 2 you need to create an NCX file. For EPUB 3 you need a navigation document, with NCX being an optional fallback. |
10-16-2020, 01:20 PM | #3 |
Running with scissors
Posts: 1,552
Karma: 14325282
Join Date: Nov 2019
Device: none
|
If you want to eyeball a well formed epub 2 or epub 3 you could use Calibre's editor or Sigil; I use the latter. Add an h2 at the start of each file. Then, in Sigil, use Ctl-T to generate a table of contents from the h2 tags. I prefer to make epub 3s so after I generate the table of contents, in Sigil's Tools menu I run the first two items in the Tools > Epub 3 tools menu; Generate ... and Update ... so that I get the optional fallback that jhowell mentioned. With Sigil you can have it start a new epub as either epub 3 or epub 2
|
10-16-2020, 01:35 PM | #4 | |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
10-16-2020, 05:38 PM | #5 | |
Connoisseur
Posts: 70
Karma: 2119794
Join Date: Feb 2020
Location: Colorado
Device: Kobo Libra H20
|
Quote:
I'm using epub 3. I only have a need to ever view these books on my Kobo, so I'm not too worried about backward compatibility or publishing these books. So this is mostly an exercise in learning a bit about epub structure, and also a means of honing my python skills. I'm still very fuzzy on the interplay between this navigation file, a TOC page, and the manifest and spine portions of the content.opf files. I'm sure I'll have more questions. |
|
10-16-2020, 07:49 PM | #6 |
Running with scissors
Posts: 1,552
Karma: 14325282
Join Date: Nov 2019
Device: none
|
H2 is what I use. Sometimes books have Parts and I use h1 for those titles. You could just as easily use h5 for the chapter titles. The only convention that I know of is that Sigil nests the higher numbered h tags in the lower numbered ones; e.g., h2 is nested in h1. In the table of contents the nested ones are indented. When you generate the table of contents with Ctl-T you can specify which ones to include/use so I specify h2 and h1.
|
10-16-2020, 07:56 PM | #7 | |
Connoisseur
Posts: 70
Karma: 2119794
Join Date: Feb 2020
Location: Colorado
Device: Kobo Libra H20
|
Quote:
|
|
10-16-2020, 08:09 PM | #8 | |
Running with scissors
Posts: 1,552
Karma: 14325282
Join Date: Nov 2019
Device: none
|
Quote:
<itemref idref="nav.xhtml" linear="no"/> Last edited by hobnail; 10-16-2020 at 08:18 PM. |
|
10-16-2020, 11:53 PM | #9 | |
Bibliophagist
Posts: 35,380
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Code:
h1 h2 h3 h3 h3 h4 h2 etc... Last edited by DNSB; 10-16-2020 at 11:55 PM. |
|
10-17-2020, 03:14 PM | #10 |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Most publishers use <p class="someclass">Chapter One</p> for the chapter title. But if you are wanting to make it easy to built a ToC from the chapter titles, use <h2>Chapter One</h2> and define what you want h2 to be in CSS.
|
10-17-2020, 05:50 PM | #11 |
A Hairy Wizard
Posts: 3,094
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Most Some publishers use <p class="someclass">Chapter One</p> for the chapter title....
....and I would add that although it is certainly possible to do it that way, I would recommend using the <h1-6> tags for their semantically correct purpose of providing a heading hierarchy. You can apply the exact same CSS to the <h> tags and visually it will be identical, but automated systems, accessibility systems, etc. can figure out the structure of your document much better/faster(/stronger??) if you use the proper markup. It also has the added benefit of programs like Calibre or Sigil creating the automated ToC based on your <h> tags - as has been mentioned above. Last edited by Turtle91; 10-17-2020 at 05:52 PM. |
10-17-2020, 07:15 PM | #12 |
Running with scissors
Posts: 1,552
Karma: 14325282
Join Date: Nov 2019
Device: none
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Chapter Heading formate displayed wrong in Kobo | Kaylee Skylyn | ePub | 9 | 07-26-2015 12:13 AM |
Titles displayed incorrectly in reader | anthony.burton4 | Library Management | 5 | 02-28-2013 06:12 PM |
Chapter #s or Chapter Titles? | bmcox | Writers' Corner | 33 | 02-01-2013 07:03 AM |
Ebook chapter titles: with or without chapter number? | amoroso | Writers' Corner | 16 | 06-14-2011 06:35 AM |
PRS-350 Breaks after Chapter Titles | Rand Brittain | Sony Reader | 2 | 10-25-2010 12:53 PM |