Updated: May 18, 2012
If you're even semi-serious about writing books and professional papers, then LaTeX is the only real way to go. If you don't feel like using a simple text editor or typing your documents on the command line, you may want to try a graphical frontend. In this regard, the best available software is probably LyX, which combines the strength of text markup with the more conventional WYSIWYG approach.
All right, so you know all about being cool, and I've given you a handful of LyX tips and tricks, not once, but twice, all of which enhance your e-ego and add splendid lines to your resume. But we did not talk about exporting your LaTeX-made documents into e-books. While PDF works well, you may want special formats, like EPUB, MOBI and others, specifically designed for e-book readers. Let's try that. All using Linux only.
Name of the game: Calibre
Truth to be told, this article is mostly about Calibre, an awesome program that does an awesome job of e-book conversions. With the growing popularity of e-book devices, this need becomes somewhat of a geek's must-have. And when you combine the power of LaTeX with that of Calibre, you exceed He-Man's powers.
Now, let's be serious and check Calibre. First of all, the tool runs on a variety of platforms, so everything you see here will work on Windows, Linux or even Mac. On Linux, you just need to download a single installation script that will auto-configure everything for you.
The first time the program starts, it will ask you to setup the work directory. And basically, that's all. You are ready to start working and converting your e-books.
The program dubs itself the one stop solution to all our e-book needs. And I guess I tend to agree. The interface is colorful and stylish, although it may appear a little cluttered to the casual user. But it's simple. Just Add books, then click Convert.
There are many input and output formats you can choose. For example, you can use PDF as your input, which will probably be the popular choice, as most people will have this or that software that can easily convert their work to PDF, including various PDF distillers and office suites.
In my case, I used my Linux Kernel Crash Book. It was written in LyX and exported as a PDF file. For output, you can choose a range of options, including EPUB, MOBI, LIT, RTF, and others. Here, I will demonstrate with EPUB and MOBI, as promised.
Before you start the conversion job, you can customize the look and feel of your output documents. The available menus will change based on your output format. You can configure pretty much anything, including even Amazon Kindle options. I believe you might want to perform several trial & error runs until you get all the little details figured out.
And then you start converting:
You may want to try a more classical approach, too. In this regard, you want pure LaTeX files, often suffixed with .tex, converted into e-books using one or more intermediate formats. I must admit that Calibre covers your every need, but still, here's an alternative.
First, let's say you have a LyX document. It is LaTeX, but not pure LaTeX, so you may want to export it. Just like we did with PDF, you do the same thing. Choose an output format, either pdflatex or plain, whichever suits you best.
Now, you want to download and install the tex4ht set of tools, designed specifically to convert tex files to XHTML, which you can then convert further to e-book formats. Indeed, Calibre, as well as other tools, support HTML, although as you've seen PDF is much simpler to handle.
Once this is done, you must power the command line and start typing. I will begin with an example and then elaborate on the options I used. You can find more in the man pages and the online guide linked further below.
mk4ht htlatex crash-book-0.2.tex 'xhtml,charset=utf-8,pmathml'
All right, so we invoke the command against a tex file, in this case my Crash book. We want to convert the file to XHTML, with the character set UTF-8 and conversion of any mathematical symbols into PMathML CSS.
Additionally, you may want several more options, like:
'-cunihtf -utf8 -cvalidate'
We want to validate the output HTML code and use a standard conversion that does not bias in favor of any browser. All of these options are, well, optional. If you ask me, this is ugly, but some people may prefer this way.
The next step is to convert HTML to EPUB and/or any other format.
Some useful sites:
There you go. You are now a geek extraordinaire. You possess the mystical e-book conversion powers, using nothing but Linux and its assortment of wondertools. Calibre seems like the most comprehensive choice and will eliminate any need for complex multi format trans-conversions to achieve the desired result. If you insist, then you go the more difficult way of the command line.
This tutorial teaches several things, but the gist of it is, if you have books or documents, in pretty much whichever format, you can easily export it into compatible formats for e-book readers and mobile devices. Here, we demonstrated with EPUB and MOBI.
That would be all. If you want more LaTeX and LyX magic, email me. In plain tex. Hihi.