6

For the Kindle book I'm producing, I would like to have the .ncx ebook table of contents and an html table of contents as part of the book.

However, TeX4ebook doesn't include the html TOC (in this example, toctestli1.html) in the epub. Is there a way to get it to do so?

Here is my MWE:

\documentclass[]{book}
\begin{document}
\tableofcontents
\chapter{One}
This is one\par
tra la la\par
\chapter{Two}
This is two\par
boodledy-boodledy\par
\end{document}

Using this config file:

\Preamble{xhtml}
\CutAt{chapter}
\begin{document}
\EndPreamble

(Incidentally, tex4ebook seems to just discard the html toc, because it will include subsections in the .ncx toc, even when they are excluded from the html toc)

Also, I do not have enough reputation to add TeX4ebook as a tag, but perhaps someone else could do so? I think I will have a number of other questions related to it. Thanks!

2

I looked into this issue and updated tex4ebook so it should work now. To add some background about the issue. Because of memory limits of e-readers, it is good to break ebook files into smaller chunks, so each chapter or section is in a standalone file.

In our example, following file structure is created:

toctest.html
   -> blank file

toctestli1.html
    -> table of contents

toctestch1-html
    -> chapter 1

toctestch2.html

table of contents is in standalone file, because files are are split even at starred chapters. file toctest.html is empty because there is no text outside chapters. this is because you haven't used \coverimage and/or \maketitle which are placed here normally.

The reason why \tableofcontents wasn't visible is that reading order was governed by modified tableofcotents command, which generated list of used files. But this tableofcontents didn't include starred chapters and sections, as well as other html files (for example footnotes generate separate files by default). All these files not included in tableofcontents were added in postprocessing with special attribute which causes them to not be included in normal browsing (you could find them only with link, for example the footnotes).

Fix for this issue is to path every sectioning command to register current filename in reading order. All cut files should be included in reading order now, but other files, like footnotes should be still accessible only with links.

  • Sorry for the long delay thanking you for this. I thought that I would have my next related question very quickly but I didn't. Posting it now in separate question. Your help is very much appreciated! – Nat Kuhn Oct 27 '14 at 15:41
  • I met a strange issue which seems related to this. If I have some unnumbered sections and I compile it with tex4ebook -f mobi, the unnumbered sections appears at the last of the book in the generated epub file and mobi file. Without option "-f mobi", the order of sections is correct. Is this issue known before? – Yai0Phah Jan 16 at 16:43
  • @FrankScience no, I don't know about this issue. can you please make an example? – michal.h21 Jan 16 at 17:05
  • It seems very general. Just a tex file including \section*{Test1}Test1 followed by \section{Test2}Test2 will lead to this (tex4ebook -f mobi foo). I see files fooli*.html including these unnumbered sections. tex4ebook version 0.1d – Yai0Phah Jan 16 at 17:24
  • @FrankScience There may be some issue with used packages, simple test with one numbered and one unnumbered sections seems to work as expected. – michal.h21 Jan 16 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.