Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render Math Equations in iOS [duplicate]

I was wondering if there is an easy way to implement the rendering of math equations into an iOS app. It doesn't have to be interactive. All it should do is display the equation in traditional ways so when the user is dealing with complex equations it makes it easier to follow.

ex. 2^(2/(6^(1/2))) gives: Example output

Wolfram Alpha does this along with other apps that I have seen. It doesn't have to deal with variables either.

like image 650
Neil Avatar asked Apr 14 '13 17:04

Neil


People also ask

How do you copy MathType equations?

Right-click (Mac: ctrl+click) the equation and choose Copy as MathML from the contextual menu.

How do you write math equations on Iphone?

Tap the Document tab, tap Document Setup, then double-tap the equation. Move an inline equation within the text: Select the equation and drag it to a new position. Equations in the header or footer can be moved within the header or footer when your document is in Document Setup view.

How do I add MathType to Keynote?

Tip: To set MathType as the default equation editor, choose Keynote > Preferences (from the Keynote menu at the top of your screen), click General, then select “Insert equations with MathType.”


2 Answers

A UIWebView can display mathML since iOS5. Your example:

<math title="2^(2/(sqrt(6))" xmlns="http://www.w3.org/1998/Math/MathML">
  <mstyle mathcolor="blue" fontfamily="sanserif" displaystyle="true">
    <msup>
      <mn>2</mn>
      <mrow>
        <mfrac>
          <mn>2</mn>
          <mrow>
            <msqrt>
              <mrow>
                <mn>6</mn>
              </mrow>
            </msqrt>
          </mrow>
        </mfrac>
      </mrow>
    </msup>
  </mstyle>
</math>

This will render in a UIWebView on iOS.

There are javascript libraries that can convert for you - eg mathjax can accept ASCIIMath input such as this example 2^(2/(sqrt(6))

There is a good discussion of these issues here Tradeoff between LaTex, MathML, and XHTMLMathML in an iOS app?

like image 185
foundry Avatar answered Nov 09 '22 06:11

foundry


For simple expressions, the easiest way is probably to use HTML and display the expression in a UIWebView. This will work especially well if the expression part of other content that can also be displayed using HTML.

like image 44
Caleb Avatar answered Nov 09 '22 06:11

Caleb