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.tex
contains 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?
Best Answer
I have avoided using
gnuplottex
at all by adding the following custom dependency to.latexmkrc
:My
gnuplot
file uses thecairolatex
terminal (or any other terminal who produce a.tex
file). Mylatex
document contains\input{gnuplot_output.tex}
which, because of the newly defined dependency, causes a system call tognuplot
upontex
compilation. The.gnu
file and.tex
files are now a normal dependency, andgnuplot
will not recompile unless the time stamp is changed.It's important to notice that the path specified in
set output "path/gnuplot_output.tex"
in the.gnu
file is relative to thetex root
file as long as thegnuplot
system call is induced bylatexmk
.