MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Limits of sum incorrectly placed if sum is entered as unicode character

Open felixlen opened this issue 10 months ago • 2 comments

Issue Summary

There is a difference in rendering if the macro \sum or the corresponding unicode character ∑ is used. LuaLaTeX rendering leads to identical placement of limits, while MathJax always treats limit positions for ∑ with inline style. This issue occurs with Safari and OS X.

Steps to Reproduce:

Rendering

$$ ∑_{k=1}^{n} - \sum_{k=1}^n $$

yields the following output:

Image

With LuaLaTeX on the same snippet both sum signs and placement of limits look identical.

Technical details:

  • MathJax Version: 3.2
  • Client OS: (e.g., Mac OS X 10.8.4)
  • Browser: (e.g., Chrome 29.0.1547.57)

felixlen avatar Mar 24 '25 18:03 felixlen

Yes, some macros set properties that are not part of the unicode character itself. Mostly these are the large operators like \sum. You can use the following configuration to map the unicode characters for these large operators to their associated macros:

MathJax = {
  tex: {
    packages: {'[+]': ['unicode-largeops']}
  },
  startup: {
    ready() {
      const {MacroMap} = MathJax._.input.tex.SymbolMap;
      const {Configuration} = MathJax._.input.tex.Configuration;
      const BaseMethods = MathJax._.input.tex.base.BaseMethods.default;
      const ParseMethods = MathJax._.input.tex.ParseMethods.default;
      new MacroMap('unicode-largeops', {
        '\u220F': ['Macro', '\\prod'],
        '\u2210': ['Macro', '\\coprod'],
        '\u2211': ['Macro', '\\sum'],
        '\u22C0': ['Macro', '\\bigwedge'],
        '\u22C1': ['Macro', '\\bigvee'],
        '\u22C2': ['Macro', '\\bigcap'],
        '\u22C3': ['Macro', '\\bigcup'],
        '\u2A00': ['Macro', '\\bigodot'],
        '\u2A01': ['Macro', '\\bigoplus'],
        '\u2A02': ['Macro', '\\bigotimes'],
        '\u2A04': ['Macro', '\\biguplus'],
        '\u2A06': ['Macro', '\\bigsqcup'],
      }, {
        Macro: BaseMethods.Macro
      });
      Configuration.create('unicode-largeops', {
        handler: {character: ['unicode-largeops']}
      });
      MathJax.startup.defaultReady();
    }
  }
}

You can add other unicode characters if you need special mappings for them as well.

dpvc avatar Mar 24 '25 20:03 dpvc

Thanks a lot, your solution works well for me! Is it planned to include these macros at some point or is it out of scope for MathJax? If not I am happy to close here.

felixlen avatar Mar 25 '25 08:03 felixlen