Using MathJax with a document generated by Word

351 views
Skip to first unread message

Charles Wells

unread,
Jul 8, 2011, 12:37:43 PM7/8/11
to MathJax Users
I have a lot of articles in my website http://www.abstractmath.org/MM/
that I generated by writing them in Microsoft Word and using MathType
to enter equations and using its command Publish to Math Page to
generate html. I wanted to convert those html files to using
MathJax.

The process succeed except for a very minor problem (item 4 below). I
am going to describe what I did in detail because I suspect other
users might want to do this kind of conversion as well.

I did the following steps:

1. Opened the doc file of (part of) one of the posted articles
(http://www.abstractmath.org/MM/MMSymLang.htm) and used MathType to
toggle all the math formulas to TeX.

2. Generated the Math Page html file from that doc file. As expected,
doing this preserved the TeX forms rather than converting the formulas
to pictures.

3. Entered the following code into the head of the html file and saved
the file:

<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-
AMS-MML_HTMLorMML"></script>

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX","output/HTML-CSS"],
extensions: ["tex2jax.js"],
tex2jax: {
inlineMath: [ ['$','$'], ['\\(','\\)'] ],
processEscapes: true
}
});
</script>

4. Looked at the file I generated in Firefox. All the TeX formulas
remained in TeX. The little green arrow in the Firefox tab containing
this file never stopped turning, suggesting it was trying to connect
to your website (or something). Note: This file is on my computer.

5. Posted the same file on my website here:
http://www.abstractmath.org/MM/MathJax%20Examples/MMSymLangTexJaxExp2.htm
The formulas are shown properly!

6. This file on my website: http://www.abstractmath.org/MM/MathJax%20Examples/MMExampleTexJax3.htm
(made from scratch rather than by modifying a MathPage file) works
correctly too, but the copy on my computer ALSO works correctly.

What's the difference?

Charles Wells

Davide P. Cervone

unread,
Jul 8, 2011, 1:30:50 PM7/8/11
to mathja...@googlegroups.com
The configuration script must come BEFORE the script tag that loads
MathJax.js (see the documentation at

http://www.mathjax.org/docs/1.1/configuration.html#using-in-line-configuration-options

for details). I think if you switch the order, everything will work
for you ask expected.

Davide

Charles Wells

unread,
Jul 8, 2011, 1:49:13 PM7/8/11
to MathJax Users
I tried it both ways. Whether the configuration script is before or
after the script loader the formulas are converted on the file on the
website http://www.abstractmath.org/MM/MathJax%20Examples/MMSymLangTexJaxExp2
and not for the same file on my own computer. The website file has
the script loader first at present.

--CW

On Jul 8, 12:30 pm, "Davide P. Cervone" <d...@union.edu> wrote:
> The configuration script must come BEFORE the script tag that loads  
> MathJax.js (see the documentation at
>
>        http://www.mathjax.org/docs/1.1/configuration.html#using-in-line-conf...
>
> for details).  I think if you switch the order, everything will work  
> for you ask expected.
>
> Davide
>
> On Jul 8, 2011, at 12:37 PM, Charles Wells wrote:
>
>
>
>
>
>
>
> > I have a lot of articles in my websitehttp://www.abstractmath.org/MM/
> >http://www.abstractmath.org/MM/MathJax%20Examples/MMSymLangTexJaxExp2...

Davide P. Cervone

unread,
Jul 8, 2011, 2:21:46 PM7/8/11
to mathja...@googlegroups.com
The link has the scripts in the wrong order, so you should switch that.

But that being said, I do see that MathJax doesn't run when your page
is used locally rather than from the server. The culprit seems to be
the google adds script. Here is what is happening: MathJax uses the
page's onload handler to tell when it is OK to look for math on the
page, but when the google adds script is included in the page, the
onload handler never fires. I suspect that the adds script is
inserting something into the page that never loads or that continues
to add something behind the scenes so that the page never thinks it is
ready. If the add script is recording the add usage, for example, it
may be that when used locally, it can't properly identify the web site
it is being used from, and that causes something in the script not to
work properly. I haven't looked into what it actually does to try to
figure out what is preventing the onload handler from firing.

Davide

Charles Wells

unread,
Jul 8, 2011, 3:40:50 PM7/8/11
to mathja...@googlegroups.com
Thanks, that explanation makes sense.  The ads generate very little revenue, so I will experiment with omitting them.

