
View Full Version : Mathematics/MathML in EPUB
AprilHare 02152010, 06:01 AM Is anyone aware of a simple way to add mathematical formulae to EPUBs and expect them to be viewable on a liseuse, such as my firmware upgraded PRS500?
I've been looking around at methods used in HTML:
1) MathML is popular in websites, but liseuses cannot handle it. And MathML is a pain to typeset by hand.
2) There are LaTeX to MathML CSS sheets available, which allows for easiertotypeset LaTeX to be used however then you have the MathML display problem.
3) I know that Wikipedia supports mathematical script (looks very much like LaTeX) and the onthefly generated output is images/SVG. This would be better for EPUB. Something like that would be practical methinks.
4) You can use a dedicated program, make every single equation an image, then plug them manually into a EPUB. Very inconvenient.
Any ideas?
I was thinking along the lines of a 'MathML to image' processor which can take advantage of LaTeX to MathML somehow. Not sure if SVG is an option, anyone tested it?
Jellby 02152010, 08:02 AM With the current state of affairs, I would go with the TeX > image route, with a utility like tex2im (http://www.nought.de/tex2im.html). To make your life easier, you could include the TeX code in the HTML, either in an "alt" attribute or as a comment, and have a script automatically process all the needed formulas and generate the images. something like this:
HTML file:
<p>A nice identity:</p>
<img class="TeX" src="formula1.png" alt="e^{ix}=1" />
and then have a script look for <img> elements with class="TeX", generate a temporary .tex file with the "alt" content, and run tex2im to create the file named in "src".
This script (http://www.fauskes.net/nb/htmleqII/) seems to use a similar idea.
KNotTed 02152010, 01:23 PM There's also some information at http://svgkit.sourceforge.net/SVGLaTeX.html on converting LaTeX to SVG.
pietvo 02152010, 07:59 PM You can also use pdflatex to convert the equations to PDF and then use pdf2svg to convert them to SVG. Or do it interactively with inkscape.
I am not sure, however, if all ereaders supporting ePub will do SVG properly.
AprilHare 02152010, 11:48 PM You can also use pdflatex to convert the equations to PDF and then use pdf2svg to convert them to SVG. Or do it interactively with inkscape.
I am not sure, however, if all ereaders supporting ePub will do SVG properly.
Since these documents are for me, I need it to work with Sony Reader ePub implementation  or bust.
Peter Sorotokin 02162010, 12:28 AM Since these documents are for me, I need it to work with Sony Reader ePub implementation  or bust.
Sony Reader does SVG sufficiently well for math formulas.
Jellby 02162010, 04:54 AM You could also try a direct MathML to SVG converter, like this (http://www.grigoriev.ru/svgmath/).
bobcdy 02162010, 02:57 PM 45713Another way is to use Word with Mathtype, create the equation, and then do a screen copy with Belltech CaptureXT Screen Capture. I've attached an image (I hope it works, this is the first such attachment I've tried)
rmm200 02172010, 02:30 AM Never is a long time  but I would say we will never get fonts that support math operations like this. Latex does a great job at it  and the people that need to create formulas probably already know it. Maybe what we need is a good Latex to HTML converter, which plugs the formulas in as SVG.
Robert
WillAdams 02172010, 09:03 AM The fonts are coming:
http://www.stixfonts.com/
William
frabjous 02172010, 01:54 PM The fonts are coming:
http://www.stixfonts.com/
William
At first, looking at this made me rather excited, until I saw that the glyphs are based on Times. I am so monumentally disappointed now that I want to cry. I am so sick of Times, and this thing has the danger of spreading over the sciences and other technical disciplines like the plague. Wouldn't it have been better to pick something that does better on low resolution screens anyway? Has anyone seen what Times looks like at low resolution recently?
But here's another question: do those ePub renderers that don't support SVG images do OK with a .PNG fallback? And if so, can anyone point me to the proper HTML snippet to use?
WillAdams 02172010, 02:18 PM Well then you can use Calibria, Cambria, Candara, Constantia, &c.
Resolution shouldn't be an issue much longer as display density gets higher and operating systems finally become resolution independent.
William
frabjous 02172010, 02:50 PM Well then you can use Calibria, Cambria, Candara, Constantia, &c.
Ugh. No. (1) those are owned by the despised Microsoft, if I'm not mistaken, and (2) they are not available for LaTeX.
Asana Math is promising. In the meantime, I'll probably just stick with my old standbys like the mathdesign fonts (URW Garamond, Bitstream Charter, Adobe Utopia), kpfonts, and URW Palladio.
PaulTopping 02192010, 07:29 PM You guys may be interested in the Ebooks for Math and Science group on LinkedIn: http://www.linkedin.com/groups?gid=1945452 (I am the group owner). Also, MathJax (http://www.mathjax.org) may also be of interest. If an ebook reader can do JavaScript, it can be used to render both TeX and MathML.
AprilHare 02202010, 06:14 AM The beta STIX fonts seem good but unsure if licence would prevent redistribution.
I'd be interested in a howto for producing a working epub for Sony Reader with maths.
HarryT 02202010, 06:57 AM Never is a long time  but I would say we will never get fonts that support math operations like this. Latex does a great job at it  and the people that need to create formulas probably already know it. Maybe what we need is a good Latex to HTML converter, which plugs the formulas in as SVG.
Robert
I think personally that "fonts" are the wrong approach for complex equations. They are essentially "graphical" objects, and need to be "drawn". SVG seems like by far the best approach.
frabjous 02202010, 12:34 PM I think personally that "fonts" are the wrong approach for complex equations. They are essentially "graphical" objects, and need to be "drawn". SVG seems like by far the best approach.
I don't really see what you're trying to say. An SVG is still going to need a font to display the individual symbols making up the equations. (Or else recreate the symbols with a vector graphic commands, which is more or less the same thing, resource wise.) The SVG is going to allow you easily to specify the font to use and the exact location of the character, so the formatting is right. We still need the fonts.
Fonts are one issue, laying out the symbols properly is another.
I really don't think JavaScript is the right direction to go in. Let's not introduce a bunch of security holes into eBook readers if we don't have to. Native MathML or LaTeX support would be much preferable. In the meantime, SVG support is a nice compromise.
It's not 100% clear from the website, but I would expect the STIX fonts to be freely distributable. I assume they'll clarify such matters when the fonts are actually released.
AprilHare 02242010, 07:46 AM Okay, now for the nitty gritty...
I see instructions for embedding fonts here: http://www.mobileread.com/forums/showthread.php?t=61587
But how would I adapt this for the beta STIX fonts? I want to double confirm that previous attempts to use MathML weren't being stuffed up due to a lack of fonts..
WillAdams 02242010, 09:30 AM One can't display math reasonably w/o having fonts for the special characters involved  using vector objects is markedly inefficient (fonts and their handling are highly optimized) and requires significantly more space.
Placing math fonts into an svg would be reasonable, so long as all svgs in a document would be able to access fonts from a central repository.
William
