mathjax

Why does this "startup" configuration, while allowing for auto-sizeable double brackets, renders \coloneq (and similar commands) literally, as text?


This is a MathJax question.

In this answer, Davide Cervone provides a solution to make dobule brackets auto-sizeable (when used with \left and \right), but as a result, \coloneq becomes a text rather than a symbol. I am trying to figure out why and how to fix it. Can you help? The output should have both the brackets and the := symbol, but this is what we have instead:

test

<script src="file:\\[MY_PATH]\MathJax-master\tex-chtml.js" id="MathJax-script" async></script>
<script>
  window.MathJax=
    { startup:
        { ready()
            { MathJax.startup.defaultReady();
              const{Token}=MathJax._.input.tex.Token;
              const{MapHandler}=MathJax._.input.tex.MapHandler;
              const delimiter=MapHandler.getMap('delimiter');
              delimiter.add('\\llbracket',new Token('\\llbracket','\u27E6'));
              delimiter.add('\\rrbracket',new Token('\\rrbracket','\u27E7'));
            }
        },
      tex:
        { inlineMath:
            [ ['$','$'],
              ['\\(','\\)']
            ],
          packages:
            { '[+]':['mathtools']
            }
        },
      loader:
        { load: [ '[tex]/centernot']
        }
    };
</script>
<br><br>\(\left\llbracket\dfrac{a}{b}\coloneq\dfrac{c}{d}\right\rrbracket\)
<br><br>\(a\coloneq{}b\)

Setup specs:

As a sidenote, one of the MathJax scripts generates an error, but it seems to be an unrelated issue and doesn't interfere with the output (as far as I can tell): TypeError: NetworkError when attempting to fetch resource. speech-worker.js:1:411404 TypeError: can't convert undefined to object: "...for(let r,o=0;r=Object.keys(t)[o];o++){...}..."


Solution

  • The configuration you give doesn't load the mathtools extension where \coloneq is defined. Instead, it loads centernot, which is not included in your tex.packages configuration. If you add '[tex]/mathtools' to your loader.load array, it works for me. Try it here:

    <script>
      window.MathJax=
        { startup:
            { ready()
                { MathJax.startup.defaultReady();
                  const{Token}=MathJax._.input.tex.Token;
                  const{MapHandler}=MathJax._.input.tex.MapHandler;
                  const delimiter=MapHandler.getMap('delimiter');
                  delimiter.add('\\llbracket',new Token('\\llbracket','\u27E6'));
                  delimiter.add('\\rrbracket',new Token('\\rrbracket','\u27E7'));
                }
            },
          tex:
            { inlineMath:
                [ ['$','$'],
                  ['\\(','\\)']
                ],
              packages:
                { '[+]':['mathtools']
                }
            },
          loader:
            { load: ['[tex]/mathtools']
            }
        };
    </script>
    <script src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js" async></script>
    <br><br>\(\left\llbracket\dfrac{a}{b}\coloneq\dfrac{c}{d}\right\rrbracket\)
    <br><br>\(a\coloneq{}b\)

    Note that the configuration should come before loading the MathJax component you are using, so it is in place when MathJax loads. I have changed the URL to the jsdelivr.net CDN, since we don't have access to your local disk, and I removed the unneeded centernot load.

    Note that your graphic does not correspond to your description. Commenting out the startup block in the code you give does not produce the result in your graphic:

    <script src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js" async></script>
    <script>
      window.MathJax=
        { /*startup:
            { ready()
                { MathJax.startup.defaultReady();
                  const{Token}=MathJax._.input.tex.Token;
                  const{MapHandler}=MathJax._.input.tex.MapHandler;
                  const delimiter=MapHandler.getMap('delimiter');
                  delimiter.add('\\llbracket',new Token('\\llbracket','\u27E6'));
                  delimiter.add('\\rrbracket',new Token('\\rrbracket','\u27E7'));
                }
            },*/
          tex:
            { inlineMath:
                [ ['$','$'],
                  ['\\(','\\)']
                ],
              packages:
                { '[+]':['mathtools']
                }
            },
          loader:
            { load: [ '[tex]/centernot']
            }
        };
    </script>
    <br><br>\(\left\llbracket\dfrac{a}{b}\coloneq\dfrac{c}{d}\right\rrbracket\)
    <br><br>\(a\coloneq{}b\)

    This is due to the same problem with the mathtools package not being loaded. The fact that \colopneq is not defined has nothing to do with the startup block.