make your LaTeX document your “makefile”

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

% \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
  gnuplot "#1.plot"}%

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


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

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
   % you have to use the full relative path here anyway

There you go. Any questions left?


Peter Pan. Kann fliegen mit Feenstaub.

Tagged with: , , ,
Posted in LaTeX, Technik
3 comments on “make your LaTeX document your “makefile”
  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…

  2. Adoa says:

    Why should I want to have my makefile in LaTeX syntax? Almost every other synax is more readable than LaTeX. I can use the epslatex terminal, anyway. I would rather make my editor call ‘make’ instead of ‘pdflatex’. The almighty vim can do that with the vim latex-suite. And yes, vim should be available on Windows, too.

  3. laclaro says:

    You’re right. LaTeX syntax is terrible… It’s just that I like the idea of having only one file to worry about. And the upper definition I have in my header anyway. It’s just adding the updateplot-command.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Posts by topic…
…by month
Have a look at…

%d bloggers like this: