I am trying to render MathML in a word document. I believe this is possible but I am not sure of the steps. Could someone help please?
Hi Steven,
Thanks for your inquiry. Please use following code example to achieve your requirements.
DocumentBuilder builder = new DocumentBuilder(doc);
String mathML = “<m:math> \n” +
" <m:mfenced open="{" close=""> \n" +
" <m:mtable columnalign=“left”> \n" +
" <m:mtr> \n" +
" <m:mtd> \n" +
" <m:mn>\n" +
" 2\n" +
" </m:mn> \n" +
" <m:mi>\n" +
" x\n" +
" </m:mi> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mo>\n" +
" +\n" +
" </m:mo> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mi>\n" +
" y\n" +
" </m:mi> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mo>\n" +
" =\n" +
" </m:mo> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mn>\n" +
" 3\n" +
" </m:mn> \n" +
" </m:mtd> \n" +
" </m:mtr> \n" +
" <m:mtr> \n" +
" <m:mtd> \n" +
" <m:mi>\n" +
" x\n" +
" </m:mi> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mo>\n" +
" +\n" +
" </m:mo> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mn>\n" +
" 3\n" +
" </m:mn> \n" +
" <m:mi>\n" +
" y\n" +
" </m:mi> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mo>\n" +
" =\n" +
" </m:mo> \n" +
" <m:mo>\n" +
" \n" +
" </m:mo> \n" +
" <m:mn>\n" +
" 2\n" +
" </m:mn> \n" +
" </m:mtd> \n" +
" </m:mtr> \n" +
" </m:mtable> \n" +
" </m:mfenced> \n" +
" </m:math>\n" +
“\n”;
builder.insertHtml(mathML);
doc.save(MyDir + “Out v16.7.0.docx”);
Thanks for the help.
Hi Steven,
Thanks for your inquiry. Could you please attach complete html here for testing? We will investigate the issue on our side and provide you more information.
Just run the above code in the first reply, it will yield the result I posted.
We use MathJax for Web Browser rendering of MathML.
2 x + y = 3 x
- 3 y = 2
The equations are not stacked with the brace, but rather side by side.
What am I missing here?
Thanks for the help
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml("\n" +
"<mfenced open=\"{\" close=\"\">\n" +
" <mtable columnalign=\"left\">\n" +
" \n" +
" \n" +
" 2\n" +
" x\n" +
" \n" +
" +\n" +
" \n" +
" y\n" +
" \n" +
" =\n" +
" \n" +
" 3\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" x\n" +
" \n" +
" +\n" +
" \n" +
" 3\n" +
" y\n" +
" \n" +
" =\n" +
" \n" +
" 2\n" +
" \n" +
" \n" +
" \n" +
"\n" +
"");
doc.save(MyDir + "Out v16.11.0.docx");
Yes. You are correct, the latest version does work. We are using version 15.11 and it does not work there. Time for an upgrade.