-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unicode characters that behave different from the corresponding LaTeX macro #920
Comments
Thanks for posting this here, too. |
Also the unicode symbol <math xmlns="http://www.w3.org/1998/Math/MathML">
<mi mathvariant="normal">∞</mi>
<mrow data-mjx-texclass="ORD">
<mo>∞</mo>
</mrow>
</math> |
Also, the behavior is different for unicode characters
is converted to <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<msubsup>
<mo>∑</mo>
<mrow data-mjx-texclass="ORD">
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</msubsup>
<munderover>
<mo data-mjx-texclass="OP">∑</mo>
<mrow data-mjx-texclass="ORD">
<mi>i</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
</math> Same for other symbols of TeX class
|
Also, the behavior is different for unicode uppercase greek letters and the corresponding LaTeX macros. <math xmlns="http://www.w3.org/1998/Math/MathML">
<mi>Σ</mi>
<mi mathvariant="normal">Σ</mi>
</math> How to change "mathvariant" of unicode uppercase greek letters to "normal" by default? Thanks! |
@hbghlyj, you are correct that MathJax doesn't handle raw unicode characters in the same way as it does the corresponding macros. it is possible, however, to map these characters to the appropriate macros if you wish. One possible version 3 configuration that does this would be the following: MathJax = {
startup: {
ready() {
const {Configuration} = MathJax._.input.tex.Configuration;
const {MacroMap} = MathJax._.input.tex.SymbolMap;
const BaseMethods = MathJax._.input.tex.base.BaseMethods.default;
//
// Subclass the MacroMap to add ['Macro', ...] around the macro string
// in the definitions for each character
//
class MacroChars extends MacroMap {
constructor(name, json, methods) {
for (const [name, macro] of Object.entries(json)) {
json[name] = ['Macro', macro];
}
super(name, json, methods);
}
}
//
// Create a macro mapping for the characters to their TeX equivalents
//
new MacroChars('unicode-chars', {
//
// Some larg operators
//
'\u220F': '\\prod',
'\u2210': '\\coprod',
'\u2211': '\\sum',
'\u222B': '\\int',
'\u222C': '\\iint',
'\u222D': '\\iiint',
//
// Greek capitals (you can add the rest)
//
'\u03A3': '\\Sigma',
//
// Some other symbols
//
'\u221E': '\\infty',
'\u221A': '\\sqrt',
'\u221B': '\\sqrt[3]',
'\u221C': '\\sqrt[4]',
//
// Double-struck letters (add the rest)
//
'\u2102': '\\mathbb{C}',
'\u211D': '\\mathbb{R}',
//
// Over- and under-braces (could do over/under-parens, etc.)
//
'\u23DE': '\\overbrace',
'\u23DF': '\\underbrace',
}, BaseMethods);
//
// Create the package containing these characters
//
Configuration.create(
'unicode-chars', {handler: {character: ['unicode-chars']}}
);
MathJax.startup.defaultReady();
}
},
tex: {
//
// Tell TeX to use your new package
//
packages: {'[+]': ['unicode-chars']}
}
} I have not included every character that you will want, so you will need to augment this to suit your needs. Note also that the replacement string can be any TeX code, not just a single macro. This could be the basis for a proper extension, and that would make a nice first effort for someone looking to contribute to MathJax. |
This is not an appropriate place to post advertisement for your tool. Also, as it is KaTeX-based rather than MathJax-based, it's also not very tactful. |
Not at all clear from your original post. Your statement that "I don't know if I can share it here or not, but I thought it might be of some help" suggests you are trying to point people to your tool and that it might be useful to them, which seems like an advertisement, not a request for help. This issue tracker is for reporting bugs in MathJax or requesting new features, not general guidance for non-MathJax projects or other open-source projects. Since you are not reporting a bug or asking for a feature, and your project isn't even MathJax-based, this is not the right place for your post. It is also not good practice to attache your comment to an existing issue that really has nothing to do with your post, even if it were appropriate for this forum. If you are looking for general programming or open-source advice, you might consider a forum like stack overflow. |
I've made a list of unicode symbols that behave different from the corresponding LaTeX macro:
Demo: http://jsfiddle.net/4WvgA/6/
I made a unicode math typer here: http://kasperpeulen.github.io/PressAndHold/Unicode/
And there I use some Davide hack there, to make those unicode symbol behave like LaTeX macros, but I would like it if people can use my tool also at other places as well. There are probably same unicode characters where it is not obvious how mathjax should handle them. But for many cases, I think there is only one obvious option.
The text was updated successfully, but these errors were encountered: