Skip to content
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

Unreliable LaTeX equation rendering #3

Closed
borlafgis opened this issue Feb 3, 2024 · 9 comments
Closed

Unreliable LaTeX equation rendering #3

borlafgis opened this issue Feb 3, 2024 · 9 comments

Comments

@borlafgis
Copy link

borlafgis commented Feb 3, 2024

I've been tying the extension, and it works great for the most part, but I am having issues with LaTeX expressions: sometimes they are not rendered or they are not correctly rendered.

When they do not render (they do not seem to be recognized by mathjax), there are some things that may be clues of what is happening:

  • LaTeX blocks are represented as surrounded by \[ and \] or (\( \)), even though I only use '$' at the start/end.

image

image

  • If I refresh the page sometimes the rendering comes back
  • Moving markdown cells seems to cause breaks in the rendering
  • Disabling the extension restores everything

When they do not render correctly, a right click > math settings > restore defaults allows the equations to be properly visualized

Broken
image

Re-rendered:
image

@borlafgis
Copy link
Author

borlafgis commented Mar 15, 2024

I updated jupyterlab-quarto to version 0.3.2 and then to 0.3.3. Everything seemed to work ok for a while, but now the issues are back:

Some cells are rendered wrong (if I reset mathjax to defaults they come back)
image

Some cells do not render at all no matter what I do
image

