Hi Davide,
Thank you for your response. I tried following your suggestion but it
doesn't work for me. It could be because of my lack of understanding
of how exactly MathJax.Hub.Reprocess and MathJax.Hub.PreProcess work.
I have created a jsFiddle paste to demonstrate the issue I am facing:
http://jsfiddle.net/WbCy3/ . We can see in this demo that the math
equations are rendered fine when we first press the 'Update' button,
but they are not rendered when we press the button the second time.
This is how I am doing the update when the button is pressed. Note
that previewArea.innerHTML is being completely overwritten before the
following code executes.
if (firstUpdate) { // firstUpdate is initialized to 'true'
MathJax.Hub.Queue(['Typeset', MathJax.Hub, previewArea]);
firstUpdate = false;
} else {
MathJax.Hub.Queue(
['resetEquationNumbers', MathJax.InputJax.TeX],
['Reprocess', MathJax.Hub, previewArea],
['PreProcess', MathJax.Hub, previewArea]
);
}
I am able to fix this by replacing calls to MathJax.Hub.Reprocess and
MathJax.Hub.PreProcess with MathJax.Hub.Typeset as follows:
if (firstUpdate) {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, previewArea]);
firstUpdate = false;
} else {
MathJax.Hub.Queue(
['resetEquationNumbers', MathJax.InputJax.TeX],
['Typeset', MathJax.Hub, previewArea]
);
}
Here is the demo URL for my fix:
http://jsfiddle.net/TXUMz/
Could you please explain me why MathJax.Hub.Reprocess and
MathJax.Hub.PreProcess calls do not re-render the math equations?
Also, do you think my way of fixing this using a call to
MathJax.Hub.Typeset is fine?
Susam Pal
On Mar 31, 8:10 pm, "Davide P. Cervone" <
d...@union.edu> wrote:
> The feature did make it into v2.0 -- it's just the documentation that
> didn't. I did say what it would be in the message you cite:
>
> BTW, the new routine that I've added to the API is
> MathJax.InputJax.TeX.resetEquationNumbers, so for the final 2.0
> release, you should be able to use
> MathJax.Hub.Queue(
> ["resetEquationNumbers",MathJax.InputJax.TeX],
> ["PreProcess",MathJax.Hub],
> ["Reprocess",MathJax.Hub]
> );
>
> So I would go with this rather than changing the internal variables by
> hand. That way, if the code for this gets updated,
> resetEquationNumbers will be updated as well, and you won't have to
> fix your own code.
>
> Davide
>
> On Mar 30, 2012, at 2:06 PM, Peter Krautzberger wrote:
>
>
>
>
>
>
>
> > This came up during the beta tests cf.
http://groups.google.com/group/mathjax-users/browse_thread/thread/933...
>
> > Davide, you mentioned an API for clearing labels to be in 2.0, but I
> > can't find it in the docs. Did that feature make it to 2.0?
>
> > Peter.
>
> > On Fri, Mar 30, 2012 at 1:39 PM, Susam Pal <
su...@susam.in> wrote:
> > Hi,
>
> > I have an online application that shows live preview of the output
> > rendered by MathJax as the user types his LaTeX code in a form. I have
> > run into an issue regarding duplicate definition of labels while
> > updating the preview.
>
> > A demonstration of the issue is available in my application itself:
> >
http://mathb.in/119
>
> > When you first load that page, the equation will be rendered fine. But
> > if you edit anything, it will trigger a preview update. After the
> > update, MathJax would display this error:
>
> > Label 'eq1' mutiply defined
>
> > The preview update is implemented as:
>
> > MathJax.Hub.Queue(['Typeset', MathJax.Hub, previewArea]);
>
> > If you are interested in the actual code, please see updatePreview()
> > function inhttp://
mathb.in/scripts/mathb.js
>
> > I am able to reproduce this issue in the
math.stackexchange.com form
> > and other websites that support live MathJax preview. Visit
> >
http://math.stackexchange.com/questions/askand paste this code: