Opened 11 years ago

Closed 11 years ago

#11315 closed defect (fixed)

remove pstricks from default latex preamble

Reported by: saliola Owned by: jason, was
Priority: major Milestone: sage-4.7.1
Component: graphics Keywords: latex, days30
Cc: jhpalmieri Merged in: sage-4.7.1.alpha1
Authors: Franco Saliola Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


At Sage Days 30 we noticed some problems with trying to view a graph using pdflatex on Mac OS X. It seems to be related to having pstricks loaded as part of the default latex preamble:

   ! LaTeX Error: You have run the document with pdflatex, but PSTricks
                  requires latex->dvips->ps2pdf or alternatively the use
                  of the package `auto-pst-pdf'. Then you can run
                    `pdflatex -shell-escape <file>' (TeX Live)
                    `pdflatex -enable-write18 <file>' (MikTeX).

   See the LaTeX manual or LaTeX Companion for explanation.
   Type  H <return>  for immediate help.

   l.3 \begin{document}


If you have a Mac, you can test this on the following minimal example. (I have the latest version of MacTeX installed.)

   \begin{center}{\Large\bf SAGE}\end{center}

This causes the following example to fail:

   sage: g = sage.misc.latex.latex_examples.graph()
   sage: latex.add_to_preamble(r"\usepackage{tkz-graph}")
   sage: view(g, pdflatex=True, tightpage=True)
   Latex error

But it works if we remove pstricks from LATEX_HEADER:

   sage: LATEX_HEADER = sage.misc.latex.LATEX_HEADER
   sage: sage.misc.latex.LATEX_HEADER = LATEX_HEADER.replace(r"\usepackage{pstricks}","")
   sage: view(g, pdflatex=True, tightpage=True)

So, we should remove pstricks from the default latex preamble.

Attachments (1)

trac_11315-remove_pstricks_from_preamble.patch (3.4 KB) - added by saliola 11 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 11 years ago by saliola

  • Status changed from new to needs_review

I modified the _repr_ method of the pstricks example to explain that one needs to add the pstricks package to the preamble. This is consistent with how things are done in the other sage.misc.latex.latex_examples.

I also fixed things so that there is a line break following every usepackage in the preamble:

sage: print sage.misc.latex.COMMON_HEADER

sage: print sage.misc.latex.LATEX_HEADER
\oddsidemargin 0.0in
\evensidemargin 0.0in
\textwidth 6.45in
\topmargin 0.0in
\headheight 0.0in
\headsep 0.0in
\textheight 9.0in

sage: print sage.misc.latex.SLIDE_HEADER

comment:2 Changed 11 years ago by saliola

  • Keywords days30 added

comment:3 Changed 11 years ago by rbeezer

Thanks, Franco. This patch looks good to me, in principle. But I'm traveling and am not really in a position to fully test, so will not be able to do a review for a while.


comment:4 Changed 11 years ago by jhpalmieri

  • Reviewers set to John Palmieri
  • Status changed from needs_review to positive_review

Looks good to me, fixes the problem, and passes all tests. I still think we should get rid of "
usepackage{graphicx}" as well, but that can happen another time.

comment:5 Changed 11 years ago by jdemeyer

  • Merged in set to sage-4.7.1.alpha1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.