moving latex packages and latex macros to Mathjax config

9 views
Skip to first unread message

Alex Jordan

unread,
Jun 10, 2026, 1:03:37 PM (10 days ago) Jun 10
to prete...@googlegroups.com
Questions for Brad and Rob.

I am reviving an effort to put:
  • latex packages
  • latex macros
into the actual MathJax configuration for pages. Rather than \require'ing packages and defining macros in some special span of math content. I have it working for a regular HTML build and for Jupyter. 

In the Runestone manifest, there is a "latex-macros" element which has text content, specifically the \require'ing of any packages, and the definitions of all latex macros. Within Runestone, say some exercise needs to be used. The ambient RS page uses the content of "latex-macros" with a hidden div to load all that stuff inside math content delimiters. 

Are you interested in moving to the approach where these things are in the MJ config? An outline of the change (which is identical for MJ3 and MJ4) is that the manifest "latex-macros" element would be structured like this:
latex-macros: {
    packages: ['package1', 'package2', ... ],
    macros: <a multiline string defining all the macros>
}

Then in the Runestone page, where the MathJax config is set up, it would be altered appropriately to load these packages and define these macros.


For Rob, I am also aware now that similar adjustment would be needed for math extraction and Sage Math Cloud/Cocalc. I've reviewed those and it looks like things will work fine once I make the same changes. I'll check before opening any PR.


If anyone is wondering why I'm interested in this, it's more than just an OCD desire to put MJ configuration into the actual MJ configuration. The result would be that the window.MathJax variable "knows" what the packages and macro definitions are. Those can then be accessed from other things. In particular, an iframe that is loading a webwork exercise using the *WeBWorK server's MathJax* is able to access the parent window's MathJax variable, get that information, and load those things. Whereas presently we have to repeat all \require'ing and macro definition within each exercise.


Rob Beezer

unread,
Jun 11, 2026, 12:24:34 PM (9 days ago) Jun 11
to prete...@googlegroups.com
I have reopened

https://github.com/PreTeXtBook/pretext/pull/2761

where a lot of discussion has already happened. Some is stale since that was
when we had MJ3.

I am concerned about supporting conversions where we do not get to touch the MJ
configuration, aka Jupyter notebooks.

I suspect the Sage Math Cloud conversion has bit-rotted and may never come back.
A Jupyter notebook conversion should suffice for thst platform.

Rob


On 6/10/26 10:03, Alex Jordan wrote:
> Questions for Brad and Rob.
>
> I am reviving an effort to put:
>
> * latex packages
> * latex macros
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com <mailto:pretext-
> dev+uns...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/
> CA%2BR-jrcw3D62FCwtbB8XqwB8pHc6--0MBsyVmd_GSwEnCvMvxA%40mail.gmail.com <https://
> groups.google.com/d/msgid/pretext-dev/CA%2BR-
> jrcw3D62FCwtbB8XqwB8pHc6--0MBsyVmd_GSwEnCvMvxA%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages