jQuery and MathJax

679 views
Skip to first unread message

pyba

unread,
Dec 5, 2010, 6:28:34 AM12/5/10
to MathJax Users
Hello,
I would to make a little tools so as to produce probabilty-tree. I've
decided to use jQuery.

My problem is that when jQuery adds a content, I would like to recall
MathJax so as to treat the new content.

Is it possible ?

Best regards.
Christophe

============= THE HTML-JS CODE ===================

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<script src="http://www.mathjax.org/mathjax/MathJax.js"></
script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/
jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("span.formula").after(': \( \sigma(y-x) \)');
});
</script>
</head>


<body>
<span class="formula">One formula added by </span>.
<br/>
The same formula already typed in the HTML code : \( \sigma(y-x) \).
</body>
</html>

Sean Hogan

unread,
Dec 5, 2010, 11:23:04 PM12/5/10
to mathja...@googlegroups.com, pyba
Hi Cristophe,

MathJax can do this. Have a look at the MathJax documentation on
Modifying Math on the Page:
http://www.mathjax.org/resources/docs/?typeset.html

Sean

Robert Miner

unread,
Dec 6, 2010, 10:45:30 AM12/6/10
to mathja...@googlegroups.com, pyba
Christophe, and any other interested jQuery users,

I think a lot of people would be interested in having some code samples
and observations about best practices for using MathJax with jQuery. If
you end up writing yourself some sample pages that can be separated from
your project, it would make a great article for the Resources section of
mathjax.org and/or a section in the docs.

If you run into programming problems or questions, especially if they
might imply changes or enhancements to the MathJax APIs, please don't
hesitate to bring them up. The mathj...@googlegroups.com list is the
best place for that kind of discussion.

Thanks,

--Robert


Dr. Robert Miner
Vice President, Research and Development
MathJax Project Coordinator

Design Science, Inc.
140 Pine Avenue, 4th Floor
Long Beach, California 90802
USA
Main: (562) 432-2920
Direct: (651) 223-2883
Fax: (651) 292-0014
rob...@dessci.com
www.dessci.com

pyba

unread,
Dec 6, 2010, 11:19:45 AM12/6/10
to MathJax Users
Hello,
indeed I forgot to put an example here/ Sorry, here it is :

===================================================================

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<script src="http://www.mathjax.org/mathjax/MathJax.js"></
script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/
jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.formula')
.html('\\( \\sigma(y-x) \\)');
.after('. And we also add one fraction : \\( \\frac{7}{9} \
\)');
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
});
</script>
</head>
<body>
One formula in the HTML code : \( \sigma(y-x) \).
<br/>
The same formula added by jQuery : <span class="formula"></
span>.
</body>
</html>

Robert Miner

unread,
Dec 6, 2010, 11:26:30 AM12/6/10
to mathja...@googlegroups.com
Thanks!

> -----Original Message-----
> From: mathja...@googlegroups.com [mailto:mathjax-
> us...@googlegroups.com] On Behalf Of pyba
> Sent: Monday, December 06, 2010 10:20 AM
> To: MathJax Users
> Subject: Re: jQuery and MathJax
>

pyba

unread,
Dec 6, 2010, 11:38:54 AM12/6/10
to MathJax Users
There are extra return in the code I've typed.

Here the lines that have been splitted without my permission... :-). I
hope that no other wrong printings will come...

----- WRONG PRINTING -----
<script src="http://www.mathjax.org/mathjax/MathJax.js"></
script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/
jquery.min.js" type="text/javascript"></script>

----- GOOD TYPING LOOKS LIKE -----
<script src="..."></script>


----- WRONG PRINTING -----
.after('. And we also add one fraction : \\( \\frac{7}{9} \
\)');

----- GOOD TYPING -----
.after('. And we also add one fraction : \\( \\frac{7}{9} \\)');


----- WRONG PRINTING -----
The same formula added by jQuery : <span class="formula"></
span>.

----- GOOD TYPING -----

Davide P. Cervone

unread,
Dec 8, 2010, 12:11:48 PM12/8/10
to mathja...@googlegroups.com
See the documentation at

http://www.mathjax.org/resources/docs/?typeset.html

and several of the other discussions here, e.g.

http://groups.google.com/group/mathjax-users/browse_thread/thread/c3540d56e09b0885/cc7abc4b098923c1?hl=en&lnk=gst

Finally, there is an example of this in the MathJax/test folder; see
sample-dynamic.html for one example.

Davide

Reply all
Reply to author
Forward
0 new messages