multiline mlath text

Hi,

I want to display the values of some variable (namely, alpha, beta, gamma, delta) on a plot, and making a legend like
“$ \alpha=%G, \ \bet=%G, \ \gamma=%G, \ \delta=%G $” % values is not very readable.
Is there away to make multiline mathtext ?

thanks

BL

There is no way to insert newlines in the mathtext part of the string (by that I mean between the '$'). However, you can put newline characters outside of '$'. It gets a bit hairy because of Python's string escaping rules, but you could do something like:

   "$\\alpha=%G$\n$\\beta=%G$"

Note the double \\ where we really want a backslash, since we can't use "raw" string literals and write a newline character.

One other caveat: The spacing of the lines doesn't take into account the height of the math expression, so you can really only do simple one-liners (i.e. no fractions or exponents) in the math expression. Your example looks like it will work though.

This is really sort of "unsupported" and my example works only by accident... it's something I didn't think about while re-writing mathtext recently. Hopefully this can be improved in a future version -- I can see it as being generally useful.

Also -- for others on the list: Is there a TeX or LaTeX standard for putting newlines in the middle of a math expression that perhaps we should support? All the Googling I've been able to do basically assumes that layout such as that would occur in a layer outside of the math expression (with the exception of typesetting things like matrices).

Cheers,
Mike

BL wrote:

···

   Hi,

I want to display the values of some variable (namely, alpha, beta, gamma, delta) on a plot, and making a legend like "$ \alpha=%G, \ \bet=%G, \ \gamma=%G, \ \delta=%G $" % values is not very readable. Is there away to make multiline mathtext ?

thanks

BL

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

I dont think newlines are supported this way in tex. Here's an example:

\documentclass[]{article}

\begin{document}

$a=e^{i\pi}\\x=y$

$$a=e^{i\pi}\\x=y$$

\begin{eqnarray}
a & = & \frac{e^{i\pi}}{e^{-i\pi}} \\
  & = & e^{i2\pi}
\end{eqnarray}

\end{document}

The first treats the newline as if it occurred in regular text mode, the
second ignores the newline entirely, and the third is intelligent enough to
do what it should.

···

On Thursday 17 January 2008 08:51:06 am Michael Droettboom wrote:

There is no way to insert newlines in the mathtext part of the string
(by that I mean between the '$'). However, you can put newline
characters outside of '$'. It gets a bit hairy because of Python's
string escaping rules, but you could do something like:

   "$\\alpha=%G$\n$\\beta=%G$"

Note the double \\ where we really want a backslash, since we can't use
"raw" string literals and write a newline character.

One other caveat: The spacing of the lines doesn't take into account the
height of the math expression, so you can really only do simple
one-liners (i.e. no fractions or exponents) in the math expression.
Your example looks like it will work though.

This is really sort of "unsupported" and my example works only by
accident... it's something I didn't think about while re-writing
mathtext recently. Hopefully this can be improved in a future version
-- I can see it as being generally useful.

Also -- for others on the list: Is there a TeX or LaTeX standard for
putting newlines in the middle of a math expression that perhaps we
should support? All the Googling I've been able to do basically assumes
that layout such as that would occur in a layer outside of the math
expression (with the exception of typesetting things like matrices).

Cheers,
Mike

BL wrote:
> Hi,
>
> I want to display the values of some variable (namely, alpha, beta,
> gamma, delta) on a plot, and making a legend like
> "$ \alpha=%G, \ \bet=%G, \ \gamma=%G, \ \delta=%G $" % values is not
> very readable.
> Is there away to make multiline mathtext ?
>
>
> thanks
>
> BL
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Darren S. Dale, Ph.D.
Staff Scientist
Cornell High Energy Synchrotron Source
Cornell University
275 Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

darren.dale@...163...
office: (607) 255-3819
fax: (607) 255-9001
http://www.chess.cornell.edu