Graphics, Figures & TablesHow can I use pstricks with TeXShop?

Information and discussion about graphics, figures & tables in LaTeX documents.
AndyD
Posts: 12
Joined: Sun Nov 15, 2009 3:35 pm

How can I use pstricks with TeXShop?

Post by AndyD »

I am new to LaTeX and have been using it for a couple of months now for my OU Maths course. I have been using the TeXShop distribution qute happily, and have just upgraded to the 2009 release (V2.26), running under OS X 10.6.1 on my shiny new MacBook Pro :P

I am now getting to the stage where I would like to do some more advanced graphics and have bought myself the LaTeX Graphics Companion book, which gives loads of great looking examples. Unfortunately, none of them seem to work for me :cry:, which I'm assuming is down to my lack of integration between TeXShop and pstricks.

I think pstricks is bundled with the TeXShop distribution (mainly an act of faith, I admit, but the distro is pretty huge). I did manually download pst-pdf and managed to run the tests on this quite successfully from the command line, which ought to confirm that pstricks is installed somewhere at least.

TeXShop has loads of configuration options, but I honestly don't know which ones I need to tweak. I did try changing some settings, but only managed to screw up my environment, so that none of my old docs would process correctly.

I've tried the obvious path of searching google and this site, but with no success. Can anybody give me an idiot's guide for integrating the two tools?

Thanks,

AndyD

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: How can I use pstricks with TeXShop?

Post by josephwright »

This is not to do with TeXshop, but the LaTeX to PDF route you use. To use pstricks, you need to do LaTeX -> DVIPS -> PS2PDF. The method set up by TeXshop "out of the box" is pdfLaTeX, which generates a PDF directly but cannot be used with pstricks. I forget the menu you need, but one of the menus in TeXshop sets this.
Joseph Wright
AndyD
Posts: 12
Joined: Sun Nov 15, 2009 3:35 pm

Re: How can I use pstricks with TeXShop?

Post by AndyD »

A kind of success, but it feels horribly klunky:

1) I first downloaded the pst-pdf package, which comes with a shell script 'ps4pdf' that replaces LaTeX, but with pstricks support.
2) Put this in /usr/local/bin, so that it gets found on the path.
3) Modified the TeXShop preferences on the Engine tab, setting the LaTeX value to 'ps4pdf' in place of its previous value (which was 'pdflatex --shell-escape --synctex=1').

Result = success, although this feels really klunky to me, as I said at the beginning.

If somebody can suggest a cleaner way of solving this problem I'd really appreciate it, ideally one that avoid the need for a mediating script to cover up the gaps :oops:
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: How can I use pstricks with TeXShop?

Post by josephwright »

There's a menu item in TeXshop (I grabbed the latest release to check this): on the Typeset menu, select "TeX and DVI" rather than "pdfTeX". That should be all you need to do: TeXshop will go via DVI mode, which will work with PStricks.
Joseph Wright
AndyD
Posts: 12
Joined: Sun Nov 15, 2009 3:35 pm

How can I use pstricks with TeXShop?

Post by AndyD »

Sadly, this fix didn't work for me. I restored my setting to their original value and applied your change, with the following result on a trivial pstricks input file, that processed fine with the previous settings.

This is a real shame, since your config change was the just sort of thing I was looking for. I'm sure it's the right approach, but I just wish I knew what the solution was.

If you can spot the error in my test then I'd be happy to hear it!

AD

Code: Select all

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
 \write18 enabled.