Charles Wells
--
professional website: http://www.cwru.edu/artsci/math/wells/home.html
blog: http://sixwingedseraph.wordpress.com/
abstract math website: http://www.abstractmath.org/MM//MMIntro.htm
astounding math stories: http://www.abstractmath.org/MM//MMAstoundingMath.htm
personal website:  http://www.abstractmath.org/Personal/index.html
sixwingedseraph.facebook.com

Davide P. Cervone

unread,
Jul 8, 2011, 3:55:36 PM7/8/11
to mathja...@googlegroups.com
You only have a problem when they are used locally, not when they are on your website, so you should be able to use them on the website, just not on the local file.  You could probably include code that checks if document.location.protocol === "file:" and insert the script call otherwise.  Or you could try adding your own onload handler that adds the add script at that point.  Both would take a little javascript to add the script to the DOM dynamically.

Davide

Robert Miner

unread,
Jul 10, 2011, 12:11:04 PM7/10/11
to mathja...@googlegroups.com

Hi Charles,

Out of curiosity, why didn't you choose to use the Save as MathPage command in Word to save out MathML (or LaTeX) for MathJax?  I'd have thought that would have been easier. 

Plus, the double translation MathType ->LaTeX -> MathML (internally in MathJax) is probably more lossy than Word + MathType -> HTML+MathML via MathPage.

--Robert


>> and not for the same file on my own computer.  The website file has
>> the script loader first at present.
>>
>> --CW
>>
>> On Jul 8, 12:30 pm, "Davide P. Cervone" <d...@union.edu> wrote:
>>
>>> The configuration script must come BEFORE the script tag that loads
>>> MathJax.js (see the documentation at
>>>


>>> ..
>>>
>>> for details).  I think if you switch the order, everything will work
>>> for you ask expected.
>>>
>>> Davide
>>>
>>> On Jul 8, 2011, at 12:37 PM, Charles Wells wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>

>>>  I have a lot of articles in my websitehttp://www.**abstractmath.org/MM/<http://www.abstractmath.org/MM/>


>>>> that I generated by writing them in Microsoft Word and using MathType
>>>> to enter equations and using its command Publish to Math Page to
>>>> generate html.  I wanted to convert those html files to using
>>>> MathJax.
>>>>
>>>
>>>  The process succeed except for a very minor problem (item 4 below).  I
>>>> am going to describe what I did in detail because I suspect other
>>>> users might want to do this kind of conversion as well.
>>>>
>>>
>>>  I did the following steps:
>>>>
>>>
>>>  1. Opened the doc file of  (part of) one of the posted articles


>>>> and used MathType to
>>>> toggle all the math formulas to TeX.
>>>>
>>>
>>>  2. Generated the Math Page html file from that doc file.  As expected,
>>>> doing this preserved the TeX forms rather than converting the formulas
>>>> to pictures.
>>>>
>>>
>>>  3. Entered the following code into the head of the html file and saved
>>>> the file:
>>>>
>>>
>>>  <script type="text/javascript"


>>>> AMS-MML_HTMLorMML"></script>
>>>>
>>>
>>>  <script type="text/x-mathjax-config">
>>>>  MathJax.Hub.Config({

>>>>   jax: ["input/TeX","output/HTML-CSS"**],


>>>>   extensions: ["tex2jax.js"],
>>>>   tex2jax: {
>>>>     inlineMath: [ ['$','$'], ['\\(','\\)'] ],
>>>>     processEscapes: true
>>>>   }
>>>>  });
>>>> </script>
>>>>
>>>
>>>  4. Looked at the file I generated in Firefox.  All the TeX formulas
>>>> remained in TeX.  The little green arrow in the Firefox tab containing
>>>> this file never stopped turning, suggesting it was trying to connect
>>>> to your website (or something). Note: This file is on my computer.
>>>>
>>>
>>>  5. Posted the same file on my website here:


>>>> ..
>>>> The formulas are shown properly!
>>>>
>>>

yanru...@gmail.com

unread,
May 7, 2013, 9:38:08 PM5/7/13
to mathja...@googlegroups.com, wellso...@gmail.com
Hi Charles,

I saw your post, and have some questions on how to convert MS Word to MathJax? Do you know whether there are software to be used? 
My problem now is that I have a lot (really a lot) of math equations written in Word documents, but now I want to put them on website. So I am not sure how to do it. Could you suggest?

Thanks a bunch.

Yanru

Peter Krautzberger

unread,
May 7, 2013, 9:56:43 PM5/7/13
to mathja...@googlegroups.com, wellso...@gmail.com
Yanru, have you tried David Carlisle's advice from http://dpcarlisle.blogspot.com/2007/04/xhtml-and-mathml-from-office-20007.html ?


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages