Skip to content

HTML: Move MathJax packages and macros to its configuration#2761

Closed
Alex-Jordan wants to merge 1 commit intoPreTeXtBook:masterfrom
Alex-Jordan:mathjax-macros
Closed

HTML: Move MathJax packages and macros to its configuration#2761
Alex-Jordan wants to merge 1 commit intoPreTeXtBook:masterfrom
Alex-Jordan:mathjax-macros

Conversation

@Alex-Jordan
Copy link
Copy Markdown
Contributor

We have long put author-demanded packages (cancel, etc) in a \require{} inside a block of math content. And long placed author-defined macros in the same block of math content.

This change moves all of that into the actual configuration block for MathJax. This was motivated by certain changes I'd like to make for WeBWorK, but just seems like the actual appropriate way to do all this. I don't believe it was possible with MJ2, so we did what we did. And held onto it. But with my testing of the sample article with both MJ3 and MJ4, this works.

This warrants lots of testing. I'll try other projects, other browsers, other devices, etc. But I wanted to post it here to see if there is interest in even more people testing. Marking this as draft until I can report more testing.

@rbeezer
Copy link
Copy Markdown
Collaborator

rbeezer commented Jan 7, 2026

I've looked at this closely. I can't check too much further right now, but I think we are unable to alter the MathJax configuration for Jupyter notebooks?

Can you test there? Yes, the conversion has been neglected, but no, it has not been abandoned. And there are reasons to move its necessary maintanence up in priority.

@rbeezer
Copy link
Copy Markdown
Collaborator

rbeezer commented Jan 7, 2026

I built the sample article with the Jupyter conversion stylesheet. (Requires using xsltproc.)

Section 7, "Mathematics" has its problems, but the cancel package is working.

JupyterLite looks like it may a good place to test viewing notebooks.

https://jupyterlite.github.io/demo/lab/index.html

@Alex-Jordan
Copy link
Copy Markdown
Contributor Author

Does Section 7 have its problems with or without this change? Or only with this change?

The cancel extension is probably not what we should test with, because it is automatically included when the autoload extension is used. Any combined components configuration of MJ that includes TeX input jax loads autoload. So for example PTX uses tex-svg.js, tex-mml-chtml.js, or tex-chtml.js, and these all load cancel already.

I took a short look at Jupyter and how it seems to load MJ. It seems to use the mathjax-full combined component (available with MJ3, but not MJ4). Which I assume also loads autoload.

Is it up for consideration to keep things the same for Jupyter notebooks, while making a change like this for HTML? I can appreciate not wanting divergent MathJax details to maintain. It seems that the Jupyter MJ config is what it is though, and in one sense it's already divergent from the config used in PTX HTML. It would be a matter of still getting extensions to work in Jupyter.

I won't be fast with this, too many local issues with our term having started. But I think I'll post some sort of record of what I test as I go.

@rbeezer
Copy link
Copy Markdown
Collaborator

rbeezer commented Jan 7, 2026 via email

@rbeezer
Copy link
Copy Markdown
Collaborator

rbeezer commented Jan 8, 2026 via email

@Alex-Jordan
Copy link
Copy Markdown
Contributor Author

Only one thing from -html was used in the jupyter conversion: the variable that glues all the packages together, each wrapped in \require(). So I moved it directly to the one place it is used in the jupyter conversion.

Tested again, and:

  • sample article Mathematics page is working
  • sample article Mathematics page is working with debug.mathjax4 yes
  • jupyter notebook works to the same degree, with or without this change (where it is not working is that if the SA source uses & instead of \amp, then that becomes & for Jupyter, and you end up seeing "amp;")

I noticed an MJ4 issue I will either post about, or post a fix for. It's an issue that is independent from this PR.

@Alex-Jordan Alex-Jordan marked this pull request as ready for review February 16, 2026 04:50
@rbeezer
Copy link
Copy Markdown
Collaborator

rbeezer commented Mar 31, 2026

Looks like there needs to be a little more care with how broadly this is used.

Claude AI says:

Hard blockers — three files not updated

  1. xsl/pretext-runestone.xsl line 527 still references $latex-packages-mathjax, which this PR deletes. Any Runestone build using docinfo/math-package will fail or silently omit the content.
  2. xsl/support/extract-math.xsl line 135 has the same reference. SVG, MathML, Nemeth, and speech math extraction for projects using math packages will fail.
  3. xsl/pretext-smc.xsl line 351 calls <xsl:call-template name="latex-macros"/>, which this PR removes. SageMathCloud output breaks entirely.

There are also a couple of merge conflicts when I rebase on master. I know what it was that changed recently, but I can't be sure about how to resolve the conflicts. So I did not get very far in verifying the claims above. I did see that (1) seems correct in that the variable is not defined but is used. That should cause XSL to raise an error.

Sounds like it will be a while until you can get back to this. Maybe we will be on MJ 4 by then! Let's hope. I'm going to close this temporarily. You or I can re-open it when it can become active again.

@rbeezer rbeezer closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants