6

I plan to use Xcode to make an app for the iPhone that displays math equations that high school and college students often use. I do all my math with Mathematica, and it allows me to save such equations in three relevant formats. (1) LaTex (.tex); (2) MathML (.mml); (3) XHTMLMathML.

The Mathemactica documentation says the third format is XHTML with embedded MathML. I found some of the examples at this browser test don't look so good on my iPhone. So I will propbably not rely completly on MathML.

I am a total beginner with Xcode and the three file formats that I mention above, but I have some experience with OOP in C++. Assuming Mathematica can do a good job writing the required LaTeX, MathML, XHHTMLMathML needed for whatever equation, what are the tradeoffs between the three file formats? Can I mix the formats in the same app?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Ted Ersek
  • 193
  • 2
  • 5
  • I wrote an iOS application that does equation typesetting and LaTeX output, and let me tell you it was not an easy undertaking. I talk a little more about the typesetting side in [my answer here](http://stackoverflow.com/questions/2907045/drawing-formulas-with-quartz-2d/2908269#2908269), but I should say that parsing LaTeX is quite a challenge. MathML has been easier to work with in my experience, but I haven't spent as much time with it as LaTeX. Writing a parser for any of the formats you list, much less the visual layout engine, will take some time. – Brad Larson Nov 06 '12 at 03:21
  • @Brad Larson, This is a follow-up to [this question](http://stackoverflow.com/questions/13215321/how-to-make-math-equations-in-xcode). I am not looking to make an app that allows a user to type or edit math equations. My app will allow a user to look-up useful equations that they don't have memorized. That would include the quadradic equation, volume of a sphere, etc. I am looking for guidance on what approach I should use to ensure the equations are displayed like they are in a text book. – Ted Ersek Nov 06 '12 at 23:09
  • Right, the biggest challenge for me was in the layout of the equation elements, which is why the people in your previous question pointed to my older answer. You might have a little easier of a time of it without needing to edit them, but you're still going to need to do custom Quartz drawing and layout of these elements. A hierarchical structure to this is what I'd still recommend, even for static equation layout. Your parser would generate this hierarchy of elements, which you could then render onto the screen using some combination of Quartz, UIKit, and CALayers. – Brad Larson Nov 06 '12 at 23:49
  • 1
    Maybe another option, since it sounds like it's a finite list of equations ... spit them out into svg "images" and render with SGVKit. – Greg Combs Sep 05 '13 at 00:09

1 Answers1

4

I would suggest to use HTML. The "right" way to include mathematical content is MathML -- which is part of HTML5 (but see below for using TeX).

iOS's UIwebview is webkit based and therefore has the same partial MathML support (though on iOS5 it's significantly worse due to a font bug) so I would also suggest to use MathJax (disclaimer: I'm part of MathJax).

MathJax is an open source javascript library which understands TeX and Asciimath input, converts either one to MathML and renders MathML as HTML-CSS or SVG (in any modern browser).

MathJax has no problem mixing these input formats. Additionally, it has better MathML support than webkit (and you can always configure MathJax to use the native MathML support if you want -- say when you know your content should render fine in webkits native support).

To get you started, you can take a look at this open source app to see how MathJax can be integrated in an iOS app.

Peter Krautzberger
  • 5,145
  • 19
  • 31