"Ken Schutte" <kts.lists@...287...> writes:
I'm trying to add some more complex LaTeX-rendered equations into a a
figure, and having some problems. I've been trying various things
with 'usetex', but it seems the problem might be that I can't seem to
write the LaTex code on a single line.
It seems that text objects containing newlines are not passed to LaTeX
correctly. I suspect this might be an interaction with a (non-usetex)
feature where the lines of a multiline string are aligned separately,
e.g.:
text(0,0,'''very long line here
foobar
baz''', ha='center')
You should be able to work around this particular problem by not using
any newlines, but this example has another problem:
\begin{equation*}
x(t) =
\begin{cases}
1, \quad & t \ge 0 \\
0, & t < 0
\end{cases}
\end{equation*}
You need to use the amsmath package. The (totally unsupported) way to do
this is use the text.latex.preamble setting:
text.latex.preamble : \usepackage{amsmath}
# IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES
# AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP
# IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO.
After adding that setting, this works for me:
In [1]: t = r'''
...: \begin{equation*}
...: x(t) =
...: \begin{cases}
...: 1, \quad & t \ge 0 \\
...: 0, & t < 0
...: \end{cases}
...: \end{equation*}
...: '''
In [2]: text(0,0,t.replace('\n',' '))
Out[2]: <matplotlib.text.Text object at 0xab82a50>
···
--
Jouni K. Sepp�nen