Displaying MathML with epub switch

8 posts / 0 new
Last post

Hi all,

I'm trying to create an ePub 3 file with MathML, but I'm having some trouble. In both Readium and on the iPad, both the MathML version and the fallback image are displaying. I've even pulled the example switch from the IDPF specification (http://idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml-epub-switch) into my ePub but am having the same issue with that equation. Also, I have MathML and switch declared in my opf file.

Here's an example from my content:
<epub:switch id="IFC0006-R-E___7">
<epub:case required-namespace="http://www.w3.org/1998/Math/MathML">
<mml:math display="block">
<mml:mtext>Current ratio</mml:mtext>
<mml:mtext>Current assets</mml:mtext>
<mml:mtext>Current liabilities</mml:mtext>
<span class="inline-equation"><img src="images/IFC0006-R-eq01.jpg" /></span>

Any thoughts on what I might be missing?


That's definitely a bug in Readium. You should report it in the tracker. Readium works fine with the switch element when it contains text content in the default case (see the Hefty Water sample), but I'm getting the same behaviour as you when an image is inserted.

iBooks doesn't support the switch element, or wasn't as of the last time I opened the test suite in it (which was a few minutes ago).


Oops, I wasn't paying attention to what I was pasting where. I'm not getting duplication, I just pasted an image into the wrong place.

Not sure why you're getting that behaviour. One thought is to check that xmlns:epub has been declared somewhere in scope, otherwise the switch itself might be getting ignored.

As a final note, I've actually discovered the opposite problem of you. I can't get the MathML to display at all. Readium only ever renders the default case.

Thanks for taking a look. I do have a xmlns:epub="http://www.idpf.org/2007/ops" declaration in my HTML. I'll look into those sample files and bug report when I have a chance.

It's unfortunate that iBooks doesn't support the switch element. What MathML I've seen on the iPad looks pretty good, especially compared to the fallback image. But, if we can only use an image equation or MathML, I expect we'll have to go with the image since we need to support ePub2 readers.

Thanks again!

It's worth pointing out two things here regarding iOS:

1. iOS' MathML support is only good from iOS 6 onwards. It's supported in iOS 5, but has a number of missing glyphs.
2. The Kobo reader app on iOS supports ePub:switch using the MathML and SVG namespaces, and has done since March 2012 ;o)

Do you added "display:none;" in stylesheet for class="inline-equation"? This will work for display the single content either MathML or Image.

Modify your stylesheet as below:


@media only screen and (min-width: 595px) and (max-width: 610px){


Secondary menu