I reopen this post, which was started some time ago but didn't came with a solution. I don't really remember what was the exact problem with this (well, of course, gnuplot
didn't work correctly). So I write here my actual problem, which is the same as before.
Problem
I reinstalled the operating system (Mac OS X 10.8.2), installed MacTeX (the last one), installed MacPorts and gnuplot
through it (in an administrator account). In this account, the command port
works correctly from terminal (which let mi install gnuplot
), and also does gnuplot
app (from terminal). Then created a new (non-admin) account, and then neither port
nor gnuplot
worked. After little hacking (here it is more info), I solved it.
Now port
and gnuplot
work both from terminal in both accounts.
But here is the problem. I use TextMate to compile my documents, which compiles everything perfectly. But if I use some code which needs of gnuplot
it isn't able to call it. See at the bottom for some examples.
On the contrary, if I call the file from the terminal with pdflatex --shell-escape file.tex
then it compiles perfect.
Question
What happens? Is it a PATH problem? How can I solve it? (I don't really understand what is a PATH, therefore I can't try/imagine by myself)
Code and Logs
Example 1:
\documentclass{scrartcl}
\usepackage{gnuplottex}
\begin{document}
\begin{gnuplot}
plot sin(x)
\end{gnuplot}
\end{document}
Part of the .log file
\openout3 = `Ejercicio1-gnuplottex-fig1.gnuplot'. Opening gnuplot stream Ejercicio1-gnuplottex-fig1.gnuplot runsystem(gnuplot Ejercicio1-gnuplottex-fig1.gnuplot)...executed. Package gnuplottex Warning: Conversion of Ejercicio1-gnuplottex-fig1.gnuplot fa iled. Package gnuplottex Warning: Please convert Ejercicio1-gnuplottex-fig1.gnuplot m anually.
And from the terminal no error at all.
Example 2:
\documentclass{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot gnuplot {sin(x)};
\end{axis}
\end{tikzpicture}
\end{document}
The .log problems from TextMate:
Latex Error: ./Ejercicio1.tex:6 Package pgfplots Error: Sorry, the
gnuplot-result file 'Ejercicio1.pgf-plot.table' could not be found.
Maybe you need to enable the shell-escape feature? For pdflatex, this
is '>> pdflatex -shell-escape'. You can also invoke '>> gnuplot
.gnuplot' manually on the respective gnuplot file..! Package pgfplots Warning: You have an axis with empty range.
Replacing it with a default range and clearing all plots.
And no errors from terminal with pdflatex --shell-escape file.tex
.
Best Answer
This might be an issue with TextMate's
PATH
, which is not (necessarily) the same as thePATH
when you work from Terminal. You can check that TextMate is able to find gnuplot by opening a new file in TextMate, typing the linewhich gnuplot
, and running that line with Ctrl-R. If TextMate gives you an error message, then it can't find gnuplot; if it prints a directory name then it can.So assuming that TextMate can't find gnuplot, the easiest way to fix this is to go to TextMate's Preferences > Variables and edit the entry for PATH. You should change this so that the directory containing gnuplot is in the list, for example
might work for you. (It's important that you keep
$PATH
in this list too, otherwise TextMate won't be able to use many important commands.) Make sure the check box next to PATH is checked. Now if you open a new file and typewhich gnuplot
, Ctrl-R, it should give you something, and if you typewhich pdflatex
, Ctrl-R, it should say/usr/texbin
.Finally, you need to make sure that TextMate runs pdflatex with the
shell-escape
option. TextMate allows you to pass options to the TeX compiler using comments at the beginning of your document. Try adding thisas the first line of your file. Both of the examples you provided compile without any problems on my machine if I include this as the first line. (TextMate 2.0-alpha.9387)