jupyterquiz icon indicating copy to clipboard operation
jupyterquiz copied to clipboard

Javascript Error: MathJax.typeset is not a function

Open nvaytet opened this issue 1 year ago • 10 comments

Getting the error Javascript Error: MathJax.typeset is not a function when making a quiz in a notebook. The quiz seems to work fine, but the error is displayed below the quiz display: Screenshot at 2023-08-24 10-12-22

I'm using JupyterLab, in case that helps?

nvaytet avatar Aug 24 '23 08:08 nvaytet

Can you please try the following? Make a Markdown cell above your cell that calls JupyterQuiz and put any LaTeX in it. For instance, the following should just be a blank space:

$~$

Please let me know if that resolves that error, and then I will consider how to best mitigate this in general.

jmshea avatar Aug 29 '23 15:08 jmshea

Hi there, I tried what you suggested but it did not make the error go away :-(

nvaytet avatar Aug 30 '23 14:08 nvaytet

I have also encountered this error message, and the resulting quiz does not correctly typeset the math. image After looking into the console for error message, I found out that the error message is in this line: image my MathJax version is 3.2.2. Could you help me with this issue?

scott-yj-yang avatar Jan 04 '24 23:01 scott-yj-yang

This is a strange error because MathJax.typeset() is definitely defined in MathJax 3.2.2.

Can you please provide more information to help me try to figure this out:

What is the environment you are running this in? Is this in JupyterLab or something else? What version?

Can you open the Javascript Console in your browser and capture the output after executing the code that causes the error you sent?

jmshea avatar Jan 05 '24 01:01 jmshea

Thank you for your quick reply. I execute the notebook inside the conda environment. I tried both Jupyter notebook and JupyterLab, but yielded the same error message.

Name: notebook Version: 7.0.6 Name: jupyterlab Version: 4.0.10

The following is the console output of the Javascript. image

scott-yj-yang avatar Jan 05 '24 03:01 scott-yj-yang

This is actually affecting me, too. The issue is that in JupyterLab 4, the MathJax variable never gets updated to have the appropriate methods. I have not been able to figure out how to access the MathJax.typeset() method, so I have reached out on the JupyterLab Discourse. I will update when I known something more.

jmshea avatar Jan 06 '24 13:01 jmshea

OK, I have coded up a solution that works for me, but it is a little "hacky". Basically, I check whether MathJax.typeset() is available if it looks like MathJax 3 is loaded. If it is not available, then I configure and load MathJax 3 myself. Can you try it out? You will need to install version 2.7.0a1:

pip install jupyterquiz==2.7.0a1

The make sure you restart your kernel and rerun your Jupyter notebook using JupyterQuiz. Let me know if that solves the issue for you and if it causes any undesirable side effects to the rest of your NB.

jmshea avatar Jan 06 '24 15:01 jmshea

Thanks for the promptly reply! Yes, the version 2.7.0a1 resolve the rendering issue. Now the LaTeX math can be rendered normally.

scott-yj-yang avatar Jan 11 '24 20:01 scott-yj-yang

Great! Please bump to 2.7.0a2 to get better support for dark mode themes.

jmshea avatar Jan 29 '24 22:01 jmshea

I am going to leave this open until we get a proper fix from upstream

jmshea avatar Jan 29 '24 22:01 jmshea