Ask Your Question

LaTeX in plot not showing Greek letter

asked 2014-12-10 20:22:46 +0100

mathochist gravatar image

Hello. I'm using the following code to generate an image of a triangle for a trigonometry quiz.

p = polygon2d([[0,0], [0,3], [4,0]], fill = False, axes = False)
p += text("$\theta$", (3, 0.2), fontsize = 22)

The issue is that Sage doesn't seem to recognise $\theta$ as LaTeX, even though it's in dollar signs. In the corner of the triangle, it puts "heta". Why isn't this typesetting correctly? How can I fix it?

Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-12-10 20:39:07 +0100

slelievre gravatar image

updated 2014-12-11 13:31:08 +0100

In the string "$\theta$", the group \t becomes a tab.

You can escape the backslash this way: "$\\theta$".

But it is more convenient to use a raw string: r"$\theta$".

So your code becomes:

p = polygon2d([[0,0], [0,3], [4,0]], fill = False, axes = False)
p += text(r"$\theta$", (3, 0.2), fontsize = 22)

Use this trick whenever you have text containing \, which is often the case if your text is latex code!

edit flag offensive delete link more


I want to give this more than one up vote! (I mean without messing with the admin panel.) I must have answered this very question 10 times at AIMS, and it happens to me at least once a semester as well. I wonder where a good place to document this would be? (Since our FAQ is moribund - though that would be a pretty good place.)

kcrisman gravatar imagekcrisman ( 2014-12-10 21:00:02 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2014-12-10 20:22:46 +0100

Seen: 1,882 times

Last updated: Dec 11 '14