[IPython-User] tex magic: parsing calculations to tex

Matthias BUSSONNIER bussonniermatthias@gmail....
Sat Aug 25 07:50:08 CDT 2012

Le 25 août 2012 à 11:51, Johan Beke a écrit :

> Hi all,
> As I said before, I would like to have numerical input formulas parsed to tex. I've written a simple magic function 'tex' which does the trick for numerical expressions. For the moment it needs to be without assignment. 
> The code:
> ...

I didn't looked at everything, will do later  when I've more time. 

> I've modified some code I found on stackoverflow. I don't know if it can be legally included in the ipython distribution. However, I can have a workaround with regex and string functions. Had some code but it is more complicated than this.
> identifiers for variables are parsed a bit different. The first occurrence of _ is the real LaTeX subscript. Next occurrences will give a comma.
> Any comments?

I don't use it a lot, but I know that sympy already have the ability to render variable as latex with the sympyprinting extension. They also  do nice things like treating underscore in variable name like you do. Maybe this could be merged into the sympyprinting extension ? Or share code with it. I think especially of all the correspondence between name <-> tex symbol.

> Screenshot: http://i50.tinypic.com/2gvpwmv.png

You could also use http://nbviewer.ipython.org/ :-)

You could make it as en extension (upload it to a gist ? ) and please add it to the known extension index : 


More information about the IPython-User mailing list