What is a reasonable course to convert a novel from latex to epub/azw?

I need to convert a novel (NO math, but lots of citations and direct speech) from current PDF/printed paper to high-quality epub/azw4 to publish as eBook.

Current layout is based on memoir and quotmark.

I know I can use htlatex to produce a reasonable output, but that is not really satisfactory because it produces a single .html file with little control over chapters that do not behave "as expected" (i.e.: start a chapter at top of page and not like a "continuous ribbon").

I would like to have a behavior similar to standard Kindle Create output (I tried going the latex->docx->KindleCreate way, but it messes badly with direct speech and "maiuscoletto" I use heavily (using Italian language might add noise to process as MSWord has "localized" Style names possibly unknown to other tools).

Can someone suggest a viable alternative?

I did not find a suitable answer perusing similar questions.

• Acording to kdp.amazon.com/en_US/help/topic/GUGQ4WDZ92F733GC#trouble your best choice is possibly PdfLaTeX (non reflowable PDF) to Complex Textbook but the price is a more limited range of hardware (However it seems to be the majority of current reader applications) best way is to use the preview functionality
– user170109
Apr 20, 2019 at 2:13
• I have an epub output format on my latex-to-xyz code, which can be found at github.com/loopspace/latex-to-internet It is somewhat experimental. Apr 20, 2019 at 7:24

tex4ebook can produce ePub, ePub3 and mobi formats from LaTeX sources. It uses tex4ht (the same system as htlatex uses) for the LaTeX to HTML conversion. The HTML files are then processed and packed to produce the requested output. It needs the kindlegen command installed for the mobi output.

Basic usage:

tex4ebook -f epub3 filename.tex


You may want to add some custom metadata, cover image or a nice CSS. It can be added using a configuration file:

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


Save the file as myconfig.cfg and require it in tex4ebook using the following command:

tex4ebook -c myconfig.cfg filename.tex


The config file adds a cover image named conver.png (it must exist in the current directory) and the CSS file provided by The Blitz Framework. You may add how many CSS files you want using the \Configure{AddCss}

BTW, even htlatex can produce separate HTML files for each chapter:

htlatex filename.tex "xhtml,2"


The number in the last parameter specifies at which sectioning levels should be the files partitioned, there are four possible levels (up to \subsection I think). It produces some navigation in each file, which is not that useful in ebooks. tex4ebook removes the navigation, so it is still preferable to use it instead of htlatex.

• Thanks. This seems to be exactly what I need. I will need to tweak a bit \frontmatter and insert a few images. Can You suggest the right style to get a properly formatted e-book? Note: my volume is quite large (>700 pages) and divided in three \part; what is the right way to put cover/description/author info in an e-book? Apr 20, 2019 at 12:10
• @ZioByte I've updated my answer. The author and title should be included automatically from the \title and \author commands. Apr 20, 2019 at 18:39
• I'm having problems with images (in the text, not cover; inserted using \includegraphics): they disappear from tex4ebook completely (I didn't find any reference to the files in logs). Can You divine what's happening or should I issue another Question? Apr 21, 2019 at 10:56
• @ZioByte do you use the image extensions in \includedraphics? if not, you may need to add the \DeclareGraphicsExtensions{.svg,.png,.jpg,.pdf} command to the configuration file. It it doesn't help, it would be best to post a new question. Apr 21, 2019 at 15:36