8

How can I achieve stretchy double brackets in MathJax using TeX? For example,

Math using double brackets

The TeX package stmaryrd has this but MathJax doesn't support the import of arbitrary packages.

I'd like the double brackets to look good at all sizes.

Bonus: Is this possible in AsciiMath?

mjk99
  • 1,290
  • 11
  • 18

1 Answers1

10

The MathJax TeX fonts don't include the characters needed for these brackets. But you can get a similar effect using something like \left[\!\!\left[x^2\over 2\right]\!\!\right] or \left[\!\left[x+1\right]\!\right] or even [\![x+1]\!]. Unfortunately, the number of backspaces (\!) that you need depends on the content, so it is not easy to automate this. This is also dependent on the font in use, so if you are doing this on your own web site and using HTML-CSS (as opposed to SVG or CommonHTML output), you might want to disable the use of local STIX fonts, since the spacing would be different for that.

Alternatively, you could configure your page to use the STIX-Web fonts, which do include the needed characters (though not everyone likes the look of them), but you would also have to add the proper names and characters to the TeX delimiters list. Something like

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  "HTML-CSS": {fonts: ['STIX-web']},
  SVG: {font: 'STIX-Web'},
  TeX: {Augment: {
    Definitions: {
      delimiter: {
        '\\llbracket': '27E6',
        '\\rrbracket': '27E7
      }
    }
  }}
});
</script>

added just before the script that loads MathJax.js itself should do it. Note that this works for HTML-CSS and SVG output, but not CommonHTML output, since the latter only uses the MathJax TeX fonts at the moment.

Davide Cervone
  • 11,211
  • 1
  • 28
  • 48
  • This does not seem to work anymore in MathJax version 3. At least setting the delimiter as above results in an error for me. Any idea if this is possible within version 3? – Max Maier Sep 26 '20 at 06:42
  • @MaxMaier, the STIX fonts are not yet available in v3, and the default fonts don't include larger sizes of U+27E6 or U+27E7, or the pieces necessary to make multi-character stretchy assemblies for these characters. So ever if you could configure v3 to allow these as delimiters, it would not do much good at the moment. But you can see [this issue tracker](https://github.com/mathjax/MathJax/issues/2535) for how to do it in v3. – Davide Cervone Sep 26 '20 at 20:22
  • thanks for pointing this out! I will keep track of changes of the issue tracker. Already excited when the STIX v3 fonts will land into MathJax :) – Max Maier Sep 30 '20 at 14:18