Converting MathJax compatible code for MS Word

2,196 views
Skip to first unread message

jgall...@gmail.com

unread,
May 8, 2012, 3:57:19 PM5/8/12
to mathja...@googlegroups.com
Does anyone know how to use mathjax compatible MathML and LaTeX to generate equations for a word doc? I'm working in PHP. I want to be able to offer the user the ability to view their equations in HTML or download a .doc version.

Peter Krautzberger

unread,
May 8, 2012, 4:29:12 PM5/8/12
to mathja...@googlegroups.com
You could look into pandoc  http://johnmacfarlane.net/pandoc/index.html. In the docx output, pandoc renders mathematics using OMML. MathML and LaTeX are acceptable inputs. They also have an active user list.

Peter.

Marc Grober

unread,
May 8, 2012, 4:52:48 PM5/8/12
to mathja...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Carlisle and Murray Sargent did some blog entries about using
xslt in order to have Word address MathML a handful of years ago. You
can do the same kind of thing a bit simpler I think with LO. Of
course, one can't resist but ask why anyone would want to offer such a
document in .doc format, let alone .docx format.... Why not simply
make optimized html available? If you are not looking at having the
user edit the docs, then simply convert to pdf, or convert your docs
on the fly to epub format and have your users use Azardi, which
boasts inclusion of MathJax?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPqYegAAoJEMCi9wxDaNqEHQEIAM6ZKWTwf5MiYYEPwbgzOLIe
TMEYYfH1QIhHJJuekQRSuZ6pJKF9RPWNMP/IE/xJqu57hHbxrnvoKuVCDILH2xqf
IO1hRWol4/7/ccT8pNsi+A/0fze718gMFXj5lPjpRKuMB7Eyp9x8d+JKW0keWFzJ
2o82YQH+/8W/Suho9B8daAThwei0zU05TvMD+7fIhHTAeQVtG69TFO8dpWufiNUk
OXaYAz/xsZGMmmiR8LrowbXDNxnNOgtTtXsQxaaaXuBOJ7NS/j20D3ulxSQpW/TW
/HyOjPwFPYZ8HpgeRC/Fc4CFUkscliCcMmD3NgD5Br2lm+lAtT26vm2dOMhf4Cs=
=ewJk
-----END PGP SIGNATURE-----

jgall...@gmail.com

unread,
May 14, 2012, 2:46:49 PM5/14/12
to mathja...@googlegroups.com
Sorry, what is LO?


On Tuesday, May 8, 2012 2:52:48 PM UTC-6, net-buoy wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Carlisle and Murray Sargent did some blog entries about using
xslt in order to have Word address MathML a handful of years ago.  You
can do the same kind of thing a bit simpler I think with LO.  Of
course, one can't resist but ask why anyone would want to offer such a
document in .doc format, let alone .docx format....  Why not simply
make optimized html available? If you are not looking at having the
user edit the docs, then simply convert to pdf, or convert your docs
on the fly to epub format and have your users use Azardi,  which
boasts inclusion of MathJax?

Christophe BAL

unread,
May 14, 2012, 3:22:49 PM5/14/12
to mathja...@googlegroups.com
LO certainly means Libre Office.

Christophe

2012/5/14 <jgall...@gmail.com>

Marc Grober

unread,
May 14, 2012, 3:50:46 PM5/14/12
to mathja...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



On 5/14/12 10:46 AM, jgall...@gmail.com wrote:
> Sorry, what is LO?