entering extended mode
(./example1.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, ku
rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, po
lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, span
ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded.
(/usr/local/texlive/2009/texmf-dist/tex/latex/amscls/amsart.cls
Document Class: amsart 2009/07/02 v2.20.1
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2009/texmf-dist/tex/latex/amsfonts/amssymb.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/pstricks/pstricks.sty
(/usr/local/texlive/2009/texmf-dist/tex/generic/pstricks/pstricks.tex
`PSTricks' v1.29  <2009/05/19> (tvz)
(/usr/local/texlive/2009/texmf-dist/tex/generic/pstricks/pstricks.con))
(/usr/local/texlive/2009/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/local/texlive/2009/texmf-dist/tex/latex/pdftex-def/pdftex.def)))
(/usr/local/texlive/2009/texmf-dist/tex/latex/datetime/datetime.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fmtcount.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-english.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-UKenglish.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-british.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-USenglish.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-spanish.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-portuges.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-french.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-german.def)
(/usr/local/texlive/2009/texmf-dist/tex/latex/fmtcount/fc-italian.def)
No configuration file fmtcount.cfg found.
)) (/usr/local/texlive/2009/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty)
(./example1.aux) (/usr/local/texlive/2009/texmf-dist/tex/latex/amsfonts/umsa.fd
) (/usr/local/texlive/2009/texmf-dist/tex/latex/amsfonts/umsb.fd)
(/usr/local/texlive/2009/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
! Undefined control sequence.
<recently read> \c@lor@to@ps 
                             
l.14 \begin{pspicture}(4,5) \psframe(0.7,2)(3.3,3)
                                                  
? 
! Undefined control sequence.
\XC@usec@lor ...string \color@ #1#2\endcsname \@@ 
                                                  \fi \space 
l.14 \begin{pspicture}(4,5) \psframe(0.7,2)(3.3,3)
                                                  
? 
Process aborted
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How can I use pstricks with TeXShop?

Post by localghost »

The log you attached indicates that you compiled with the pdflatex compiler engine. This can't work. You have to use latex to compile to DVI and further convert to PS and PDF.

As you already mentioned, you can use the (auto-)pst-pdf package for use of pstricks with the pdflatex compiler engine. Note that you need to have shell escape enabled (forum search).


Best regards
Thorsten
AndyD
Posts: 12
Joined: Sun Nov 15, 2009 3:35 pm

How can I use pstricks with TeXShop?

Post by AndyD »

You must think me very dense, for which I can only apologise. I really am a LaTeX newbie and a lot of this is a mystery to me.

I have now modified my 'LaTeX' setting on the Typesetting panel to 'latex --shell-escape --synctex=1', which seems to be what you are recommending, along with setting the Default Script on the typesetting panel to 'Tex + DVI', as joseph suggested - but the end result = failure :(

Based on the previous posts, I feel that I'm within a hair's breadth of getting this working - it's just so frustrating :oops:
larry2001
Posts: 1
Joined: Thu Nov 19, 2009 12:32 pm

Re: How can I use pstricks with TeXShop?

Post by larry2001 »

I installed TeXShop and tried to process a tex file containing pstricks commands. It didn't work. I then selected the menu Composition > TeX and DVI. It worked beautifully. The default is Composition > Pdftex. In order to set the default to "TeX and DVI" so that you wouldn't have to select it each time, go to the menu

TeXShop > Preferences > Composition

and select as default script "Tex + DVI" instead of "Pdftex".

You probably changed setting that you shouldn't have. One solution is to reinstall the TeXShop package.
AndyD
Posts: 12
Joined: Sun Nov 15, 2009 3:35 pm

How can I use pstricks with TeXShop?

Post by AndyD »

Thanks for the input - although this sounds very close to what joseph suggested earlier, which didn't work for me.

Since the two of you are now suggesting this solution I'll give it another try - although this time I'll completely remove my current TeXShop installation, just in case there is any 'badness' lurking around that persists between installs.

I'll let you know how I get on - and thanks again for your input.
AndyD
Posts: 12
Joined: Sun Nov 15, 2009 3:35 pm

Re: How can I use pstricks with TeXShop?

Post by AndyD »

OK, it still failed, despite my best efforts to completely remove all previous traces of TeXShop - deleting the app from /Applications, deleting the TeX folder from /Library and deleting the TeXShop folder from ~/Library. Curiously, despite all this, it still retained my list of previously accessed files - I'm guessing this info is stored at the OS level, rather than the app level.

However, the bottom line is that it still failed for me, even though it's worked for at least two other people - what gives?? :(
Post Reply