In the regular LaTeX, I am using a lot of Unicode characters (which I can input directly from my keyboard), such as →, ∊ and many others. However, MathJax displays them as question marks. Is it possible to display them as the original Unicode characters?
I suspect that the problem is that they are not being saved to the original HTML file properly. You might use the View Source menu in your browser to see if the characters show up properly in the source HTML file. MathJax certainly CAN show unicode characters if they are properly encoded in the file. But using such characters directly is often complicated because of encoding issues. Not only must you save the file correctly, you also have to make sure the file is being shipped to your reader with the proper encoding so that their browser will interpret the characters properly. That means you should probably include the line
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
in your document's <head> to make sure the encoding is set properly.
This can be done, though it takes a little coding to do it, since MathJax's \def only works for names that begin with the backslash. If you place
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX;
var MACROS = {
"\u2211": "\\sum",
"\u221A": ["\\sqrt{#1}",1]
};
for (var id in MACROS) {if (MACROS.hasOwnProperty(id)) {
TEX.Definitions.special[id] = "myMacro";
}}
TEX.Parse.Augment({
myMacro: function (c) {
var args = [c].concat(MACROS[c] instanceof Array ? MACROS[c] : [MACROS[c]]);
return this.Macro.apply(this,args);
}
});
});
</script>
in your HTML file somewhere BEFORE the script that loads MathJax.js itself, then this will define the characters listed in the MACROS variables to act like macros.
In this case, the first of these will define ∑ to work like \sum. You can add more definitions to the MACROS variable above as well (make sure you separate them by commas, and make sure there is no comma after the last one in the list). Note that the definitions are JavaScript strings, so you have to double all the backslashes. You can make a macro that has arguments as in the second example, by putting the macro definition inside brackets and followed by the number of arguments that there are. In the second definition, I've defined √{...} to work like \sqrt{...}. Here, I have used numeric references to the unicode characters to avoid encoding problems, but you could use the characters directly within the quotes, as in
var MACROS = {
"∑": "\\sum",
"√": ["\\sqrt{#1}",1]
};
if you prefer, but again, using actual unicode characters does introduce more complications of making sure your files are saved properly and transferred to the server undamaged (as you have already seen).
Davide