Insert Equation in Writer from MathML

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
tl1170
Posts: 9
Joined: Thu Apr 22, 2010 4:12 pm

Insert Equation in Writer from MathML

Post by tl1170 »

Hi, we have been using an in-house program for years that automates creation of odt files. Basically the program converts a well-formatted HTML file to an odt file for printing purpose. The HTML file could contain mathml that is from another program. The mathml is compliant with standards. The program generates odt files by creating a series of xml files then converting them to a zip file. Equations are embedded as mathml. Most time the generated odt files are good. But sometimes it has issues with certain equations. In this case, a fraction equation that has expression in numerator or denominator. The odt file could contain many equations and our users are using the program on a daily basis, so it is not convenient for them to correct the equations manually.

Maybe a different question is, how do I create equation from mathml in Writer instead of using Formula tool?

As a side note, the same odt file display correctly in MS Word 2013. But we do not want to use MS Word to open odt files.

Thanks.
Attachments
test3.odt
(13.28 KiB) Downloaded 272 times
Last edited by tl1170 on Tue Feb 07, 2017 5:07 pm, edited 2 times in total.
OpenOffice 4.1.3 Windows 10
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Insert Equation in Writer from MathML

Post by keme »

I do not have Office 2013 anymore, but Word 2016 shows the same mess that Writer displays on the attached file (only without the red syntax markers). Not sure what it is meant to display, but certainly not what I get...

It seems that the file lacks a few left/right keywords. They may have been "lost in translation". I just see a lot of interspersed "none" in the code. Also, there is an unpaired right brace. Hence, I suspect that the formula generation is faulty. Subexpressions should always be bracketed. Invisible bracketing is done by braces (curly brackets), and a few extra levels of braces doesn't hurt the resulting formula.
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
tl1170
Posts: 9
Joined: Thu Apr 22, 2010 4:12 pm

Re: Insert Equation in Writer from MathML

Post by tl1170 »

Sorry the odt file seems corrupted after I played with it many times. I have uploaded a new odt file which shows fine in Word 2013. Could you check that in Word 2016? Thanks!
OpenOffice 4.1.3 Windows 10
tl1170
Posts: 9
Joined: Thu Apr 22, 2010 4:12 pm

Re: Insert Equation in Writer from MathML

Post by tl1170 »

You are right the braces have impact here. If I add braces in numerator and denominator then the fraction shows correctly. Attached is a copy of odt file with two fractions regarding braces.
keme wrote:I do not have Office 2013 anymore, but Word 2016 shows the same mess that Writer displays on the attached file (only without the red syntax markers). Not sure what it is meant to display, but certainly not what I get...

It seems that the file lacks a few left/right keywords. They may have been "lost in translation". I just see a lot of interspersed "none" in the code. Also, there is an unpaired right brace. Hence, I suspect that the formula generation is faulty. Subexpressions should always be bracketed. Invisible bracketing is done by braces (curly brackets), and a few extra levels of braces doesn't hurt the resulting formula.
Attachments
test.odt
(15.94 KiB) Downloaded 259 times
OpenOffice 4.1.3 Windows 10
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Insert Equation in Writer from MathML

Post by keme »

The file "test3", currently attached to your first post, is a mess in Writer but displays fine in Word 2016. I can "copy" from the formula in Word, but the clipboard item seems to be just an empty section of unformatted text (iow. "typed nothing"). As soon as I edit it from Writer (just insert a space in the code, which will do nothing to the formula) then save, it gets jumbled up in Word also. It seems to me that Word cannot interpret the formula code, so a fallback solution (image, postscript code, ???) is used instead.

In your latest "test" attachment, the first formula is slightly messed up, in Word and Writer alike. Adding a leading "{" and trailing "}" fixes it. The second one - almost the same, only some additional bracketing - looks fine as it is.
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
Post Reply