Ticket #11315: trac_11315-remove_pstricks_from_preamble.patch

File trac_11315-remove_pstricks_from_preamble.patch, 3.4 KB (added by saliola, 2 years ago)
  • sage/misc/latex.py

    # HG changeset patch
    # User Franco Saliola <saliola@gmail.com>
    # Date 1304874234 14400
    # Node ID cacdbf288bd0d6e237912613e19c04ac3517f4fc
    # Parent  f8bdf65336cfdc59771dca5141e5b96d72c1d57b
    trac 11315: remove pstricks from default latex preamble
    
    diff --git a/sage/misc/latex.py b/sage/misc/latex.py
    a b special method ``_latex_(self)`` that re 
    2525 
    2626EMBEDDED_MODE = False 
    2727 
    28 COMMON_HEADER='\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\\usepackage{graphicx}\\usepackage{pstricks}\\pagestyle{empty}\n\\usepackage[utf8]{inputenc}\\usepackage[T1]{fontenc}\n' 
    29  
    30 LATEX_HEADER='\\documentclass{article}' + COMMON_HEADER + '\\oddsidemargin 0.0in\n\\evensidemargin 0.0in\n\\textwidth 6.45in\n\\topmargin 0.0in\n\\headheight 0.0in\n\\headsep 0.0in\n\\textheight 9.0in\n' 
    31  
    32 SLIDE_HEADER='\\documentclass[a0,8pt]{beamer}' + COMMON_HEADER + '\\textwidth=1.1\\textwidth\\textheight=2\\textheight\n' 
    33  
    34 #SLIDE_HEADER='\\documentclass[landscape]{slides}\\usepackage{fullpage}\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\\usepackage{graphicx}\usepackage{pstricks}\pagestyle{empty}\n' 
     28COMMON_HEADER='\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{amsfonts}\n\\usepackage{graphicx}\n\\pagestyle{empty}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n' 
     29 
     30LATEX_HEADER='\\documentclass{article}\n' + COMMON_HEADER + '\\oddsidemargin 0.0in\n\\evensidemargin 0.0in\n\\textwidth 6.45in\n\\topmargin 0.0in\n\\headheight 0.0in\n\\headsep 0.0in\n\\textheight 9.0in\n' 
     31 
     32SLIDE_HEADER='\\documentclass[a0,8pt]{beamer}\n' + COMMON_HEADER + '\\textwidth=1.1\\textwidth\n\\textheight=2\\textheight\n' 
    3533 
    3634import shutil, re 
    3735import os.path 
    def view(objects, title='SAGE', debug=Fa 
    18221820        sage: view(3, mode='display') 
    18231821        <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</div></html> 
    18241822        sage: sage.misc.latex.EMBEDDED_MODE = False 
     1823 
     1824    TESTS:: 
     1825 
     1826        sage: from sage.misc.latex import _run_latex_, _latex_file_ 
     1827        sage: g = sage.misc.latex.latex_examples.graph() 
     1828        sage: latex.add_to_preamble(r"\usepackage{tkz-graph}") 
     1829        sage: file = os.path.join(SAGE_TMP, "temp.tex") 
     1830        sage: O = open(file, 'w'); O.write(_latex_file_(g)); O.close() 
     1831        sage: _run_latex_(file, engine="pdflatex") # optional - latex 
     1832        'pdf' 
     1833 
    18251834    """ 
    18261835    if isinstance(objects, LatexExpr): 
    18271836        s = str(objects) 
    and try again from the notebook -- you s 
    24222431            """ 
    24232432            return """LaTeX example for testing display of pstricks output. 
    24242433 
    2425 To use, view this object.  It should work okay from the command 
    2426 line but not from the notebook.  In the notebook, run 
    2427 'latex.add_to_jsmath_avoid_list("pspicture")' and try again -- you 
    2428 should get a picture (of forces acting on a mass on a pendulum).""" 
     2434To use, first try calling 'view' on this object -- you 
     2435should get gibberish.  Now, make sure that you have the most 
     2436recent version of the TeX package pstricks installed. Run 
     2437'latex.add_to_preamble("\\usepackage{pstricks}")' and try 
     2438viewing it again. From the command line, this should pop 
     2439open a nice window with a picture of forces acting on a mass 
     2440on a pendulum. In the notebook, you should get an error. 
     2441Finally, run 
     2442'latex.add_to_jsmath_avoid_list("pspicture")' and try again 
     2443-- you should get a nice picture.""" 
    24292444 
    24302445        def _latex_(self): 
    24312446            """