Next: , Up: Almost LaTeX formulae

### 5.1 MathML v. simplified LaTeX

You can use directly MathML's presentation and contents markup in tbook files. For this, insert $ elements without worrying about namespaces. But except for not too complicated equations this is quite longish: Einstein's famous equation of equivalence of mass and energy looks like  [itex] <mi>E</mi> <mo>=</mo> <mi>m</mi> <msup> <mi>c</mi> <mn>2</mn> </msup>$


in MathML. I hope you agree with me that there is room for improvement. Therefore tbook's formula elements <m> (inline equation), <dm> (displayed or block equation), <ch> (chemical formula), and <unit> (physical quantity) use a so-called simplified LaTeX syntax.

You may use roots, fractions, standard functions like “sin”, stretchable braces, sub- and superscripts and accents. You may nest these structures so deep until your XSLT processor complains. And you can use these elements inside MathML to get the best of both worlds. (However HTML output only contains valid MathML.)

Roots work with \sqrt, fractions with \frac, just as in LaTeX. Human text is included via \text that is known from AMSTeX. Standard functions are typed without a \'. Stretchable braces are all braces immediately within a {...} grouping. Sub- and superscripts as in LaTeX, but always a possible subscript before the superscript. Accents are just written immediately before the accented variable or group, they're made wide accents if necessary. If you make a space between accent and anything that follows, the accent is treated as an operator. (So, a \vec becomes a \to.)

Here an example:

<m>&Hat;{1-x_{\text{eff}}} &ne; {( &int;_0^&infin; sin(&tilde;x)
\frac{\sqrt[3]{1/e}}&beta; dx )}
&ne; lim_{x &rarr; &infin;}\frac1x</m>


(In a Unicode-able editor you could see the special characters directly instead of their ugly &...; representations.) In printed output this will look like this:

For HTML output, the responsible stylesheet produces:

     $<mover accent="true"><mrow><mn>1</mn><mo>-</mo> <msub><mi>x</mi><mrow><mtext>eff</mtext></mrow></msub></mrow> <mo>&Hat;</mo></mover><mo>&ne;</mo><mrow><mo>(</mo> <munderover><mo>&int;</mo><mn>0</mn><mo>&infin;</mo></munderover> <mi>sin</mi><mo stretchy="false">(</mo><mover accent="true"> <mi>x</mi><mo>~</mo></mover><mo stretchy="false">)</mo> <mfrac><mrow><mroot><mrow><mn>1</mn><mo>/</mo><mi>e</mi></mrow> <mn>3</mn></mroot></mrow><mi>&beta</mi></mfrac><mi>d</mi><mi>x</mi> <mo>)</mo></mrow><mo>&ne;</mo><munder><mi>lim</mi><mrow><mi>x</mi> <mo>&rarr;</mo><mo>&infin;</mo></mrow></munder><mfrac><mn>1</mn> <mi>x</mi></mfrac>$


Lucky us.

Notice that you can use <m>, <ch> and <unit>` within MathML constructs. This is useful if you have to include matrices, but it is especially useful for stacked equations, which LaTeX calls “equation arrays”. See Equation arrays.