#6089: [with patch, needs review] view command: don't always use jsMath
-------------------------+--------------------------------------------------
 Reporter:  jhpalmieri   |       Owner:  jhpalmieri
     Type:  enhancement  |      Status:  new       
 Priority:  minor        |   Milestone:  sage-4.0  
Component:  misc         |    Keywords:            
-------------------------+--------------------------------------------------
 The attached patch provides a way to not always use jsMath when rendering
 LaTeX for the 'view' command in the notebook.  It works by looking for
 certain strings in the latex code for the object, and if it finds them, it
 creates and displays a png file, bypassing jsMath altogether.  The
 "certain strings" are stored in a list which is initially empty, but can
 be populated by using
 {{{
 latex.jsmath_avoid_list(...)
 }}}
 or
 {{{
 latex.add_to_jsmath_avoid_list(...)
 }}}
 To test it out, for example: in a notebook cell, try
 {{{
 class bozo(SageObject):
     def __init__(self):
         pass
     def _latex_(self):
         return r"""\begin{pspicture}(0,-4)(14,0)
   \psline{-}(0,0)(0,-4)
   \psline[linewidth=2pt]{-}(0,0)(1,-3)
   \qdisk(1,-3){3pt}
   \psarc{-}(0,0){0.6}{270}{292}
   \psline{->}(1,-3.3)(1,-4)
   \psline{->}(1.1,-2.7)(0.85,-1.95)
   \psline{-}(5,0)(5,-4)
   \psline[linewidth=2pt]{-}(5,0)(6,-3)
   \qdisk(6,-3){3pt}
   \psarc{-}(5,0){0.6}{270}{292}
   \psarc{-}(5,0){3.2}{270}{290}
 \end{pspicture}"""
 }}}
 Then the latex string for instances of this class contains commands that
 jsMath can't handle, and indeed, {{{view(bozo())}}} ought to produce a
 typical jsMath error: a little box saying {{{Unknown environment
 "pspicture"}}}.  Then do
 {{{
 latex.add_to_jsmath_avoid_list("pspicture")
 }}}
 and try viewing again; it ought to pop up a pstricks picture.  It's a
 little slow, but I think we may have to live with that.

 To the graph theorists: You ought to be able to do the same thing with
 graphs, as long as {{{'\\usepackage{tkz-graph}'}}} has been added to the
 latex preamble.  If you're doing that automatically, then you could also
 add an entry to {{{jsmath_avoid_list}}}...

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6089>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to