Search code examples
htmlmathjax

Simplest Way to Write Math Fractions


I currently use MathJax to write math equations because the result looks professional (More here). It's like an html language.

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

The problem is that to write one equation requires this much code:

 <math display='block'>
<mrow>
<mi>x</mi><mo>=</mo>
  <mfrac>
    <!-- Start Numerator -->
    <mrow><mo>&#x2212;</mo><mi>b</mi><mo>&#x00B1;</mo>
      <msqrt>
        <mrow>
          <msup><mi>b</mi><mn>2</mn></msup><mo>&#x2212;</mo><mn>4</mn>  <mi>a</mi><mi>c</mi>
        </mrow>
      </msqrt>
    </mrow>
    <!-- Start Denominator -->
    <mrow>
      <mn>2</mn><mi>a</mi>
    </mrow>
  </mfrac>

Is there a way that I can write math equations like (2y^3)/x^4 and have them appear as neat as MathJax, but with less code?


Solution

  • MathJax supports TeX notation that is generally more straightforward. For example, a fraction can be written very simply like this: a+1\over b+1.

    You just have to set some configurations, that will vary depending on your workflow.

    You can see examples here: http://www.tuhh.de/MathJax/test/sample-tex.html

    One of the advantage of MathMl is that in recent Microsoft Word versions, you can export equation you enter with their equation editor directly to MathMl, so the markup is a bit more complex, but if you have Word, you basically have a MathMl editor. To use this, simply go in your Word settings, in Equation section you should have somthing like copy MathMl to text. Then you just enter your equations, select, click copy and you can paste it as MathMl.