converting latex to ebook

OK, I think I’ve finally figured out the best way to turn a LaTeX book into an ebook: Use TeX4ht (SimpleTeX4ht will work if you’re on a Mac) to convert the book to HTML, and then use Calibre to convert the HTML files to epub or mobi or what have you.

The trick, which I had incredible trouble digging up on forums, is getting Calibre to deal with footnotes. If you just give it the base HTML file, it’ll hang forever. You’ve got to give it a ZIP of all the HTML files (since TeX4ht creates each footnote as a separate HTML page crosslinked to the body of the text). Better put the CSS file in too if you want all your precious bolding and italicking to come through.

Drawbacks: TeX4ht doesn’t seem to handle images properly (which is to say “at all”), and it likes to put large text (unless it’s specifically designated a chapter heading) into monospace font. I haven’t figured out why either of these things is, but they seem like the kind of thing one could write a Python script to deal with. Which I will probably do at some point. But not tonight.

I also feel I should say that Pandoc, despite claims for versatility that would make the Swiss army green, takes an incredibly long time to install from MacPorts and appears entirely inert. It’s supposed to be able to handle LaTeX, HTML, and epub, but was good for neither the LaTeX-HTML nor the HTML-epub step of this process. But if anyone wants to give me a Pandoc one-liner that’s as good as the LaTeX-TeX4ht-Calibre scheme described above, I’d be happy to try it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s