Edit: I think I found the issue: GNUplot adds a to the second timestamp to the top of the *.tex file it generates, so of course latexmk thinks it has changed. %% 2021-01-18 11:32:42 AM

I usually use latexmk to compile my documents as that saves a lot of manual work figuring out how many times I need to compile it. However, if I use gnuplottex with it, every single run it says Changed files, or newly in use since previous run(s): 'loop-gnuplottex-fig1.tex'

Which...shouldn't be true? It might be being written every time, but it isn't changed. Is there a way around this, so that minor changes to my document don't trigger five runs of pdflatex, as that takes a very long time on my desktop, and an interminable one on my laptop.

Here is a MWE that triggers this issue. It is not as easy to compile as I would like as one needs to install Gnuplot for it to work, then copy three files from GNUplot's \share\texmf\tex directory structure to somewhere TeX can find them. (It appears at one point this was supposed to happen automatically if you installed LaTeX after GNUplot based on the config files in GNUplot).

Also, this MWE only works on Windows: You must unset the "miktex" option if compiling it on a Postix system.

%Note, you need GNUplot installed for this to compile, 
       %and need to copy three files from GNUplot to somewhere TeX can find them!
\usepackage[miktex]{gnuplottex} %MiKTeX means windows since they can't do basic testing, unset if on *nix

\begin{gnuplot}[terminal=tikz, terminaloptions=color]
plot sin(x)

I SUSPECT that this issue might be related to this question, but there is no worked examples, so I'm not exactly sure about how to set up my document to use what they are talking about, but it sounds like it bypasses this package entirely and speeds compilation a lot.

  • AFAIK there's no nice way to fix this unfortunately. Gnuplottex writes the gnuplot files and generates the corresponding graphs on each run as it doesn't keep track of what's changed. You could try to define the dependencies for latexmk manually, omitting those files, but then if they change latexmk might not recompile correctly. Jan 18, 2021 at 20:16

2 Answers 2


With Ulrike Fischer's suggestion to look at the *.tex file output, I found the problem.

The tex file contains a date/time stamp down to the second, as such:

%% generated with GNUPLOT 5.4p1 (Lua 5.3; terminal rev. Jun 2020, script rev. 114)
%% 2021-01-18 11:32:42 AM 

Which means that in practical terms, after every output the file will be different and latexmk will think it needs to recompile it.

Knowing this, I found that the file that generates the *.tex file is gnuplot-tikz.lua and looking through it I found the following:

  -- for regression tests etc. we can turn off the timestamp
  notimestamp = false,

There does not appear to be a way to set this from the text file or inside the GNUplot script, though I could easily have missed something. Editing gnuplot-tikz.lua and setting this to true fixes the problem, but is far from an ideal solution.

I've written this as an answer, as it works and does fix the problem, but if someone else writes up a better answer, I would appreciate it.

  • I am also going to email this to the person mentioned in the README file and see if this can be made accessible or default.
    – Canageek
    Jan 18, 2021 at 20:50

Another way of handling this is to configure latexmk to ignore the problematic lines when it determines whether or not the tex file has changed. The method is in the entry for %hash_calc_ignore_pattern in the latexmk documentation. What should work is to put the following in a latexmkrc file

$hash_calc_ignore_pattern{'tex'} = '^%%';

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .