MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

break automatically when the formula becomes larger in version 3

Open saraOrkide opened this issue 2 years ago • 3 comments

I want it to break automatically when the formula becomes larger than the page size instead of scrolling so that the formula does not lose its readability. In version 2, I used linebreaks: {automatic: true}, but in version 3, I could not fix this.

saraOrkide avatar Jan 03 '24 10:01 saraOrkide

This is a duplicate of #2447.

Automatic linebreaking is not implemented in v3. It is one of the features that has been included in v4 (now in beta release).

dpvc avatar Jan 03 '24 13:01 dpvc

Yes, I realized that I switched to version 4, but this piece of code gave an error on version 4

       startup: {
                ready() {
                    const { CHTMLmn } = MathJax._.output.chtml.Wrappers.mn;
                    CHTMLmn.prototype.remapChars = function (chars) {
                        const C = [];
                        for (const c of chars) {
                            const text = this.font.getRemappedChar('mn', c);
                            C.push(...(text ? this.unicodeChars(text, this.variant) : [c]));
                        }
                        return C;
                    };

                    const FontData = MathJax.config.chtml.font;
                    const REMAP = FontData.remapChars.mn;
                    var ZERO = 0x6F0;     // use 0x660 for Arabic, 0x6F0 for Persian
                    for (var i = 0; i < 10; i++) { REMAP[0x30 + i] = String.fromCodePoint(ZERO + i) }


                    MathJax.startup.defaultReady();
                }
            }

saraOrkide avatar Jan 03 '24 13:01 saraOrkide

this piece of code gave an error on version 4

Yes, there are some internal changes in v4 that affect this code. Here is a version that works for v4:

  startup: {
    ready() {
      const ParseMethods = MathJax._.input.tex.ParseMethods.default;
      const {RegExpMap} = MathJax._.input.tex.TokenMap;
      new RegExpMap('digit', ParseMethods.digit, /[\d.٫۰-۹]/);
      
      const {ChtmlMn} = MathJax._.output.chtml.Wrappers.mn;
      ChtmlMn.prototype.remapChars = function (chars) {
        const C = [];
        for (const c of chars) {
          const text = this.font.getRemappedChar('mn', c);
          C.push(...(text ? this.unicodeChars(text, this.variant) : [c]));
        }
        return C;
      };
      
      const {FontData} = MathJax._.output.common.FontData;
      const REMAP = FontData.defaultMnMap;
      var ZERO = 0x6F0;     // use 0x660 for Arabic, 0x6F0 for Persian
      for (var i = 0; i < 10; i++) {REMAP[0x30 + i] = String.fromCodePoint(ZERO + i)}
      
      MathJax.startup.defaultReady();
    }
  }

dpvc avatar Jan 03 '24 14:01 dpvc