Skip to content

Multiple MathJax + Incomplete MathJax #1037

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

Closed
misyntropy opened this issue Feb 2, 2016 · 6 comments · Fixed by #1055
Closed

Multiple MathJax + Incomplete MathJax #1037

misyntropy opened this issue Feb 2, 2016 · 6 comments · Fixed by #1055

Comments

@misyntropy
Copy link

I am using Jupyter with IPython from Anaconda3 on Windows 7, notebook v4.1.0 which seems to contain MathJax 2.5.3 (I had to verify MD5 hashes manually, there is absolutely no mention of MathJax version anywhere).

I tried to switch the math renderer to NativeMML, but it could not find the required config.js. Adding the files directly from the MathJax release did not help (seems to be loading only those files listed in some config var, not the actual directories apparently).

The bigger issue is that I currently have 3 versions of MathJax on my system without having tried any repair of my own :

  1. C:\Users\MilindAnaconda3\pkgs\mathjax-2.2-0\Lib\site-packages\IPython\html\static\mathjax - v2.2.0
  2. C:\Users\Milind.ipython\nbextensions\mathjax - v2.4
  3. C:\Users\Milind\Anaconda3\pkgs\notebook-4.1.0-py34_0\Lib\site-packages\notebook\static\components\MathJax - v2.5.3

It appears that 3. is being used currently.

At this point I cannot figure out what is Anaconda's problem, and what is Jupyter's and what is MathJax's, so wanted to document it here first.

I'd be happy to help in fixing this issue (and others of this level), I love the concept of Jupyter. But I don't know what's going on.

@misyntropy misyntropy changed the title MathJax redundant + incomplete Multiple MathJax + Incomplete MathJax Feb 2, 2016
@minrk
Copy link
Member

minrk commented Feb 2, 2016

I'm not sure what the source of 1. is, perhaps conda used to separate MathJax as a package from IPython, but added it as a dependency. That would only affect the pre-Jupyter notebook (IPython < 4).

Number 2. is a remnant of IPython < 4, when we didn't ship mathjax, due to its size, and the default was to use a CDN. If you wanted local mathjax, you could install it as an nbextension. This no longer has any effect as of notebook 4.0, because we bundle MathJax as a plain old dependency.

The only relevant one if you are using current versions is 3, now that the notebook bundles a stripped MathJax as a normal dependency.

@misyntropy
Copy link
Author

That was informative and explains the situation somewhat, thanks. I should have mentioned that I upgraded Conda from v2 to v3, sorry about that. What remains is 2 things :

  1. Assuming that I'm adamant about MathML, how would I ensure that the required files are accessible to the frontend? Just putting the files in the correct location has no effect : the files are just not found.
  2. Why a stripped copy of MathJax? I'm no authority, but I thought "bundling" meant a local copy with no relation to the direct release, and "dependency" meant a separate package that the package manager recognizes as required.

@minrk
Copy link
Member

minrk commented Feb 2, 2016

Assuming that I'm adamant about MathML, how would I ensure that the required files are accessible to the frontend?

You would need to modify the notebook's build process to change what files are installed, then run python setup.py install. This is where we whitelist MathJax files.

Since we do the slimming at install time, instead of the above, you will have all of MathJax available if you do a development install:

git clone https://github.com/jupyter/notebook
cd notebook
python setup.py js css
pip install -e .

which only links to the source dir, instead of copying the whitelisted files into site-packages.

Why a stripped copy of MathJax?

Size. A complete MathJax install is many times larger than the entirety of the notebook and all other dependencies combined. A slimmed version without image fonts is still more than everything else combined. So we follow the recommended MathJax process for stripping the size of an install by only including the files/fonts we use at install time.

We could add MathML as an additional bundled output format, since it is not especially large.

@misyntropy
Copy link
Author

Since we do the slimming at install time, instead of the above, you will have all of MathJax available if you do a development install:

Even though I copied the new files (NativeMML/config.js) to the location of MathJax (notebook-4.1.0-py34_0\Lib\site-packages\notebook\static\components\MathJax - v2.5.3) , the local server gave a 404 when I tried to access the file via browser. Restarting Jupyter, restarting the system, did not help. What was going on?

We could add MathML as an additional bundled output format, since it is not especially large.

That would be great. Not all of us live and die by Google's mandates (re: chrome's removal of MathML).

Size. A complete MathJax install is many times larger than the entirety of the notebook and all other dependencies combined.

Ok I understand the point about disproportionate size, but for context : the anaconda installer alone is 330MB. Any number of MathJax files of any size is not going to affect me in any way. And I think such users would form a significant chunk of Jupyter's userbase.

I hope you guys can point me to the reason (github issue/commit) why IPython3/Jupyter moved to a bundled copy of MathJax from a package/nbextension... And would it be possible for me to redirect Jupyter to use a full, separately installed copy of MathJax? I am guessing that I could install a copy of MathJax, and then change some paths in Jupyter.

@minrk
Copy link
Member

minrk commented Feb 4, 2016

If you have a full MathJax installed in nbextensions. That would be:

`jupyter --data-dir`/nbextensions/mathjax

You can tell the notebook to use that one with:

c.NotebookApp.mathjax_url = 'nbextensions/mathjax'

As for the reasoning for bundling: we used to use MathJax from a CDN because the size of a mathjax dependency was completely unacceptable. That was suboptimal because it meant for most users, math wouldn't work without a network connection (e.g. on a plane). Only by using a stripped copy, following the MathJax documentation for reducing the size of a MathJax install, was it feasible to treat it like the rest of our js dependencies.

@goerz
Copy link

goerz commented Jun 28, 2018

That should be

c.NotebookApp.mathjax_url = '/nbextensions/mathjax/MathJax.js'

Cf. b3f02b2

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants