fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.94k stars 285 forks source link

Equation numbering: MathJax native solution #1460

Open mdAshford opened 3 years ago

mdAshford commented 3 years ago

Could we not activate equation autonumbering when MathJax is loaded (which is the norm for MathJax)?

So, in SetupMathJax.js, add tags: 'ams' to the tex configuration block:

from

    tex: {
        inlineMath: [
            ["$", "$"],
            ["\\(", "\\)"],
        ],
    },

to

    tex: {
        tags: 'ams',
        inlineMath: [
            ["$", "$"],
            ["\\(", "\\)"],
        ],
    },

I get full MathJax functionality after making the change.

Equation numbers always get out of sequence (additions, selections, etc). I was working on a button to force MathJax to re-render the math, but reloading the page works well enough.

One can always suppress eqn numbering with the \notag switch or starred environments ( \begin{equation*} vs \begin{equation} )

By the way, I love you dearly for config/launching MathJax in its own script.

fonsp commented 3 years ago

What happens when you add new equations in the middle of a page? Are later equations re-numbered? Are references updated?

mdAshford commented 2 years ago

What happens when you add new equations in the middle of a page? Are later equations re-numbered? Are references updated?

New equations get numbered with the next increment, relative to the entire page. Moreover, rerunning a cell with numbered equations bumps those numbers to the next available. Call it a feature: (1466) means I'm fiddling too much.

However, simply reloading the page renumbers everything, updates all the references, etc. It works well, though the reload is a little janky in principle. Unsaved changes could get lost, but the do-you-really-want-to-leave-the-page warning is basic protection. Re-executing cells containing labelled equations sends MathJax into hysterics over duplicate labels, but that's well-established MathJax behavior. Page-reload fixes that, too.

If you've used the classic Jupyter notebooks with any of the autonumbering nbextensions active, the behavior will feel familiar (except they have a button that triggers a MathJax-only reload). On page reload, the renumbering appears to run top-down, but I haven't yet tested it with cells containing both MathJax and Julia to see what happens with Pluto's cell-execution ordering.

fonsp commented 2 years ago

I'm not happy with that behaviour, it feels clunky and un-pluto-y. We might be able to use it if we can trigger the renumbering automatically whenever needed