Robert G. Plantz


Home

About Me

Book Errata

RPi4 gpio

LaTeX to HTML


Background

I used LaTeX to write and typeset the x86-64 book. It has been used in the classroom since 2008 so has been thoroughly "debugged", thanks to feedback from many students. (See the Errata.) The book was originally printed by the campus bookstore as a "reader", which meant that I did not get paid royalties for my work. In 2011 I made a PDF version available, which students preferred to the print version.

This history led me in early 2013 to consider converting the book to an eBook format for sale. I had three goals in mind:

With these goals in mind, and knowing almost nothing about eBooks, I began my learning process. I am a big fan of open standards, so I decided that epub would be the best format for my book. Further research taught me that epub is based on xhtml. So what I needed was a process to convert LaTeX to xhtml. The next thing I learned is that this conversion is not straightforward. The real problem is that the features that make LaTeX great for authoring technical works — rendering equations, drawing figures, formatting pages, etc. — are not implemented very well in xhtml; they are "under construction."

This led me to the decision to sell my book in both PDF and print-on-demand paperback versions. Lulu.com was the only place that provided both.

Then in my February 2015 issue of Communications of the ACM I read Do-It-Yourself Textbook Publishing by Armando Fox and David Patterson. They were successful in doing a LaTeX to Kindle conversion, so I was motivated to try again. I did get Prof. Fox's tools to work with my book, but I decided to take a slightly different approach.

Profs. Fox and Patterson sell their book through Amazon, hence the production of a Kindle version. I decided to stay with the PDF and print-on-demand paperback versions at Lulu.com, but add a no-charge HTML online version. Prof. Fox's work provided me the confidence that I could eventually figure out how to produce an HTML version from my LaTeX source without rewriting the content.

The rest of this article describes the steps I took. As you read this, keep in mind that I had not anticipated this process when I originally wrote the text. If I were to start a new text, I would attempt to anticipate the xhtml limitations when deciding which LaTeX features to use.

Also note that this is not intended to be a cookbook, howto presentation. These are only some notes about my experiences and observations. I am sure that there are better ways to do many of these things. And since the LaTeX-formatted versions are available at a reasonable cost, I did not feel compelled to worry too much about the (free) online HTML verson.

Another result of my not using the latest HTML technology is that the online book should be more widely available. Some mobile devices may not handle HTML5, MathJax, or MathML. It seems appropriate to use the "lowest common denominator" for the free online version.

Using tex4ht

I'm sure that I've missed something important here. And I've probably made some mistakes or could have done some things a better way. But this meets my needs for now. I hope it helps anyone who is dealing with some of these problems. And, as always, I welcome any corrections or suggestions about how to improve things.