jfbercher / jupyter_latex_envs

(Some) LaTeX environments for Jupyter
Other
112 stars 28 forks source link

version 1.3.8.x cannot display labeled equations #18

Open xmjiao opened 7 years ago

xmjiao commented 7 years ago

It seems that some changes between v 1.3.7.2 and v 1.3.8 broke the processing of labeled equations.

For example, the following latex statement:

\begin{equation}
\label{ftut:elast:varform:equilibrium}
-\boldsymbol{\nabla}\cdot\boldsymbol{\sigma} = \boldsymbol{f}\hbox{ in }\Omega,
\end{equation}

was processed properly in v 1.3.7.x but no longer works with v. 1.3.8. Would you please fix?

BTW, thanks for this package! I found it to be very useful.

jfbercher commented 7 years ago

This is curious. I haven't checked with 1.3.7 but I am surprised it worked. In the whole text, it is very difficult to detect which labels are attached to equations (or align, or gather or eqnarrays, etc), and I only consider as equation labels the labels of the form eq:something. These labels are maintained in their respective environments while the others are replaced by an html anchor. The equation labels are then processed by mathjax. Since the label in your example equation doesn't begin by eq:, it might be replaced by an anchor and this could cause the mathjax processing to fail. Another issue is that latex_envs did not supported several : in labels (more precisely, the prefix in eq:one:two is detected as eq:one instead of eq; This small limitation is removed in this commit. Does all this makes sense?

xmjiao commented 7 years ago

Thanks for the update! I tried the latest version. It made some difference but it is still not completely correct. The equation is rendered but the equation number of (NAN) while the other equations on the same page are rendered (2), (3), etc.

I also noticed that the following equation would not render in the latest code, but worked correctly in v1.3.7:

\begin{align}
  \label{ftut1:ns:continuity}
\rho\left(\dot{\boldsymbol{u}}+\boldsymbol{u}\cdot\boldsymbol{\nabla}\boldsymbol{u}\right) & =\boldsymbol{\nabla}\cdot\boldsymbol{\sigma}(\boldsymbol{u},p)+\boldsymbol{f},\\
  \label{ftut1:ns:momentum}
  \boldsymbol{\nabla} \cdot \boldsymbol{u} &= 0,
\end{align}

So it seems that the bug lies somewhere else.

Hope the information is useful. Thanks again for your great effort!

jfbercher commented 7 years ago

I have checked and for me the examples you provide do not work with latex_envs, version 1.3.7.2 . These examples still work in pure notebook (without the latex_envs). Perhaps was it what you used?

As said before I have for now no simple way (except for an exhaustive test) to detect if the environment at hand is an equation or not, so I rely on the eq: prefix. That is the price to pay to get the other functionalities. The NaN you mention above may come from the fact the ref is unknown. I have just pushed to pypi the last version which includes the latest commit; does it changes something?

leotrs commented 4 years ago

Are there any updates for supporting labels starting with anything other than eq:? For example, labels starting with eqn: are also very common. Otherwise, could you please kindly point to the part of the code base where I could make this change manually?