Open SteelWagstaff opened 5 years ago
Full message from user:
When I use MathJax on my person web pages, I load it with a Javascript call that looks like
There are two thing to notice about this, both in that bit that goes config=TeX-MML-AM_CHTML,https://poritz.net/MJconfig.js The first is the "TeX-MML-AM_CHTML" part, which makes over-all decisions of how MathJax is set up ... probably that choice is ok, e.g., the MathJax documentation says
Note: the configuration file TeX-MML-AM_CHTML is a great way to test all input options at once. You can find leaner combined configuration packages in our documentation.
Much more important to me is the rest of that, the ‘,https://poritz.net/MJconfig.js’. What this does is load a file of the particular LaTeX macros that I use in my formulae. E.g., rather that say something like
Consider a point $x\in{\mathbb{R}}^n$.
I can sayConsider a point $x\in\RR^n$
because there is the entryRR: '{\\mathbb{R}}'
in my MJconfig.js file.This is really, really important! LaTeX is impossibly complicated to use unless one has access to its macro definition feature, and MathJax allows that through the Javascript loading with the additional macro file. Without being able to do that, it becomes much, much less useful. Just FYI, here is my complete MJconfig.js file:
MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], processEscapes: true }, TeX: { Macros: { Aa: '{\\mathcal{A}}', Bb: '{\\mathcal{B}}', Cc: '{\\mathcal{C}}', CC: '{\\mathbb{C}}', Dd: '{\\mathcal{D}}', Ff: '{\\mathcal{F}}', Gg: '{\\mathcal{G}}', HH: '{\\mathbb{H}}', Hh: '{\\mathcal{H}}', Ii: '{\\mathcal{I}}', Kk: '{\\mathcal{K}}', Ll: '{\\mathcal{L}}', NN: '{\\mathbb{N}}', Nn: '{\\mathcal{N}}', Oo: '{\\mathcal{O}}', PP: '{\\mathbb{P}}', Pp: '{\\mathcal{P}}', QQ: '{\\mathbb{Q}}', RR: '{\\mathbb{R}}', Rr: '{\\mathcal{R}}', Span: '{\\operatorname{Span}}', Ss: '{\\mathcal{S}}', Tt: '{\\mathcal{T}}', TT: '{\\mathbb{T}}', Uu: '{\\mathcal{U}}', Vv: '{\\mathcal{V}}', Xx: '{\\mathcal{X}}', Yy: '{\\mathcal{Y}}', ZZ: '{\\mathbb{Z}}' } } });
MathJax.Ajax.loadComplete("https://poritz.net/MJconfig.js");
> So in my opinion, there are two ways this could be built into PB: 1. There could be a textbox in Settings>MathJax where the users can put in the entire context of their customization. 2. There could be a place in Settings>MathJax where users can specify a URL of a file in the format of the MJConfig.js above.
> Hmm, maybe one doesn't want to allow a full MJConfig.js -type file, perhaps specifying the delimiters for math (like the line `inlineMath: [ ['$','$'], ["\\(","\\)"] ],` in my MJConfig.js above) is not the appropriate thing to do in such a place... perhaps it belongs as its own Setting. But the Macros section of a config file is really, really nice!
> The nice thing about this is that MathJax does all of this very gracefully, it is just a matter of getting the config file or its content to MathJax in a convenient way, consistent with other aspects of the PB UX.
Another user has requested the ability to add extensions, like those used for Chemistry (i.e. https://github.com/mhchem/MathJax-mhchem/)
Advanced math users would like the ability to define TeX macros and have them be added to their MathJax configuration. See http://docs.mathjax.org/en/latest/tex.html#defining-tex-macros and http://docs.mathjax.org/en/latest/configuration.html#local-config-files. From an advanced user: “LaTeX is impossibly complicated to use unless one has access to its macro definition feature, and MathJax allows that through the Javascript loading with the additional macro file.”
Proposal: Add a text input field to the MathJax settings page that allows users to define macros Pressbooks would create a standard local config .js file with an empty macro section. User-entered macros (once sanitized -- checking for unbalanced curly braces, etc.) would be added to this section of the config file and appended to the MathJax configuration file used for that book. I.e.:
https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js,https://generic.pressbooks.pub/customMacros.js