MyST-NB icon indicating copy to clipboard operation
MyST-NB copied to clipboard

Problem with Ipython.display Markdown with math

Open WKorzen opened this issue 1 year ago • 2 comments

Describe the bug

context When I do create ipynb with cell

text2 = ('Lorem ipsum $x$ lorem $A$ ipsum?\n'
           '\t\\[\n\t\t\\text{A=}\\left[\\begin{matrix}2 x + 4 & x - 4\\\\x + 1 & -1\\end{matrix}\\right]\n'
           '\t\\]\n'
           'Lorem ipsum $x=-2.$ Ipsum lorem.\n')

and

Markdown(text2.replace('\\[','$$').replace('\\]','$$'))

I receive wrong result generated by sphinx with myst_nb

image

expectation I expected like in jupyter lab image

bug But i received image

Reproduce the bug

  • Create ipynb and add to index
  • make html

List your environment

installed:

myst-nb                       1.1.1
myst-parser                   4.0.0
jupyter                       1.1.1
jupyter-cache                 1.0.0
jupyter_client                8.6.2
jupyter-console               6.6.3
jupyter_core                  5.7.2
jupyter-events                0.10.0
jupyter-lsp                   2.2.5
jupyter_server                2.14.2
jupyter_server_terminals      0.5.3
jupyterlab                    4.2.5
jupyterlab_pygments           0.3.0
jupyterlab_server             2.27.3
jupyterlab_widgets            3.0.13
nbsphinx                      0.9.5
sphinx-autoapi                3.3.1
sphinx-rtd-theme              2.0.0
sphinxcontrib-applehelp       2.0.0
sphinxcontrib-devhelp         2.0.0
sphinxcontrib-htmlhelp        2.1.0
sphinxcontrib-jquery          4.1
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          2.0.0
sphinxcontrib-serializinghtml 2.0.0

my conf.py:

project = u"test"
   
extensions = [
         "myst_nb"
]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

html_theme = "sphinx_rtd_theme"

WKorzen avatar Sep 19 '24 23:09 WKorzen

I haven't tried a fix here, but for LaTeX heavy notebooks over at astroml-notebooks, padding the equations with empty lines solved these rendering issues for me.

bsipocz avatar Sep 19 '24 23:09 bsipocz

I haven't tried a fix here, but for LaTeX heavy notebooks over at astroml-notebooks, padding the equations with empty lines solved these rendering issues for me.

Thanks, I tried and received: image

I also tried 'dollarmath' (works with nbsphinx) and 'amsmath' extensions unfortunately without success.

WKorzen avatar Sep 20 '24 06:09 WKorzen