mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.23k stars 1.16k forks source link

a strange error about boldsymbol on dynamic pages retrieved via ajax #261

Closed a70838697 closed 12 years ago

a70838697 commented 12 years ago

The following math formula does not work $$\boldsymbol{v}{k}=\boldsymbol{A}\boldsymbol{u}{k-1}$$

dpvc commented 12 years ago

The formula works beautifully for me. You will need to provide more detail about the situation in which you are using this expression (e.g., the content management system you are using, if any), and the browser/OS combination you are using before we can help you out. For example, your title says something about footnotes, but your description doesn't say anything about that. The problem probably has to do with the interaction between your CMS and MathJax, but we can't tell without more informaiton.

a70838697 commented 12 years ago

Sorry, I should have provided more careful test. It works in a normal page, but not in a dynamic page retrieved via Ajax. I use the following javascript to refresh.

function resetEquationNumbers() {
    var AMS = MathJax.Extension["TeX/AMSmath"];
    AMS.startNumber = 0;
    AMS.labels = {};
 } 
    MathJax.Hub.Queue(
      resetEquationNumbers,
      ["PreProcess",MathJax.Hub],
      ["Reprocess",MathJax.Hub]
    );          
    MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
dpvc commented 12 years ago

First, you can remove the resetEquationNumbers routine and use

MathJax.Hub.Queue(
  ["resetEquationNumbers",MathJax.InputJax.TeX],
  ["PreProcess",MathJax.Hub],
  ["Reprocess",MathJax.Hub]
);

instead. You also should not need the MathJax.Hub.Queue(["Typeset",MathJax.Hub]); call at all, since the PreProcess and Reprocess should handle the typesetting.

As long as you are making this call after the content has been added to the page (e.g., if it is being done as part of a callback on the Ajax routine), then it should work.

But this snippet is not sufficient to tell how this is incorporated into the page, and since it is probably a timing issue, we need more of the workings of the page. Can you point us to a URL for a page that exhibits the problem? Or can you post a more complete code sample that include the full set of actions that are being taken?

dpvc commented 12 years ago

Also, by "does not work" do you mean the equation is not processed at all? Or do you mean that the bolding isn't being performed (your title suggests that bold is somehow critical to the problem, but you have not described what the problem actually is. "Does not work" is not very specific.

a70838697 commented 12 years ago

Thanks for your help, I have found it is related with the markdown parser. The markdown parser formats the text between two ''. After I added \ before , the formula is shown correctlly.

$$\boldsymbol{v}\_k=\boldsymbol{A}^{-1}\boldsymbol{u}\_{k-1}$$