I'm using the cairolatex terminal in gnuplot to create some surface plots (pgfplots is failing the task because of its hunger for memory). As the number of plots increase, I would like to include the gnuplot compilation into my tex compilation to ensure the plots are up-to-date. I came across the gnuplottex package, which seems to handle the task, though it's slow.
I have a large, nested document. Tex root is thesis.tex where I include, amongst others, theory.tex. In theory.tex I have put
\begin{figure}[htbp]
\centering
\input{gnuplot/cascade}
\input{figures/cascade}
\end{figure}
where gnuplot/cascade.texcontains the gnuplot code
\begin{gnuplot}[terminal=cairolatex]
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
\end{gnuplot}
The output of this setup is awesome. But whenever I change something in theory.tex, the entire gnuplottex routine recompiles. This takes quite some time, and is very annoying.
How come latexmk doesn't recognise that the gnuplot code hasn't changed and leave it? Could this dependency be specified, and in that case, how?
EDIT: gnuplottex is fairly slow on my system, although gnuplot is really quick. How can I avoid using gnuplottex, it's long compilation time and thus avoid having gnuplottex recompiling every time?
gnuplotcommand is being executed by thegnuplottexpackage,latexmkdoesn't control whethergnuplotis invoked. You can change things so thatlatexmkis in control ofgnuplotby turning off-shell-escapeand defining a custom dependency forlatexmkto invokegnuplot. Could you try this on your present document? (One would need a modification tognuplottexto make this solution fully general.) – John Collins Apr 03 '13 at 15:37latexmkwould control whether or notgnuplottexwould be invoked. But yeah, this could be a solution. I don't have the skills to make such a dependency though, could you please help me out? – Holene Apr 04 '13 at 06:47gnuplottexat all, and havelatexmkinvokegnuplotwhen needed. Something like this maybe (though is doesn't work, of course):add_cus_dep('gnu','eps', 0, 'makegnu2eps'); sub makegnu2eps { system("gnuplot \"$_[0].gnu\"") ; }– Holene Apr 04 '13 at 07:26gnuplotcode in a file with extension .gnu, e.g.,figure.gnu, and have a corresponding\includegraphics{figure}in your LaTeX file, then it should work. This assumes you are usinglatex, notpdflatex, to compile your LaTeX file, since you are generating an.epsfile. When you runlatexmk, there will be a missing-file error the first time it useslatex;latexmkshould detect that and usegnuplot. Then there should be a successful second use oflatex. – John Collins Apr 04 '13 at 13:50add_cus_dep('gnu','tex', 0, 'makegnu2tex'); sub makegnu2tex { system("gnuplot \"$_[0].gnu\"") ; }. Thegnuplotcode now outputsgnuplot/cascade.texand my LaTeX file requests\include{gnuplot/cascade.tex}. Thegnuplotcode is compiled (as fast as you would expectgnuplotto compile, way faster thangnuplottex), the.epsand.texfiles fromcairolatexis produced, and everything is fine! – Holene Apr 05 '13 at 11:45