tweaked var to latex.py to work with sympy

I think some of the changes I submitted to the sympy project got dropped.