111

Recently I purchased an ebook reader (Kindle), and I want to export some of my document in LaTeX to an ebook format.

I tried exporting from LaTeX to PDF, but isn't perfect because I have to zoom in-out and move around the page many times (isn't confortable like when you read a normal ebook purshased in book stores). I tried too exporting to RTF, but none of my mathematical formulas were in the output document.

So, do you know a better way to export from LaTeX documents to ebook formats that includes mathematical formulas? And, that works with Kindle (mobipocket)!

7
  • 2
    What I usually do is to set the document size to (a bit less than) the screen size of the Kindle and remove all margins. This works quite well on a Kindle DX, as its screen size is around the page size of a paperback. Not sure how pleasing the result is on a normal-size Kindle.
    – Caramdir
    Commented Apr 25, 2011 at 16:17
  • 1
    @diegocaro: You haven't selected any answer or posted any comments. Are you still missing something?
    – raphink
    Commented Sep 18, 2011 at 19:36
  • 3
    EPUB 3 supports mathml. However, no handheld reading devices support EPUB 3 yet. Kindle does not support mathml and probably will not in the foreseeable future. A further problem with Kindle is that images cannot be rendered inline in text, so you can only use images for displayed math.
    – user6853
    Commented Dec 30, 2011 at 17:44
  • i was also using the Kindle reader for reading the Ebook, but this 6" device was not able to read some technical books related to my Engineering subject. i tried so many converters to make it readable but none of them helped to achieve the same. After several hours of search, i finally found this thread which helped to solve the problem.
    – user12011
    Commented Feb 23, 2012 at 6:46
  • See tex.stackexchange.com/questions/95600/… , which has some more up to date discussion.
    – user6853
    Commented Mar 8, 2013 at 0:03

7 Answers 7

53

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

8

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.

3
  • With experience I'm improving the workflow. Now I load the htlatex output in Calibre, then convert to EPUB, then edit with Sigil for TOC, metadata and cover. The result is almost perfect.
    – mvalle
    Commented Jan 16, 2012 at 11:49
  • 3
    Using memoir's ebook option makes perfectly sense if you want to read your document as a native PDF on your reader. I don't see the point in using that when converting to EPUB or MOBI, though.
    – fudo
    Commented Jan 25, 2012 at 12:24
  • As I am creating pdfs and ebooks I recommend using image sizes relative to the page size: \includegraphics[width=0.5\textwidth]{file} Commented Jan 6, 2021 at 14:40
6

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.

5

If you don't want to make too much change, go on with Andresmp answer (https://tex.stackexchange.com/a/50568/13993), and add this :

\documentclass[12pt,a5paper]{...}
\usepackage[hmargin=3.75em]{geometry} 
...

It would give you this, even if you're working with fancy package (but beware of the header/footer size) :

"Kindle size"

Rather than that :

A4 version

The increasing may look isn't that huge, but I can ensure you does work fine.

Hope that help you.

3

AFAIK, ePub is similar to / based on HTML, so you could go from latex to HTML, then to ePub.

1
  • But it doesn't support mathematical formula
    – diegocaro
    Commented Apr 24, 2011 at 22:46
3

Have you tried Pandoc? Possibly with the --webtex option to convert MathML to SVG.

2
  • 1
    It doesn't support mathematical formula :(
    – diegocaro
    Commented Apr 25, 2011 at 1:54
  • 2
    @diegocaro: Recent versions of pandoc translate TeX math to MathML.
    – Aditya
    Commented Feb 23, 2012 at 16:52
1

Have you tried plastex ? Then Sigil to assemble the ePub.

Not the answer you're looking for? Browse other questions tagged .