I wonder if it is possible to find an analogical solution for pdflatex instead of latex, see gnuplot in LaTeX, without gnuplottex.

Changing the gnuplot code to:

\begin{gnuplot}[terminal=cairolatex, terminaloptions= pdf input]
     set samp 100;
     set iso 40;
     set xrange [0:1];
     set yrange [0:1];
     set zrange [0.8:2];
     unset key;
     unset colorbox;
     set hidden3d front;
     a = 1;
     set xyplane at a;
     f(x,y) = (x+y)/(2*sqrt(x*y));
     set xlabel "$\\tau_I$";
     set ylabel "$\\tau_D$";
     set zlabel "$\\zeta$";
     set output "figures/cascade.tex"
     splot f(x,y) with pm3d at b, f(x,y) with lines;
     unset output

and compiling with pdflatex (-shell-escape is enable) not only the .pdf and .tex files from cairolatex in path figures but also in Tex path root (thesis.tex) thesis-gnuplottex-fig1.gnuplot and thesis-gnuplottex-fig1.tex (0 bytes) are produced. The .gnuplot file can be deleted by writing cleanup in gnuplottex options. Nonetheless, the thesis.pdf document contents the plot, as desired. If it is possible to define a similar "custom dependency" for pdflatex? May be in the command line of pdflatex?

Thank you for your help in advance.


I have found a workaround to solve this problem with my basic latex skills taking into account a similar solution for Inkscape, see sub-subsection 3.3.2. LATEX code in page 3 of How to include an SVG image in LATEX by Johan B. C. Engelen in 2013.

Files structure:

        |-- main.tex
        |-- macros/
                     |-- newcommands.tex
        |-- content/
                     |-- chapter.tex
        |-- images/
                     |-- gnuplot/
                                 |-- cascade.plt
                     |-- figures/ 
                                 |-- cascade.tex
                                 |-- cascade.pdf       

Follow these steps (Windows 7, Gnuplot, Miktex,TexStudio, and Pdflatex):

  1. Add -shell-escape or -enable-write18 to the command line when calling pdflatex: pdflatex.exe -enable-write18 -synctex=1 -interaction=nonstopmode %.tex
  2. Add the gnuplot.exe windows path directory to the additional search paths in commands ($Path). For example, in my case: C:\Program Files (x86)\gnuplot\bin
  3. Following packages are required: import (Establish input relative to a directory) and filemod (Pro­vide file mod­i­fi­ca­tion times, and com­pare them). You have to add them in your preamble: \usepackage{import, filemod-expmin}
  4. The /main/images/gnuplot/cascade.plt file contains:

      cd 'images\figures'
      set terminal cairolatex pdf input
      set output 'cascade.tex'
      set dummy u, v
      set parametric
      set isosamples 21, 21
      set hidden3d back offset 1 trianglepattern 3 undefined 1 altdiagonal bentover
      set style data lines
      set title "Real part of complex square root function" 
      set urange [ -3.00000 : 3.00000 ] noreverse nowriteback
      set vrange [ -3.00000 : 3.00000 ] noreverse nowriteback
      splot u**2-v**2,2*u*v,u notitle
      unset output
  5. Add the following code to the preamble of your document (for example, in my case: /main/macros/newcommands.tex):

                  \executeiffilenewer{images/gnuplot/#1.plt}{images/figures/#1.tex}{\immediate\write18{gnuplot images/gnuplot/#1.plt}}}{%
                  \immediate\write18{gnuplot images//gnuplot//#1.plt}}%
           {\errmessage{LaTeX Error: 'images/gnuplot/#1.plt' not found, input line \the\inputlineno}}%
  6. When an image is included via \includegnu, it is automatically exported to Pdflatex again by Gnuplot when the .plt file has changed (note that the image must be specified without file extension):

                 \caption[My caption]{The caption}

Are there any other possibilities to improve these codes? May be the newcommands?

Or other possible solutions?

Thank you in advance

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.