jfbercher / jupyter_latex_envs

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

Interaction with other nbextensions #21

Open GProtoZeroW opened 7 years ago

GProtoZeroW commented 7 years ago

Dr. Bercher, Since coming across your notebook extension for better LaTex integration in the jupyter notebook I have been trying it out and overall have been fairly happy with; however, there are two issues that I have come across that have caused me some issue. The main issue is the interaction with the other notebook excitation Python Markdown while that extinction has some of its own issues the big issue is that it is completely incompatible with your extension

for example, if I make a sympy equation, perform the conversion to latex I would then try to insert it in a markdown cell in a formal equation environment. However, when I then run the markdown cell I am just given back the str object's memory address that I tried to pass via python markdown

code cell: from sympy import * init_printing() x, m, b=symbols('x, m, b') y=Function('y') lin=latex(Eq(y(x), m*x+b)) lin markdown cell \begin{equation} {{lin}} \end{equation} the output of the markdown cell is

The other two things that I would greatly appreciate in a update to this exstations is some more extensive docs on how to customize enviorments both in the notebook and in latex/html conversions. As well as way to interact with the hide cell exstation.

PS as a EE/Physics major I sincerely appreciate your signals and system repo for python

jfbercher commented 7 years ago

Hi, Actually, the problem is not related with latex_envs. Disabling it and rendering again gives the same result. The point is that the str representation of lin is <span id="python_31C1C7D4631048C081658F335BB5CB83_17">y{\left (x \right )} = b + m x</span> </p>, which includes some html code. The equations are interpreted by MathJax which does not support html in equation environments.

In principle, I could try to filter out html from equation environments, but (i) it would need some specialized code (ii) I am not sure that it will not have side effects (iii) the result will depend on the execution order of python-markdown and latex_ens extensions, which is inpredictible; I must think further on that...

jfbercher commented 7 years ago

What do you mean by interacting with the hide cellextension?

Thanks for the kind words on my LecturesOnSignalProcessing repo.

jcb91 commented 7 years ago

I'm guessing the appropriate solution would be to insert a python expression which yields a LaTeX representation of the sympy object, rather than an html/string one, so that it can be parsed correctly by mathjax...

jcb91 commented 7 years ago

As for the processing order of latex_envs and python_markdown, I think you're right @jfbercher, and it would be a good idea to define their order of execution - my guess is that it makes most sense to do the MD replacements before latex stuff...