Darren Dale wrote:
> On Fri, Dec 12, 2008 at 1:06 PM, Michael Droettboom <md...@stsci.edu 
> <mailto:md...@stsci.edu>> wrote:
>
>     Darren Dale wrote:
>
>         On Fri, Dec 12, 2008 at 9:46 AM, Michael Droettboom
>         <md...@stsci.edu <mailto:md...@stsci.edu>
>         <mailto:md...@stsci.edu <mailto:md...@stsci.edu>>> wrote:
>
>            Manuel Metz wrote:
>            > Michael Droettboom wrote:
>            >
>            >> There was a discussion on this list around a year ago about
>            this.  The
>            >> concern was that not rendering $ as $ would break
>         (matplotlib)
>            backward
>            >> compatibility with scripts that don't care about math at all
>            but use a
>            >> lot of dollar signs (e.g. financial plots).  This is one
>         of the few
>            >> places where we deliberately broke usetex compatibility in
>            favour of
>            >> matplotlib compatibility.
>            >>
>            >> That said, it's probably a bug that the escaped dollar
>         sign in
>            non-math
>            >> context is not rendered as a dollar sign.
>            >>
>            >> As a workaround "$\$%1.2f$" works with usetex on or off,
>         with the
>            >> proviso that it uses math- rather than text-rendering
>         for the
>            numbers.
>            >>
>            >> Mike
>            >>
>            >
>            > In that case I suggest to note this somewhere in the docs
>         (and User
>            > Guide) with three exclamation marks (or is it ???).
>            >
>            So there's really two sub-bugs here:
>
>            1) '\$8' gives '\$8' in mathtext (well, actually it gets
>         sent verbatim
>            to the non-math text renderer, which is a bug).  This,
>         IMHO, is a
>            "must-fix".
>
>            2) '$8' gives '$8' in mathtext and an error in usetex.
>          This could be
>            solved in two ways:
>
>            a) document the difference
>            b) make '$8' give '$8' in usetex as well
>
>            I realise b) is technically making usetex accept a string
>         that is not
>            normally valid TeX -- but it's not like a user would ever enter
>            '$8' and
>            *want* to get a TeX error back.  And usetex strings aren't
>            perfectly TeX
>            anyway.
>
>            Personally, I'm leaning toward b), because it requires less
>         mental
>            effort for the user turning usetex on/off.  And it doesn't
>         force us to
>            backtrack on the idea of supporting "$100.00" easily.
>
>            But before I commit -- any feedback?
>
>          I opposed to b). If we go that route, we can look forward to
>         advertising usetex as "a latex backend, with familiar,
>         standard latex markup, except when it isnt."
>
>     It's not as bad as that.  '\$8' will still work as in LaTeX as it
>     always has and as a LaTeX expert would expect it to.  All I'm
>     proposing is that '$8', which is currently a LaTeX syntax error,
>     will behave as it does when usetex is turned off.  So it's not
>     breaking anything that's already valid.
>
>     It's a question of which pain is worse, I guess.
>
>     The deeper question is -- should usetex even strive to have any
>     compatibility with standard text?  If not, then I can see your point.
>
>
> http://matplotlib.sourceforge.net/users/mathtext.html advertises \$ as 
> markup for $.
That's always worked and still worked -- that's not the bug at hand. 
> I think it was unwise to accept $ for $ in mathtext in the first 
> place, since mathtext uses tex markup anyway.
I'm not proposing that at all.  I think we're running into a 
misunderstanding about what I mean by "mathtext" and the scope of the 
proposed change.  By mathtext, I mean "the text between a pair of $ $ 
when usetex is off".  mathtext aims to be TeX-compatible (for a 
subset).  Regular text does not (and in fact has no markup whatsoever).  
That last point, I believe, is the root of this problem and why 
reconciling usetex with non-usetex may be a losing battle, as you're 
starting to convince me.  usetex is simply not the same thing as regular 
matplotlib text.

I'll clarify anyway -- but I'm starting to think that unless there is 
someone doing financial plots with usetex that is dying for this 
feature, I'll just leave it.

The bug at hand deals with regular text, not math text.  There has been 
a test in the non-usetex code path for a long time to determine if there 
is any math in the string (by looking for an even number of non-escaped 
$) and allow the simple monetary case to work without needing to escape 
the $.  It used to be impossible to interleave math and regular text in 
the same string and I needed a way to add support for interleaving 
without breaking existing usage, and without requiring an explicit flag 
saying "my string has math".  It's not perfect -- if you want to have 
math *and* use a dollar sign, you still have to know what you're doing 
and do some sort of escaping.  But it's served well for over a year.

The question, then, is whether to bring those smarts over to usetex, and 
whether any sort of usetex/non-usetex consistency is a goal.
>
> If we went with b), how sure are you that you can identify when a 
> dollar sign is intended and when mathmode is intended? Does 
> "$A-$100+B*$200$" mean $(A-100+200B) or A-100+200 or ..., I know this 
> is an unlikely example, I'm just trying to think of the unintended 
> consequences of circumventing one of the least buggy pieces of 
> software in existence (I mean tex, not latex).
>
It means [A-]100+B*[200] (where the contents in brackets is math, 
otherwise text), just like in TeX.  An example where there is ambiguity 
is when you have an odd number, such as "$A-$100+B$". In TeX, that's a 
syntax error, but with my proposed change (and in non-usetex already) it 
would render as "$A-$100+B$".  So at best, it's a "does the right 
thing", and at worst is a "silent fail", depending on your perspective.

Hope that clears things up.

Mike

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


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to