pythonjupyter-notebooksympy

Show multiple LaTeX-style sympy equations in a single jupyter notebook cell


Is there a way to make python (using a jupyter notebook) print multiple lines while keeping the nice equation format style?. So far, I only get python to print the last equation in SymPy's pretty printing style. In the below example, it is 2x - 4 = 20.

However, the equations y1 and y2 are not printed (or it might be better to say that they are overwritten by y3's output). When I try using a list, I only get the "raw" text, not the pretty printing format.

I have looked through Stack Overflow but I have not been able to get it to work. Does anyone know how to do this?

enter image description here


Solution

  • Jupyter notebooks display the last thing in the cell, which in your case is y3. To show all of them, you can wrap each one in display, i.e.

    display(y1)
    display(y2)
    display(y3)
    

    or put them all into a single display call.

    display(y1, y2, y3)