moonkeeper
moonkeeper

Reputation: 31

How to reference a equation cross cell in jupyter markdown

While using jupyter notebook, how can I reference equations cross cells? I found a way to referencing, but cannot auto update the displayed number.

$a=b+c \tag{*}\label{eq1}$

The referencing code [1](#mjx-eqn-eq1) displayed 1. How can it display what's in \tag{} automatically?

Upvotes: 3

Views: 2135

Answers (1)

Greenfly77
Greenfly77

Reputation: 195

Since you create a markdown link and you name it 1, this won't update. In general, Jupyter notebooks utilize MathJax (a subset of LaTeX) to render equations. The official jupyter documentation provides additional information and examples it is said, that:

Equation numbering and referencing will be available in a future version of the Jupyter notebook.

While this statement is quite old, it still seems still to be valid. As far as I can see, there are a couple of options to achieve numbering and referencing. Here is some examples:

  • MathJax provides numbering and linking. For me it did not at all work, maybe because of what the jupyter documentation says.
  • Thus, I installed and activated jupyter-contrib-nbextensions (jut as described in their readme).
  • Now my equations are numbered (actually tagged) and the reference will be updated automatically. However, there seems an issue with auto numbering, since I always also have to define a number as tag. Here is an example:
    In equation \eqref{eq:sample}, we find the value of an
    interesting integral:
    
    \begin{equation}
      \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
      \label{eq:sample} \tag{a}
    \end{equation}

Changing the tag will also update the reference. According documentation, using \label only should result in an automatically numbered equation (as in LaTeX), however that does not work for me. Maybe I have to install another extension to get it working.

Upvotes: 2

Related Questions