[Tex/LaTex] TeXShop not finding Gnuplot

external filesgnuplottexshop

I'm working in TeXShop on my mac and I love it.

There is one slight problem though. I use TikZ wich sometimes uses gnuplot to create it's plots. One would think that running TeXShop alone is enough (TeXShop should call gnuplot) but it isn't for me.

I have to run my file from the command line using:

latex -shell-escape myfile.tex

and only after I did this the plot's will appear in TeXShop. What happens is this:

  1. TeXShop can't find or call gnuplotso it doesn't create the necessary *.table files
  2. If I call latex from the command line, it automagically does find gnuplot and creates the correct *.table files
  3. When I run TeXShop again, the *.table files are already there and it just picks them up to work with.

I thought this was normal, until I discorvered it wasn't by using another package that also needs to call an external program (minted, which needs pygmentize and/or python). This package works normally from my TeXShop and this got me thinking: should calling gnuplot from TeXShop work just as well?

I'm guessing it has something to do with the location of my gnuplot, using which gnuploton the command line tells me it is in:

/opt/local/bin/gnuplot

It got installed there using the installtion guide here (actually, I installed all the macports, and gnuplot was one of them).

Readings in some other fora lead me to believe the symbolic link is broken.. Although I don't quite know what that means or how to fix it. TeXShop doesn't know where to find gnuplot.

What should I do to fix this?

PS: to avoid the obvious question: yes, --shell-escape is enabled in my TeXShop preferences.

Best Answer

You should either tell TeXShop to use /opt/local/bin/gnuplot instead of gnuplot, or add /opt/local/bin to the PATH that graphical applications see under Mac OS X. For the latter, you should have to edit (or create) the file ~/.MacOSX/environment.plist, see http://www.astro.washington.edu/users/rowen/AquaEnvVar.html.

The following should work in your case, but make sure you also add the directory where the tex binaries live

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PATH</key>
<string>/opt/local/bin:/bin:/usr/bin</string>
</dict>
</plist>

Don't forget to logout and login again for the changes to take effect.