Open PanJi-0 opened 1 month ago
Hello @PanJi-0 - thanks for raising your issue. What version of Python are you using?
I need to update the version used in the book (currently 3.9). But I tried with Python 3.10 and could render equations on my MacOS Sonoma 14.5, here's what I did:
mathjax
extension to the config file
extensions = [
"myst_nb",
"autoapi.extension",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.mathjax",
]
mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
{math} directive
as follows:
* Dollar sign notation
$$x + y = z$$
$$(a - b)^2 = a^2 - 2ab + b^2$$
x + y = z
(a - b)^2 = a^2 - 2ab + b^2
I've included all files in a ZIP here for your reference.
![image](https://github.com/user-attachments/assets/2a687e1b-8a1d-4915-a145-d6f5239d0adc)
[docs.zip](https://github.com/user-attachments/files/17319809/docs.zip)
Thank you so much for your help! The Python version I used is 3.9. I didn’t realize that this could be a contributing factor. I’ll give it a try with Python 3.10 as you suggested.
Thank you! It works. The block equations now render perfectly using both methods.
For inline equations, I find that if the file contains:
```{math}
...
```
then using \\(...\\)
works for rendering inline equations. But without this structure, I have no idea how to make inline math render correctly.
Anyway, the solution works well enough for my current needs.
Thanks again for your support!
Hello,
I'm using the Python package template from the book and encountered an issue with LaTeX math equations in
.ipynb
and.md
files not rendering correctly in the generated HTML using Sphinx. Specifically, the inline math like$x + y = z$
and block math like$$x + y = z$$
are not displayed as expected in the final documentation.Steps I’ve taken:
I added the following configuration to
conf.py
:I cleaned and rebuilt the documentation using:
The problem:
Even after following the above steps which I learnt from ChatGPT and Google, LaTeX equations in both
.ipynb
and.md
files are not rendering in the final HTML output. The equations appear as plain text rather than formatted math.Environment:
macOS Sonoma 14.5 All other settings and configurations are equivalent to those of
pycount
in the book.Thank you!