danielfrg / mkdocs-jupyter

Use Jupyter Notebook in mkdocs
https://mkdocs-jupyter.danielfrg.com
Apache License 2.0
402 stars 49 forks source link

inline math (latex) not rendering #209

Closed leoyala closed 3 months ago

leoyala commented 3 months ago

Hello.

I am using mkdocs-jupyter to add some tutorials tot eh documentation of a package I am working on. However. inline math is not being converted to an equation (see image below). The strange part is that math that is surrounded by double symbols ($$) is rendered properly (see second image below). Do you have any idea why?

I am using: mkdocs-jupyter 0.24.8 nbconvert 7.16.4 mkdocs-material 9.5.30

## Example 1: Estimating $\pi$
Monte Carlo methods have different approaches, but tend to follow a particular pattern:

1. Define a domain of possible inputs
2. Generate inputs randomly from a probability distribution over the domain
3. Perform a deterministic computation on the inputs
4. Aggregate the results

For example, consider a quadrant (circular sector) inscribed in a unit square. Given that the ratio of their areas is $\pi/4$ the value of $\pi$ can be approximated using a Monte Carlo method:
1. Draw a square, then inscribe a quadrant within it
2. Uniformly scatter a given number of points over the square
3. Count the number of points inside the quadrant, i.e. having a distance from the origin of less than 1
4. The ratio of the inside-count and the total-sample-count is an estimate of the ratio of the two areas, $\pi/4$. Multiply the result by 4 to estimate $\pi$.

image

## Example 2: Integral approximation
In this example we will try to approximate the following integral

$$I = \int_0^\infty \frac{e^{-x}}{1+(x-1)^2}$$

image

leoyala commented 3 months ago

I fixed this by including these lines in the configuration for the plugin in mkdocs.yaml:

      include_requirejs: true
      custom_mathjax_url: "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS_CHTML-full,Safe"

So it should look like this:

plugins:
  - mkdocs-jupyter:
      execute: false
      allow_errors: true
      include_requirejs: true
      custom_mathjax_url: "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS_CHTML-full,Safe"