Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-13-2011, 11:07 AM   #16
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,800
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 bfollowell View Post
I like having a TOC in my ebooks, in-line for mobis for my Kindle, but I don't want to have to scroll through it at the beginning of all my books, so I always put mine at the end anyway. Like you said, where it gets put is a personal choice. You can put it whereever you want if you create it yourself but if you let Calibre create it for you, it's definitely going to be in the back. That's great for me. Maybe not so much for someone else.

- Byron
Again in Sigil. If yo find the inline TOC at the front (Split it into a seperate file, if it isn't), just drage it to the end of the Text section and Save. Play order: adjusted
theducks is offline   Reply With Quote
Old 03-13-2011, 01:57 PM   #17
Algiedi
Overenthusiastic Noob
Algiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-books
 
Algiedi's Avatar
 
Posts: 69
Karma: 896
Join Date: Feb 2011
Location: France
Device: Kindle 3
I seem to have understood that there are 2 types of TOCs - I'm not sure which one(s) you guys are talking about since I can't remember which is called what yet.

I suppose that what I was trying to do is "convert" the in-document TOC (made with anchors & links) into a NCX/OPF one - i.e. one that can be accessed through the "GoTo" Kindle menu item.

I've tried every settings combinations in Calibre and I either get 2 TOCs (my original in-document TOC + the detected, "GoTo" TOC - apparently detected automatically from existing links) or just the in-document one (unaccessible through "GoTo").

Various forum searches indicate that I could tweak the OPF file manually but yeah, I'll just stick to the TOC detection in Calibre since it's already pretty powerful.

Although I suppose that could be a nice function to have in a future version of Calibre: the possibility to have the TOC items generated from either the text between the selected tags or an "alternate" text defined in "title=" (like Sigil does).
Algiedi is offline   Reply With Quote
Old 03-13-2011, 03:16 PM   #18
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
Quote:
Originally Posted by Algiedi View Post
I seem to have understood that there are 2 types of TOCs - I'm not sure which one(s) you guys are talking about since I can't remember which is called what yet.

I suppose that what I was trying to do is "convert" the in-document TOC (made with anchors & links) into a NCX/OPF one - i.e. one that can be accessed through the "GoTo" Kindle menu item.

I've tried every settings combinations in Calibre and I either get 2 TOCs (my original in-document TOC + the detected, "GoTo" TOC - apparently detected automatically from existing links) or just the in-document one (unaccessible through "GoTo").
The one that is an actual html file in the ebook, the one made with anchors & links is the in-line TOC and that is the only one compatible with mobi. Assuming it is marked as the TOC, this is the one the Kindle pulls up when you click on Go To - Table of Contents.

The NCX type does not work with the Kindle or with mobi in general AFAIK.

If you're trying to create some sort of "menu based" TOC system that doesn't leave an actual TOC page in the ebook, you can give up on that now. AFAIK it can't be done with mobi. Mobi is a very old and simple standard, relatively speaking.

- Byron


- Byron
bfollowell is offline   Reply With Quote
Old 03-13-2011, 03:48 PM   #19
DMSmillie
Enquiring Mind
DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'
 
DMSmillie's Avatar
 
Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
Table of Contents in MOBI/Kindle ebooks

There are two ways of coding "Table of Contents" data.

One way is to code it in HTML as part of the front matter in an ebook - exactly as it would be in a printed book - with each entry in this TOC coded as a link to an HTML anchor embedded at the appropriate point in the book content. This is often referred to as an "inline TOC", and is the primary method of providing a TOC in MOBI/Kindle ebooks.

The other way is to code it in XML in an NCX file (Navigation Control XML) which is then compiled into the resulting ebook. This is sometimes referred to as a "logical TOC" or "NCX TOC", and is the primary method of providing a TOC in EPUB ebooks.

Unfortunately, those who mostly work with MOBI files (or who are not yet used to working with ebooks, and are thinking in terms of MS Word, Open Office, and other print-related formats) tend to refer to the inline TOC as "the TOC", while those who mostly work with EPUB files tend to refer to the NCX TOC as "the TOC", leading to much confusion.

In an EPUB reader (device or application), when the user chooses to view the table of contents, the EPUB reader accesses the information in the NCX file, and generates a table of contents from that information, and presents it to the user.

In a MOBI/Kindle reader (device or application), when the user chooses to view the table of contents, the MOBI/Kindle reader looks for a "guide" data item pointing to the location of the inline TOC in the ebook HTML content, and jumps to that location, displaying the table of contents to the user. That "guide" item is originally coded into an OPF file - an XML file containing metadata about the ebook - which is then compiled into the MOBI file. The data in the NCX file, on the other hand, is used by the Kindle device and applications to enable "skip to previous/next navigation point" functionality (e.g. the ability to use the 5-way control button on the Kindle to jump to the previous or next heading or chapter). The navigation points coded into the NCX file are also displayed as small dots or tick marks on the progress bar displayed at the bottom of the reading screen.

The reason you find that the TOC created by Calibre when converting your HTML files to MOBI format can be "seen" by the Kindle, is because Calibre adds the required "guide" item to the MOBI file, pointing to the TOC it created (which is an inline TOC, just one that is placed at the end of the book content). And the likely reason the Kindle isn't seeing your hand-coded inline TOC is because there is no "guide" item pointing to it (possibly no OPF file at all?).

You can certainly hand code an OPF and NCX file to accompany the HTML file(s) for your ebook, and you might decide to do that a couple of times to become familiar with the various files that go into an EPUB or MOBI ebook, but in the longer term, I'd definitely second the recommendations others have made regarding using Sigil and Calibre. Although your final goal is a MOBI version of your book(s), it's worth using EPUB as an intermediate stage, since it is easier to ensure that all the component files are present and correct, and to edit the content of these files if required.

I'd suggest switching off the "HTML Tidy" feature in Sigil to minimise the changes it makes to the HTML code (given your desire to maintain as much control as possible over the actual code ). Add your HTML file(s), then use the TOC editor to create the logical/NCX TOC, and the Metadata editor to add the required metadata (title, author and language are the minimum requirements). Sigil will take care of creating the NCX and OPF files - you won't see them in the file list on the left of the screen, but they're there in the "package" that Sigil is creating which it will zip up into the final EPUB file.
(Note: As you add your HTML file(s), Sigil will parse them, and automatically find and add any external CSS files they link to, and any image files they refer to. Unless you have included your cover image as the first page of the book content, you should then add the cover image file in the "Images" sub-directory in the left panel, and use the "Add Semantics" feature (as described below) to designate that image file as the cover image. Sigil makes its own copies of all of these files - your original files will remain where they are, and unchanged.)

There are two routes to getting the required table of contents "guide" item into the OPF file:
  • In Sigil, split your HTML content into several files, one for each logical section of the book (e.g. title page, copyright page, table of contents, dedication, foreword, each individual chapter, etc). In the file list on the left of the Sigil window, right click on the table of contents HTML file, select "Add Semantics", then designate it as the "Table of Contents". Save your EPUB file, and import it into Calibre.
  • If you prefer to keep your HTML content in a single file, add an HTML bookmark at the start of the table of contents in the HTML content. When you import the EPUB into Calibre, use Calibre's "tweak epub" feature to open up the EPUB, then open and edit the OPF file and look for a section in the file bounded by opening and closing <guide> tags, and add the following code between those tags:

    Code:
    <reference type="toc" title="Table of Contents" href="html-filename.html#toc-anchor"/>
    (If there isn't already a "guide" section in the OPF file, simply add <guide> at the start and </guide> at the end of the code shown above, and add it after the closing </spine> tag.)

    Save the amended OPF file, then re-form the EPUB.
You can now convert the EPUB file to MOBI format in Calibre, and the existence of the "toc" guide item should ensure that Calibre doesn't automatically create and add another inline TOC to the ebook. When you open the resulting MOBI file in the Kindle, the "Go To... Table of Contents" menu entry should work properly, and cause the display to jump to your hand coded inline TOC.

Last edited by DMSmillie; 03-14-2011 at 06:23 AM. Reason: minor edits for clarity
DMSmillie is offline   Reply With Quote
Old 03-20-2011, 01:57 PM   #20
Algiedi
Overenthusiastic Noob
Algiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-booksAlgiedi has learned how to read e-books
 
Algiedi's Avatar
 
Posts: 69
Karma: 896
Join Date: Feb 2011
Location: France
Device: Kindle 3
Quote:
Originally Posted by DMSmillie View Post
...
Sorry for bumping this but I really wanted to thank you for your detailed explaination. You must have spent ages writing this!
I don't expect I'll ever need any extra info on TOCs ever again. This looks like pretty much all there is to know about them.

I will definitely be saving this post on my computer to really study it carefully.

Thanks again

This post should be like, extracted and stickied or something.
Algiedi is offline   Reply With Quote
Old 03-20-2011, 03:20 PM   #21
DMSmillie
Enquiring Mind
DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'DMSmillie understands when you whisper 'The dog barks at midnight.'
 
DMSmillie's Avatar
 
Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
You're very welcome, Algiedi.

Heh... it did take me a while to write, yes. But it was a useful exercise - I kept finding myself writing bits of it over and over again in response to various questions in other threads, and now I've got it all together in one post that I can either copy and paste, or point to, in response to similar questions in future. Sheer laziness really.
DMSmillie is offline   Reply With Quote
Old 07-10-2011, 09:08 AM   #22
Skeezix
Enthusiast
Skeezix began at the beginning.
 
Posts: 28
Karma: 10
Join Date: Jun 2011
Device: Kindle
Quote:
Originally Posted by Algiedi View Post
Very simply, what I'm trying to do, converting from html to mobi is:

When the actual chapter title in the book is "1", I want the corresponding TOC line to say "Chapter 1".

Can I do this with the Calibre XPath TOC generator thingy?
This conversation kinda got complicated in a hurry, but if anyone still cares, there's an easier way to do this that doesn't involve an epub/Sigil intermediate step. Just add custom span tags:

Code:
<h2>1</h2>
<span class="chaptitle" title="Chapter 1" />
Then, just set your xpath to:
Code:
//h:span[re:test(@class, "chaptitle", "i")]
Since the span is empty, it grabs the value from the title attribute.
Skeezix is offline   Reply With Quote
Old 07-11-2011, 10:48 AM   #23
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Sorry, ignore this post

Last edited by jackie_w; 07-11-2011 at 10:53 AM.
jackie_w is offline   Reply With Quote
Old 07-23-2011, 10:54 PM   #24
Skeezix
Enthusiast
Skeezix began at the beginning.
 
Posts: 28
Karma: 10
Join Date: Jun 2011
Device: Kindle
Quote:
Originally Posted by Algiedi View Post
When the actual chapter title in the book is "1", I want the corresponding TOC line to say "Chapter 1".
Just thought of another way you could do this:

<h2><span style="display: none">Chapter </span>1</h2>

Of course, that won't work in all cases, but it will for your example.
Skeezix is offline   Reply With Quote
Old 07-24-2011, 01:06 AM   #25
Dellu
Member
Dellu began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jul 2011
Device: Nook Simple Touch
Doesn's seem working

Quote:
There are two routes to getting the required table of contents "guide" item into the OPF file:
  • In Sigil, split your HTML content into several files, one for each logical section of the book (e.g. title page, copyright page, table of contents, dedication, foreword, each individual chapter, etc). In the file list on the left of the Sigil window, right click on the table of contents HTML file, select "Add Semantics", then designate it as the "Table of Contents". Save your EPUB file, and import it into Calibre.
  • If you prefer to keep your HTML content in a single file, add an HTML bookmark at the start of the table of contents in the HTML content. When you import the EPUB into Calibre, use Calibre's "tweak epub" feature to open up the EPUB, then open and edit the OPF file and look for a section in the file bounded by opening and closing <guide> tags, and add the following code between those tags:

    Code:
    <reference type="toc" title="Table of Contents" href="html-filename.html#toc-anchor"/>
    (If there isn't already a "guide" section in the OPF file, simply add <guide> at the start and </guide> at the end of the code shown above, and add it after the closing </spine> tag.)

    Save the amended OPF file, then re-form the EPUB.
You can now convert the EPUB file to MOBI format in Calibre, and the existence of the "toc" guide item should ensure that Calibre doesn't automatically create and add another inline TOC to the ebook. When you open the resulting MOBI file in the Kindle, the "Go To... Table of Contents" menu entry should work properly, and cause the display to jump to your hand coded inline TOC.
Thanks for the wonderful explanation. I really want the last option. I have a dozen of books to convert to epub. Marking the headings of each of the contents in Sigil is more time consuming. Since my html has inline bookmarks (contents), the last approach seems to promising. I edited the OPF file as you instructed. But, I couldn't get any Content(Table of contents) in my e-reader.

Last edited by Dellu; 07-24-2011 at 01:15 AM.
Dellu is offline   Reply With Quote
Old 07-24-2011, 01:12 AM   #26
Dellu
Member
Dellu began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jul 2011
Device: Nook Simple Touch
Thanks for the wonderful explanation. I really want the last option. I have a dozen of books to convert to epub. Marking the headings of each of the contents in Sigil is more time consuming. Since my html has inline bookmarks (contents), the last approach seems to promising. I edited the OPF file as you instructed. But, I couldn't get any Content(Table of contents) in my e-reader.


Last edited by Dellu; 07-24-2011 at 01:17 AM.
Dellu is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre settings for using 'chapter' in TOC TargonD Calibre 13 11-03-2010 08:57 PM
Les Miserables - TOC / Chapter Flags? gshipley Amazon Kindle 1 09-28-2009 10:07 PM
ADE and long chapter names in ToC frabjous Reading and Management 3 08-14-2009 11:16 AM
Chapter or TOC Creation help needed gandor62 Calibre 4 04-15-2009 02:18 PM
html2epub TOC and chapter detection help ilovejedd Calibre 6 02-22-2009 05:58 PM


All times are GMT -4. The time now is 11:23 AM.


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