Equation numbering in Jupyter notebooks

会有一股神秘感。 提交于 2019-12-18 12:13:00

问题


The fact is, that in official documentation Jupyter - motivating examples stands

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

I know there is a lot of discussion about this topic. There are some people who claim to solve this issue with some workarounds.

But for ordinary user it is hard to understand the workarounds, or how dirty/useful the hacks really are.

So my questions are:

  1. what means the "available in future version"? Does it mean something like "new month/year" or something like "probably never because it is too impossible"?

  2. If any of the workarounds provided on the Internet safe for a human consumption? I mean is it worthy? Because it is possible to use Sphinx or something else for creation of tutorials, it will be more work, but it will be more work that implementing some hacks, installing plug-ins and so on?

Note: For somebody it could seems to be a question requiring opinion based answer, but I am pretty sure it is not. Any advice can help me (or others users) to make a good/bad decision.


回答1:


I believe that essentially all information relevant to this question can be found in this long Github issue thread.

The conversation there has been ongoing for (at this moment) 3.5 years and is still active. Important highlights:

  • You can very simply turn on numbering by executing a cell with the following content:

    %%javascript
    MathJax.Hub.Config({
        TeX: { equationNumbers: { autoNumber: "AMS" } }
    });
    
  • There is an extension for equation numbering.

  • Developer minrk has suggested that this extension is the right approach and could be merged into master (but the functionality would be turned off by default).

To install the extension via pip:

pip install jupyter_contrib_nbextensions

To install the extensions via Anaconda:

conda install -c conda-forge jupyter_contrib_nbextensions 

After using one of the ways to install provided above, enable the extension:

jupyter contrib nbextension install --user
jupyter nbextension enable equation-numbering/main



回答2:


Here is a working example, to be entered in a markdown cell:

\begin{equation*}
\mathbf{r} \equiv \begin{bmatrix}
y \\
\theta
\end{bmatrix}
\label{eq:vector_ray} \tag{1}
\end{equation*}

Vector **r** is defined by equation $\eqref{eq:vector_ray}$

It's self explanatory but here's some details:

\label : name describing he equation

\tag : the label appearing next to the equationcan be a number or letters

\eqref : reference to the labeled equation

This will be shown as:




回答3:


Go to your Jupyter Notebook editor (I am using Anaconda right now), Edit menu, the last item 'nbextensions config'. It opens a page where you can see a list of extensions, one of which is "Equation Auto Numbering". Enable it and restart your notebook. You will see that a button appears on the top of your notebook for resetting the numbering of equations. You will need to press that button every now and then.



来源:https://stackoverflow.com/questions/41241984/equation-numbering-in-jupyter-notebooks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!