Search code examples
latexmathquill

MathQuill and set operators


When using MathQuill one needs to type \nsub to get the symbol. The latex you get back is \not\subset, which is fine.

But when you try to set back the same \not\subset expression to the MathQuill field, you get a different result : \neg\subset, which translates to a different rendering.

The problem can be reproduced directly on the MathQuill page (http://mathquill.com/) using the browser console :

enter image description here

Any ideas on how to handle or work around this ?


Solution

  • MathQuill will accept \nsub while typing, but also \notsubset, which got me to a simple find-and-replace solution, which does not require any other code change.

    Not the best, but it works; the only downside is that the list of text replacements is fixed; the set operators are the one I found; could be more.

    // special math pre-processing
    var mathFix = {
        "\\not\\subset" : "\\notsubset",
        "\\not\\supset" : "\\notsupset"
    }
                            
    var mathTextFixed = '<your latex here>';
    Object.keys(mathFix).forEach(function(t1) {
        mathTextFixed = mathTextFixed.replace(t1, mathFix[t1]);
    });
    
    mathField.latex(mathTextFixed);