matrix/array error

  • mrsrowe

    mrsrowe - 2007-05-29

    not sure anybody reads this.  certainly doesn't look hopeful.  nevertheless.....

    I'm trying to put this piece of code into a jsMath enabled webpage, but I don't really understand maths.

    this is the markup:

    V&=& \int_0^2\pi(5x^2-9)^2,dx\\ &=& \pi \int_0^2(25x^4-90x^2+81)\,dx\\ &=& \pi \left[5x^5-30x^3+81x\right]_0^2\\ &=& \pi(5\times32-30\times8+81\times2)\\ &=&  82\pi.

    If I strip out the \begin{eqnarray*} and end... and add $ signs, I get this message:

    can only appear in a matrix or array

    I don't understand this.  how do I format an array using ascii math.


    • Davide P. Cervone

      There are two issues here:  first, jsMath doesn't implement every LaTeX environment, so not every piece of LaTeX will work with jsMath.  In this case, eqnarray is implemented, but not eqnarray* (jsMath doesn't do labels at all, so eqnarray acts like eqnarray* anyway).  I should probably make the starred versions available as well, but since I don't use LaTeX myself very often, I don't know all the different forms of the environments.

      The second issue is that while LaTeX wants things like \begin{eqnarray}...\end{eqnarray*} not to be inside math mode, jsMath's tex2math processor only processes material that IS inside math delimiters.  So you need to put the dollar signs around the \begin{eqnarray}...\end{eqnarray} even though you would not have to in LaTeX.  A more sophisticated version of tex2math could be made to look for these \begin/\end pairs in addition to the math delimiters, but it is not high on my list of things to add.

      Hope that takes care of it for you.


    • Davide P. Cervone

      PS, in response to your comment about whether people read these messages:  these discussion forums are relatively new, and not very many people have found them yet.  I monitor them, however, and I appreciate your posting your question here.  It will help get a little more traffic going, I hope.  SOMEBODY has to be the first one to post!


    • mrsrowe

      mrsrowe - 2007-05-29


      Thanks for your reply

      I've got an extra bit of info about the markup.  I removed the * as it was causing problems for the reasons you mentioned and added a <div class="math"> so it now looks like this and it works like a charm.

      <div class="math">
      V&=& \int_0^2\pi(5x^2-9)^2,dx\\
      &=& \pi \int_0^2(25x^4-90x^2+81)\,dx\\
      &=& \pi \left[5x^5-30x^3+81x\right]_0^2\\
      &=& \pi(5\times32-30\times8+81\times2)\\
      &=& 82\pi.


      • Davide P. Cervone

        Yes, the DIV you provide will work.  Depending on how your jsMath is installed, you may also be able to use $$...$$ or \[..\] instead of the DIV.  These would be possible if you have jsMath configured to use the tex2math plugin and it is configured to look for these delimiters.  The <DIV CLASS="math">...</DIV> should always work, but is not as easy to type as $$...$$ or \[...\].


    • Niels Walet

      Niels Walet - 2007-08-30

      Would be really interested in seeing some code in tex2math that automatically wraps \begin{aa}...\end{aa} not inside a math environment, to be inside a math environment. That would then automatically see most latex code, and we could simply write some extensions to jsMath to support such environments...

      • Davide P. Cervone

        Your suggestion is a good one, and I have made an experimental patch that allows for this.  You can get it at

        This will find \begin{aaa}...\end{aaa} blocks that are outside of math mode and enclose them in <SPAN CLASS="math">...</SPAN> tags so that jsMath will process them.  Note that there are only a few LaTeX environments that jsMath supports; others will have to be implemented separately. There is an autoload feature for environments (so that the file that defines the the environment can be loaded automatically when needed).  See

        for details.  Or the required definitions could be loaded using the loadFiles array in easy/load.js.

        Note that the environment is set to be an in-line one, not a display one (and since the code for the environment may not yet be loaded, there is no way for tex2math to know anything about the environment at this point).  So if the environment needs to be a display one, that may be awkward to handle.

        See if this does what you need, and let me know if it needs to work in a different way.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks