First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 14 years ago

DSM gravatar image

I don't know that there is one. But you can use the text command, and wrap the latex in $:

text("Behold the power of TeX: $\\frac{x^2}{y^3} = 7$", (0, 0), axes=False,fontsize=20)

So you can trivially write a latexrender command yourself:

def latexrender(s):
    pic = text("$" + s.replace('$','\$') + "$",(0,0),axes=False, color='black',fontsize=20)
    pic.show()

Adding extra features like allowing you to specify the properties via **kwargs is left as an exercise for the reader.

click to hide/show revision 2
No.2 Revision

I don't know that there is one. But you can use the text command, and wrap the latex in $:

text("Behold the power of TeX: $\\frac{x^2}{y^3} = 7$", (0, 0), axes=False,fontsize=20)

So you can trivially write a latexrender command yourself:

def latexrender(s):
    pic = text("$" + s.replace('$','\$') + "$",(0,0),axes=False, color='black',fontsize=20)
    pic.show()

latexrender("17 + \sum_{i=2}^{q} \, k^2 = 29383")

Adding extra features like allowing you to specify the properties via **kwargs is left as an exercise for the reader.

click to hide/show revision 3
No.3 Revision

I don't know that there is one. But you can use the text command, and wrap the latex in $:

text("Behold the power of TeX: $\\frac{x^2}{y^3} = 7$", (0, 0), axes=False,fontsize=20)

So you can trivially write a latexrender command yourself:

def latexrender(s):
    pic = text("$" + s.replace('$','\$') + "$",(0,0),axes=False, color='black',fontsize=20)
    pic.show()

latexrender("17 + \sum_{i=2}^{q} \, k^2 = 29383")

Adding extra features like allowing you to specify the properties via **kwargs is left as an exercise for the reader.reader. I should note though that the above uses matplotlib's TeX implementation, not any system verison, AFAIK.

click to hide/show revision 4
No.4 Revision

I don't know that there is one. But from the console, you can use the text command, and wrap the latex in $:

text("Behold the power of TeX: $\\frac{x^2}{y^3} = 7$", (0, 0), axes=False,fontsize=20)

So you can trivially write a latexrender command yourself:

def latexrender(s):
    pic = text("$" + s.replace('$','\$') + "$",(0,0),axes=False, color='black',fontsize=20)
    pic.show()

latexrender("17 + \sum_{i=2}^{q} \, k^2 = 29383")

Adding extra features like allowing you to specify the properties via **kwargs is left as an exercise for the reader. I should note though that the above uses matplotlib's TeX implementation, not any system verison, verson, AFAIK.

Let's see if I can figure out how to do this from the notebook..

click to hide/show revision 5
No.5 Revision

I don't know that there is one. But from the console, you can use the text command, and wrap the latex in $:

text("Behold the power of TeX: $\\frac{x^2}{y^3} = 7$", (0, 0), axes=False,fontsize=20)

So you can trivially write a latexrender command yourself:

def latexrender(s):
    pic = text("$" + s.replace('$','\$') + "$",(0,0),axes=False, color='black',fontsize=20)
    pic.show()

latexrender("17 + \sum_{i=2}^{q} \, k^2 = 29383")

Adding extra features like allowing you to specify the properties via **kwargs is left as an exercise for the reader. I should note though that the above uses matplotlib's TeX implementation, not any system verson, AFAIK.

Let's see if I can figure out how to do this from the notebook..notebook.. okay, the above still works there. I'll see if I can figure out how to get LaTeX itself called (although I should say that the matplotlib mathtext has worked pretty well for me).

click to hide/show revision 6
No.6 Revision

I don't know that there is one. But from the console, you can use the text command, and wrap the latex in $:

text("Behold the power of TeX: $\\frac{x^2}{y^3} = 7$", (0, 0), axes=False,fontsize=20)

So you can trivially write a latexrender command yourself:

def latexrender(s):
    pic = text("$" + s.replace('$','\$') + "$",(0,0),axes=False, color='black',fontsize=20)
    pic.show()

latexrender("17 latexrender(r"17 + \sum_{i=2}^{q} \, k^2 = 29383")

Adding extra features like allowing you to specify the properties via **kwargs is left as an exercise for the reader. I should note though that the above uses matplotlib's TeX implementation, not any system verson, AFAIK.

Let's see if I can figure out how to do this from the notebook.. okay, the above still works there. I'll see if I can figure out how to get LaTeX itself called (although I should say that the matplotlib mathtext has worked pretty well for me).

After a little thought, something like the following should get the job done:

import matplotlib
matplotlib.rcParams['text.usetex']=True
def latexrender(s):
    pic = text("$" + s.replace('$','\$') + "$",(0,0),axes=False, color='black',fontsize=20)
    pic.show()

latexrender(r"17 + \displaystyle\sum\limits_{i=2}^q \, k^2 = 29383")