A MathML-object is represented in the form of Document Object Model as specified by the W3C Recommendation http://www.w3.org/DOM .
<math>
<mo> ∑ </mo>
<msupsub>
<mi> x </mi>
<mn> 3 </mn>
<mi> i </mi>
</msupsub>
</math>
|
|
A TeX - object is also represented by a tree, but the logic of its structure is different from that of a MathML DOM-tree. Each level of this tree corresponds to a TeX -group.
Example: the following TeX-expression $\sqrt {1-\alpha} + x^{3+a}$
is represented as
xmlns:pat = "http://www.orcca.on.ca/mathml/tex2mml.xml"
xmlns:pat = http://www.w3.org/1998/Math/MathML
pat:template
pat:template :
pat:tex
pat:mml
pat:img
pat:tex : none
pat:mml:
pat:rep
pat:variable
pat:img : none
| Element name | Attribute(s) | Purpose |
pat:tex2mmlmap
| version | Map file version |
pat:tex2mmlmap
| version | Map file version |
pat:tex2mmlmap
| version
| Map file version |
pat:template
| - | - |
pat:tex
| op
| Matching TeX macro/symbol name |
params (optional)
| TeX macro parameters (if any) | |
prec (optional)
| Template's precedence (Tex to MathML) | |
pat:mml
| op
| Matching MathML main operation |
mode (optional)
| = 'math' | 'text' | 'spec' | |
pat:variable
| name
| Identifies a variable by its name |
pat:rep
| - | Declares the repetition pattern |
More information about our mapping file and its specification can be found on the ORCCA site.
to contents
<pat:template>
<pat:tex op="\frac" params="\patVAR!{num}\patVAR!{den}"/>
<pat:mml op="mfrac">
<mfrac>
<pat:variable name="num"/>
<pat:variable name="den"/>
</mfrac>
</pat:mml>
</pat:template>
<pat:template>
<pat:tex op="" params="\left\patVAR!{o} \patREP*{\patVAR*{b},}\patVAR{t} \right\patVAR!{c}"/>
<pat:mml op="mfenced">
<mfenced open="pat:variable=o" close="pat:variable=c">
<pat:rep> <pat:variable name="b"/> </pat:rep>
<pat:variable name="t"/>
</mfenced>
</pat:mml>
</pat:template>
Suppose user has defined 2 style sheets for XSLT and for TeX:
combinatorics.xsl
XSLT template for an element <mmlx:binom>:
<xsl:template match = "apply/mmlx:binom[position()=1][count(child::*)=2]">
<mfrac thikness="0ex">
<xsl:for-each select = 'mmlx:binom/child::*'>
<xsl:copy-of select='.'/>
</xsl:for-each>
</mfrac>
</xsl:template>
\newcommand{\binom}[2]{left(\atop{#1}{#2}\right)}
Now we can put a template for convert <mmlx:binom> to \binom in the mapping file:
<pat:template>
<pat:tex op="\binom"params="\patVAR!{a}\patVAR!{b}"/>
<pat:mml op="apply-mmlx:binomial">
<apply>
<mmlx:binomial>
<pat:variable name="a"/>
<pat:variable name="b"/>
</mmlx:binomial>
</apply>
</pat:mml>
</pat:template>
Then we would want to translate
<apply>
<mmlx:binomial>
<apply>
<plus/>
<ci> a </ci>
<ci> b </ci>
</apply>
<mrow>
<mi> c </mi>
<mo> + </mo>
<mi> d </mi>
</mrow>
</mmlx:binomial>
</apply>
The standard way using XSLT will give us explicit expression for this notation:
\left(\atop{a+b}{c+d}\right)},
but technique of using mapping file allows us get TeX macro defined in combinatorics.cls:
\binom{a+b}{c+d},
in this case we preserve the semantic, defined by user.
The converter is available as
Converter provides a special algorithm for line breaking in TeX output.
Motivation: Standard MathML browsers (Amaya, Mozilla, MathPlayer) perform line breaking in mathematical formulas according to their own logic, but TeX does not. So long formulas, generated from MathML may not fit the page of TeX document.
The algorithm provides line breaking in long expression such as
Examples of linebreaking in special cases:
| 1. Long expression under a radical | 2. Long expression in a numerator | |
|
| |
| 3. Long superscripts | 4. Long underscripts | |
|
|
5. Long number
| | | | ||
| a + b + ... + k + m + n + ... + z | a + b + ... + k + m + n + ... + z | a + b + ... + k + + m + n + ... + z |
The converter also provides the transformation of a XML file with MathML to XML file with TeX, embedded into CDATA section.
This CDATA will be put under XML node <LaTeX> with special namespace.
Motivation: this possibility may be useful for HTML to TeX translation.
Java -code designed for this converter allows
Current version of converter provides possibilities to deal with