Peter Krautzberger · on the web

How to include MathJax in an epub3 file to work with iBooks (and possibly others)

At the Joint Mathematics Meetings Present and Future of Mathematics on the Web session, Lila Roberts presented an excellent demo of the good stuff you can do with iBooks author. The demo included MathJax and jsxgraph, and combined both with iBooks Author's easy, pretty layout tools. Of course, the drawback is that iBooks Author is

Anyway, I mentioned in the session that you can actually include MathJax in epub3 files directly to get much of the same. Well, you have to do the pretty layouts yourself and you'll depend on a javascript-enabled epub3 reading software (like iBooks) but at least you're using an open standard and retain your rights.

Let's get started!

If you're lazy, grab the file at the end of the post and hack from there. But I'll walk you through it.

Alright, that's the basics. You now have a copy of MathJax that works on any reasonably recent webkit browser, including most Android and iOS versions.

You have all inputs (LaTeX, asciimath, MathML) available but only SVG output (well, and native MathML but if that worked we wouldn't be here...).

What's next?

Create your document. That's actually hard if you don't have a workflow already and don't want to afford InDesign, Blue Griffon etc.

Personally, I will always try pandoc first. It's the most versatile tool there is and John McFarlane is just fantastic. Its TeX implementation is enough if you are writing TeX with HTML/epub output in mind, I'm sure you won't run into trouble.

If you can, consider to go through the Haskell-cabal-pain of installing the current development version -- see the instructions at the pandoc github wiki. That will get you the new epub3 writer and things should be easy.

Of course, you can hack the example file below and just use a current version of pandoc or whatever you like to generate some xHTML5 (yes, xhtml, not html if you want your file to validate). You'll have to modify the manifest etc by hand.

Anyway, let's daringly assume you have an epub3 with your xhtml+mathml content.

Adding MathJax.


This text is available as an epub3 file which includes MathJax and should run on iOS devices.


Comments