LibreOffice
>
> On Tuesday, May 8, 2012 2:52:48 PM UTC-6, net-buoy wrote:
>
> David Carlisle and Murray Sargent did some blog entries about
> using xslt in order to have Word address MathML a handful of years
> ago. You can do the same kind of thing a bit simpler I think with
> LO. Of course, one can't resist but ask why anyone would want to
> offer such a document in .doc format, let alone .docx format....
> Why not simply make optimized html available? If you are not
> looking at having the user edit the docs, then simply convert to
> pdf, or convert your docs on the fly to epub format and have your
> users use Azardi, which boasts inclusion of MathJax?
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPsWIWAAoJEMCi9wxDaNqEn/kIANbJbox/eKAn6v7150fzhjya
VVcc6gms24YJaq2n3HYuMUsh1ZGHt2MvdmlbwxiAS2lEXJ5FudhshkC5bRLznhsO
MxMs4gJjiKL5xgmQHr3UhyvqHNprlGSpIblJzvxP3Uc46LzA6eTkwM07a/bhhfeI
IYTtofEwDJ+AKFQjmHS2QbnqSM1uM/D7pv+SYeTXHeca6n46ZoJFN5GllCgO9i8g
M7gbVPvTMwg3DILrJSAOPJt5A83nloscd2LmP+7xuvlf8fQuOPEssXkwj+gMB0VG
zeIvG8udSyX5ECshJjQv/+uOoBaokswqeWxDkAYslnc5urQYLfJTkc3fDDZo0p4=
=FwqY
-----END PGP SIGNATURE-----

Jason Allred

unread,
May 24, 2012, 2:41:15 PM5/24/12
to mathja...@googlegroups.com
We are saving HTML content as a doc file and letting Word handle it.  The problem is that there is no opportunity for MathJax to run when everything is being done server-side, so the raw LaTeX and MathMML is given to the document.
--
Jason Allred

Peter Krautzberger

unread,
May 24, 2012, 2:58:40 PM5/24/12
to mathja...@googlegroups.com
Jason,

Could you please describe your situation in more detail? 

For example, 

Are you in control of the html content and/or server? If so, how is the html generated?
Are you interested in server-side or client-side conversion? 
Are you looking for a general ajax web scraper to "save" random pages on the internet?

Peter.

Jason Allred

unread,
May 24, 2012, 3:04:08 PM5/24/12
to mathja...@googlegroups.com
We control both content and server.  Html is generated exactly the same as for a browser, but its added to a temporary file with a .doc extension and some instructions for Word. 

On the browser, we can use MathJax just fine for MathML and LaTeX.  But, to my knowledge, there's no way to run javascript code on the server and render all the math before creating the file.
--
Jason Allred

Paul Topping

unread,
May 24, 2012, 3:17:44 PM5/24/12
to mathja...@googlegroups.com

The real issue is whatever you are using to convert HTML to doc needs to handle the math. There are many tools to do this conversion but I suspect that most ignore math issues.

 

Paul

Paul Topping

unread,
May 24, 2012, 3:20:02 PM5/24/12
to mathja...@googlegroups.com

If you are using Word’s own HTML import then your issue is with Microsoft. They have technology to convert MathML into equations but I suspect it is not wired up to deal with MathML embedded in HTML. There are tools for converting LaTeX to MathML, though such conversions are often not perfect.

 

Paul

 

From: mathja...@googlegroups.com [mailto:mathja...@googlegroups.com] On Behalf Of Jason Allred
Sent: Thursday, May 24, 2012 12:04 PM
To: mathja...@googlegroups.com
Subject: Re: [mathjax-users] Converting MathJax compatible code for MS Word

 

We control both content and server.  Html is generated exactly the same as for a browser, but its added to a temporary file with a .doc extension and some instructions for Word. 

Peter Krautzberger

unread,
May 24, 2012, 3:31:15 PM5/24/12
to mathja...@googlegroups.com
Jason,

As Paul points out, if you are restricted to Microsoft products, you need to take it up with them.

You said you're generating the HTML -- but from what? The best option probably starts at that source and convert that to doc.

Peter.

Jason Allred

unread,
May 24, 2012, 3:33:00 PM5/24/12
to mathja...@googlegroups.com
Thanks for helping me.  We're generating HTML dynamically with PHP.  The equations are interspersed with rich text that we insert in the HTML.
--
Jason Allred

Peter Krautzberger

unread,
May 24, 2012, 9:22:13 PM5/24/12
to mathja...@googlegroups.com
Jason,

There are many php tools to convert TeX equations to png -- a simple google search should get you started.

But as in my first reply, I would suggest to investigate pandoc http://johnmacfarlane.net/pandoc/. It's an extremely versatile converter, well documented and the community is very open and helpful.

Peter. 
Reply all
Reply to author
Forward
0 new messages