#34 jsMath does not handle \nulldelimiterspace

v3.6e
closed-accepted
nobody
5
2010-05-15
2010-05-15
fizzbowen
No

I am using the TeX translator in Design Science's MathType 6 to produce the TeX code in my web pages.

This translator and jsMath work well together, with one exception. In many of my equations, MathType produces the fragment

\kern-\nulldelimiterspace

when a delimiter is missing (for example, when the bracket used at the right side of a recently-integrated expression to indicate the limits is created, the space for the missing left bracket is filled with this output). This specific fragment triggers the error message

Missing dimension or its units for \kern

when jsMath 3.6 renders this in the browser (in this case, Firefox 3.6.3 under WinXP SP3).

The TeX sources I have read indicate that \nulldelimiterspace defaults to 1.2pt in basic TeX.

Workarounds: (1) It is possible to change all occurrences of "\nulldelimiterspace" to "1.2pt" in my HTML files, which restores full functionality (the error message goes away, and I obtain what appears to be properly rendered math). (2) Of course, it would also be possible to edit the appropriate .tld (translation directive) files in MathType, making the same replacement, so that MathType consistently generates a fixed value for the argument of \kern. However, I have to assume that some thought was put into the design of the MathType output, and so I am somewhat reluctant to override the default behavior.

I am hoping that jsMath can be modified to handle this particular output. Perhaps the value to be used for \nulldelimiterspace can even be added as a configurable item in easy/load.js.

Discussion

  • fizzbowen

    fizzbowen - 2010-05-15

    Typo ... replace ".tld" with ".tdl" in the original bug report

     
  • Davide P. Cervone

    jsMath only parses explicit dimensions, not ones stored in control sequences like \nulldelimiterspace.

    On the other hand, you can add this special case to jsMath by modifying your easy/load.js to add the following:

    jsMath.Parser = {prototype: {
    ParseDimen: function (dimen,name,advance,nomu) {
    if (dimen.match(/^-\\nulldelimiterspace([^a-zA-Z]|$)/)) {this.i += 20; return -1.2 / jsMath.em}
    var match = dimen.match(/^\s*([-+]?(\.\d+|\d+(\.\d*)?))(pt|em|ex|mu|px)/);
    if (!match) {this.Error("Missing dimension or its units for "+name); return null}
    if (advance) {
    this.i += match[0].length;
    if (this.nextIsSpace()) {this.i++}
    }
    var d = match[1]-0;
    if (match[4] == 'px') {d /= jsMath.em}
    else if (match[4] == 'pt') {d /= 10}
    else if (match[4] == 'ex') {d *= jsMath.TeX.x_height}
    else if (match[4] == 'mu') {if (nomu) {d = d/18} else {d = [d,'mu']}}
    return d;
    }
    }};

    at the bottom of the file just above the "do not modify below this" comment line. This will replace the dimension parsing routine by one that checks for -\nulldelimiterspace and returns the proper value, and then goes on to do what it usually does otherwise.

    Hope that does it for you.

    Davide

     
  • Davide P. Cervone

    I'm marking the bug as closed unless you find some problem with this suggestion.

    Davide

     
  • Davide P. Cervone

    • milestone: --> v3.6e
    • status: open --> closed-accepted
     

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

Sign up for the SourceForge newsletter:





No, thanks