LaTeX document to epub or mobi ebook formats (with mathematical formulas)

tex4ht does an excellent job at converting LaTeX to (X)HTML, and it can convert math to either bitmap or MathML in the process. From there, you can use Calibre to convert the HTML to EPUB or MOBI.

For example, if you want to produce XHTML with MathML, using UTF-8 encoding, you can do:

mk4ht htlatex youfile.tex 'xhtml,charset=utf-8,pmathml' ' -cunihtf -utf8 -cvalidate'

See the documentation for more examples.

On Wikipedia's LaTeX example, this produces a MOBI file which looks like this in Kindle PC Reader:

LaTeX to mobi, with formulas

There's probably a bit to fine-tune, but the idea is there, you get the formulas. Fine-tuning might include disabling ligatures for example.

Note that the tuning might be done in the XHTML to MOBI conversion process, possibly with Calibre's options, since the HTML document looks fine:

latex to XHTML


This works for me.

I use document class memoir with parameters [ebook,oneside,openany] with very few modifications respect to the original file (the one that produces PDF).

Compile it with: htlatex myfile "html". Then load the resulting myfile.html in Sigil. Here I add missing metadata, split the chapters and mark the cover page image. Then save as epub and load it (via Calibre) on my reader.


Why not simply

\documentclass[a5paper]{memoir}

or similar? worked fine with me. The size is adequate and you do not need to zoom in or out. If it is still difficult to read you can set the font size a bit.

Tags:

Ebook