Skip to content
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

Add ability to support user-added LaTeX Macros #16

Open
SteelWagstaff opened this issue Jul 17, 2019 · 3 comments
Open

Add ability to support user-added LaTeX Macros #16

SteelWagstaff opened this issue Jul 17, 2019 · 3 comments
Labels
authoring tools related to content creation & the authoring interface, visual & text editors, & publication menus third party related to third party tools, services, integrations or plugins

Comments

@SteelWagstaff
Copy link
Member

SteelWagstaff commented Jul 17, 2019

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

@SteelWagstaff
Copy link
Member Author

SteelWagstaff commented Jul 17, 2019

Full message from user:

When I use MathJax on my person web pages, I load it with a Javascript call that looks like
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML,https://poritz.net/MJconfig.js' async></script>

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 say Consider a point $x\in\RR^n$ because there is the entry RR: '{\\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.

@SteelWagstaff SteelWagstaff changed the title Add ability to support additional MathJax config options Add ability to support user-added MathJax Macros Jul 17, 2019
@SteelWagstaff SteelWagstaff added the X-Large - 13 Planning Poker T-Shirt Size label Jul 17, 2019
@SteelWagstaff SteelWagstaff changed the title Add ability to support user-added MathJax Macros Add ability to support user-added MathJax Macros & extensions Jul 17, 2019
@SteelWagstaff
Copy link
Member Author

Another user has requested the ability to add extensions, like those used for Chemistry (i.e. https://github.com/mhchem/MathJax-mhchem/)

@SteelWagstaff SteelWagstaff changed the title Add ability to support user-added MathJax Macros & extensions Add ability to support user-added LaTeX Macros Jul 18, 2019
@SteelWagstaff SteelWagstaff added Large - 8 Planning Poker T-Shirt Size and removed X-Large - 13 Planning Poker T-Shirt Size labels Aug 14, 2019
@SteelWagstaff SteelWagstaff added authoring tools related to content creation & the authoring interface, visual & text editors, & publication menus third party related to third party tools, services, integrations or plugins labels Nov 28, 2019
@SteelWagstaff SteelWagstaff removed the Large - 8 Planning Poker T-Shirt Size label Feb 6, 2020
@SteelWagstaff SteelWagstaff added this to the Pressbooks MathJax 1.0 milestone Jun 3, 2021
@MichSpieler
Copy link

This has been requested by another network manager (link for PB Support staff)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authoring tools related to content creation & the authoring interface, visual & text editors, & publication menus third party related to third party tools, services, integrations or plugins
Projects
None yet
Development

No branches or pull requests

2 participants