[Tex/LaTex] Enabling “–shell-escape” on TeXworks under MiKTeX


After resolving the problem on my previous question, I applied to finally install Gnuplot 4.6; and after a successful installation I had to allow the --shell-escape option on TeXworks, so I added a new Typesetting Tool on the Preferences menu, called pdfLaTeX+ShellEscape.

The lines of code inserted into the tool configuration are listed below:


The problem is that when I try to compile my MWE (MYname.tex) with the above specified option:

\begin{axis}[no markers,samples=30]
\addplot gnuplot{atanh(x)};

I get this messge:

! Package pgfplots Error: Sorry, the gnuplot-result file 'MYname.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 <file>.gnuplot' manually on the respective gnuplot file..

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.

l.7     \addplot gnuplot{atanh(x)};

I am running TeXworks 0.44, and until now it didn't show this kind of stubbornness because I compiled every document without problems.

I did also some research and I found that I could write -enable-write18 but even after this try I get the same errmsg and so I'm stuck again with the plots problem (although I discovered a powerful program like Gnuplot I don't know how to set LaTeX properly).

P.S. : Sorry for the deleted question with the same title, that issue was created by a simple human error.

Best Answer

Since we were able to establish that the compilation generated a .pgf-plot.gnuplot file, the problem was that this file was not compiled in gnuplot.

We now have a few options:

  1. run gnuplot on the .pgf-plot.gnuplot file to create a .table or .tex file and then compile again.
  2. we can modify the calling of --shell-escape for TeXworks to --tex-option=--shell-escape and then compile again without running gnuplot this time.
  3. another option posed by texenthusiast is to use a program such as Latexmk to compile multiple times; however, I still believe we would need options two's modification of --shell-escape which was discussed on TUG's message board here https://www.tug.org/pipermail/texworks/2011q2/004166.html
Related Question