Ask Your Question

Revision history [back]

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

You need to either escape the backslash: "$\\theta" or to use a raw string: r"$\theta".

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

You need to either can escape the backslash: backslash this way: "$\\theta" or .

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)
show(p)

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

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

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

But it is more convenient to use a raw string: r"$\theta"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)
show(p)

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