Please also check the follow up post, there are some important updates to this small guide!
I’ve got interested in the production of ePub from LaTeX, and I realized that this topic is surprisingly not well covered yet on the web by now, so I will share my experience here. The goal was to publish a short story, called Mary Everest and the Mystery of the Pantelegraph (a steampunk short story written in Italian and currently under translation) which I have written in XeLaTeX for more font flexibility.
Of course, all with free software. No licences, no dependencies on third parts. Only you, your text, your ability and enthusiasm!
Caveat: the main limit in my current experience is that there is no math formulas in my short story, and so I couldn’t really test how ePub cope with this known problem. Anyhow.
First, after writing the first draft on pen and paper (warmly suggested if you are used to academic writing!) I put into bits & LaTeX through my beloved Aquamacs (Emacs clone for Mac).
Then, I converted all the source in XHTML by SimpleTeX4ht.
Then, you should import your XHTML files into Sigil, the best ePub editor I’ve found. Not all editors let you edit the source, in most cases they call them “editors” but they are really only batch converters (!). With Sigil you can keep your text in control.
Finally, while not strictly needed, if you want to convert your ePub in a Mobi (for Kindles, for instance) you can always use Calibre, a very good ebook manager for your reader.