With that executeiffilenewer-command I presented in one of my previous posts, you can use your LaTeX-compiler to keep track of all the additional files which are required to build you project. If you use gnuplot to create some plots which are included in you document, why not update them automatically on compiling?

Place the follwing in you Header.tex-file

\newcommand{\executeiffilenewer}[3]{%
\ifnum\pdfstrcmp{\pdffilemoddate{#1}}%
{\pdffilemoddate{#2}}>0%
{\immediate\write18{#3}}\fi%
}
% \updateplot{filename-without-ext} command to process plotfile with
% gnuplot if changed. Changes are recognized by an indicator file
% created by gnuplot (e.g. the plot ;)), which has apart from it's
% extension the same name as the plotfile.
% Here the plotfile's extention is .plot, the plot's extension is .tex
\newcommand{\updateplot}[1]{%
gnuplot "#1.plot"}%
}


and in use it in your main document (before \begin{document})

\AtBeginDocument{
\updateplot{./Data/gnuplot-plotfile-without-extension}
}


A typical plotfile looks like this. The big pro: you can directly use latex-commands

reset
cd './Data'
set size 0.8,1
set datafile separator ','
set decimalsign ','

set terminal epslatex color solid
set output 'plot.tex'

plot './datafile.dat' u 1:3 w l ti '$T_{\phi}$ in \celsius',\
'./datafile.dat' u ($1+273):3 w l ti '$T_{\phi}\$ in K'

set term wxt; replot # preview
!epstopdf plot.eps   # get a plot.pdf


Get it into you document (copied to “Plots”)

\graphicspath{{Plots/}{Images/}{Graphics/}} % additional search paths
...
\begin{figure}[htb]%
% you have to use the full relative path here anyway
\input{Plots/plot.tex}%
\end{figure}


There you go. Any questions left?

Peter Pan. Kann fliegen mit Feenstaub.

Tagged with: , , ,
Posted in LaTeX, Technik
1. laclaro says:

filename variables in gnuplot…

I was trying to teach my bloody windows workspace to update the plotfile not only in the data-directory where Data and plotfiles are located, but also leave one version in my latex-document directory. I learned, that you can even use variables for file…