I was trying to create a minimal example, deleted a markdown sub-title cell (starting with ##) and all equations came back. It may be related to the notebook structure/ordering/cell ID's?

Also, if I close the notebook without shutting it down, when I reopen it all equations are rendered as plain text. If I refresh the tab everything goes back to normal

Thank you for your time,
Ignacio

@dragonstyle
Copy link
Contributor

I actually don't have much of a theory, unfortunately. When the notebook loads, we looks through the cells for math to be typeset and then run the MathJax typesetter on those elements. 0.3.3 added an observer that will properly do this when you add new markdown cells to the notebook. But I'm not sure why it would be so intermittent for you :(.

If you can narrow it down or share a notebook when you have it in a state that reproduces it, I could use that to see if I could reproduce the issue (which would make it much easier to fix). In addition, there could be error in the browser console (e.g. a javascript error) that could be helpful- the next time you see a failure to typeset could you check that (under your browser developer tools)?

@borlafgis
Copy link
Author

I think I found an example of a cell that refuses to render. It is in the section "time domain statistics" (the notebook is inside the zip)

0issues.zip

Miniforge console does not show any noticeable errors

@dragonstyle
Copy link
Contributor

Here's what I see when I run it locally :(. It may be a particular state that you have some way to get to (e.g. editing sequence or workflow of some kind). It also could be interaction with other Jupyter lab extensions, perhaps? Trying to think of other possibly related factors....

Screenshot 2024-03-16 at 5 14 12 PM

@borlafgis
Copy link
Author

borlafgis commented Mar 17, 2024

I will keep on trying. I will check to see if it is related to the enviroment, or something that has been left in a weird state.

Thanks a lot for your time!

P.D. 1: I have tried in a fresh environment and the markdown cells seem to be working, but I get the same issues when I use display(Math()) or display(Markdown()). It is under the first "SEPARATOR" section

P.D. 3: I am having issues rendering this notebook on the fresh environment:
https://github.com/Mark-Kramer/Case-Studies-Python/blob/master/03.ipynb
The formulae in the section "Step 1: Visual inspection" do not render if the jupyterlab-quarto pugin is active
image

P.D. 4: Launching jupyterlab showed this

    To access the server, open this file in a browser:
        file:///C:/Users/basti/AppData/Roaming/jupyter/runtime/jpserver-10608-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=be8c3a8442d57506024eca71d9c80457eca78d9d4e415989
        http://127.0.0.1:8888/lab?token=be8c3a8442d57506024eca71d9c80457eca78d9d4e415989
[I 2024-03-17 10:30:49.652 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[W 2024-03-17 10:30:53.241 LabApp] Could not determine jupyterlab build status without nodejs
[I 2024-03-17 10:30:56.504 ServerApp] Kernel started: 180398e5-d0ff-45a7-8805-8e92cfa7b4d9
[I 2024-03-17 10:30:56.554 ServerApp] Kernel started: 9c7006ea-0b41-4873-b9d8-86eca065f3db
0.01s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.01s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.01s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[I 2024-03-17 10:30:59.094 ServerApp] Connecting to kernel 180398e5-d0ff-45a7-8805-8e92cfa7b4d9.
[I 2024-03-17 10:30:59.364 ServerApp] Connecting to kernel 9c7006ea-0b41-4873-b9d8-86eca065f3db.
[I 2024-03-17 10:30:59.384 ServerApp] Connecting to kernel 9c7006ea-0b41-4873-b9d8-86eca065f3db.
[I 2024-03-17 10:30:59.401 ServerApp] Connecting to kernel 9c7006ea-0b41-4873-b9d8-86eca065f3db.
[I 2024-03-17 10:32:55.571 ServerApp] Saving file at /Documents/Profesional/2023-12-08-Python4geo/materials/Ch05_timeSeries/Ch05_timeSeries.ipynb
[I 2024-03-17 10:32:56.213 ServerApp] Saving file at /Documents/Profesional/2023-12-08-Python4geo/materials/Ch05_timeSeries/0issues.ipynb

P.D. 5. The issues are back with 0issues.ipynb :(
image

I will add some details abut my tests:

  • I use conda environments
  • I am using windows and chrome
  • There are issues if I onstal jupyterlab with conda and jupyterlab-quarto with pip in a minimal environment
  • There are issues if I install both with pip (in a different minimal environment)

@tmatthias29
Copy link

tmatthias29 commented Apr 4, 2024

I have nothing to add except that I've run into this issue and started pulling out hair to figure out what was going run. It's definitely the jupyterlab-quarto extension changing the LaTeX/MathJax output, but I don't know nearly enough about this to comment any further. I should note that I tried this is a totally clean JupyterLab environment.

I setup a really simple issue to confirm my issue. Basically, the following renders correctly in a Jupyter Notebook and Jupyter Lab environment, without jupyterlab-extension installed:

Screenshot 2024-04-04 at 2 53 42 PM

But with jupyterlab-extension installed, it seems like the output will drop random variables/symbols. In this case, it's dropping symbols when I'm using the $x^2$ notation, but this seems to be an issue even when rendering SymPy/LaTeX output as well (i.e. with Display). It might be related to flipping the order around, see the second image.

Screenshot 2024-04-04 at 2 51 37 PM Screenshot 2024-04-04 at 2 55 28 PM

Considering how useful the extension is, would be great to have this resolved, but I guess for now I'll need to remove the extension when I need to render MathJax.

@tmatthias29
Copy link

tmatthias29 commented Apr 4, 2024

Turns out, I think the issue is also (or maybe only) caused by having Markdown cells in the notebook when the extension is installed. Before I added any markdown cells in, the equation was displaying correctly (was trying this with a euclidean distance equation for a class I'm in). Started adding some markdown cells and then this happened:

Screenshot 2024-04-04 at 4 19 47 PM

@BigFlagBurito
Copy link

I have the same problem.
Have any of you found a possible solution?

@drmikecooke
Copy link

drmikecooke commented Dec 11, 2024

I have uninstalled quarto (which I installed to see if it was useful; for me, not really) since it stopped me rendering matrix equations in markdown. This, for example, the first in a sequence of pmatrices:

$$\begin{pmatrix} u_x\\ v_x \end{pmatrix}= \begin{pmatrix} 1 & x/p\\ 0 & 1 \end{pmatrix} \begin{pmatrix} u_0\\ v_0 \end{pmatrix}.$$

rendered up to the last double dollar, which it rendered as a double dollar, but then continued for the rest of the document as if the display math-mode was not closed with the text running off the page.

This was in an md file, and I was using the jupyterlab preview function.

By the way, the parentheses on the preview tab here don't properly render, but just give normal-sized rather than the extended form. The mathjax latex rendering github uses, doesn't seem correct. I have used mathjax in the past to render and didn't seem to have a problem.

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

No branches or pull requests

5 participants