mrpiggi / svg

Handling SVG pictures in LaTeX documents using Inkscape, ImageMagick and/or Ghostscript
Other
65 stars 11 forks source link

Maximum runs of pdflatex reached without getting stable files #12

Closed flaport closed 5 years ago

flaport commented 5 years ago

When running latexmk with xelatex, the pdf file of the svg keeps being regenerated every run. This causes latexmk to rerun xelatex about 5 times every time to finally halt with a

Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'svg-inkscape/test_svg-tex.pdf'
Latexmk: Maximum runs of pdflatex reached without getting stable files

or a

Latexmk: Failure in processing file 'test':
   'xelatex' needed too many passes

error (depending on the recipe used; see below). Although the pdf file is created, this is quite annoying, as compiling the file takes longer this way.

This should give a reproducible example (let's assume this file is called test.tex):

\documentclass{article}
\usepackage{graphicx}
\usepackage{svg}
\usepackage{svg-extract}
% same problem when explicitly setting convert and extract to true:
%\usepackage[convert=true,extract=true]{svg-extract}
\begin{document}
\includesvg{test.svg}
\section{Introduction}
\end{document}

run either with

latexmk -pdf -pdflatex="xelatex %O %S" -synctex=1 -interaction=nonstopmode -shell-escape test

or

latexmk -pdf -xelatex -synctex=1 -interaction=nonstopmode -shell-escape test

To reproduce the problem. Is this a bug? or are there any settings I don't know about? Note that the problem does not exists when running latexmk with the normal pdflatex.

garyng commented 5 years ago

What I did for this is to configure latexmk to ignore changes for pdf files by adding this into .latexmkrc

$hash_calc_ignore_pattern{'pdf'}='^';

(https://tex.stackexchange.com/questions/347980/how-to-make-latexmk-ignore-certain-input-files-as-dependencies/348361#348361)

flaport commented 5 years ago

Thanks, that did the trick!

However, I still think this is an issue worth solving in this package as well. If I understand it correctly, latexmk will look at the hash of each file to see if any of them have been modified and if that is the case it will rerun the build process. This means (i think) that the svg package rebuilds the pdf every run, even if the svg has not changed and the pdf was already generated. In my opinion, this should be prevented.

garyng commented 5 years ago

Yeah, I agree it was kinda hack-y.

The idea of checking the hash is also mentioned in https://github.com/mrpiggi/svg/issues/11 though. My bad, misread the reply.

flaport commented 5 years ago

Yes, I do.

OK this explains it. Too bad there's no built-in workaround... anyway, the workaround above seems to work fine, so I'll stick with that for now.

garyng commented 5 years ago

Yes, I do.

OK this explains it. Too bad there's no built-in workaround... anyway, the workaround above seems to work fine, so I'll stick with that for now.

(I fat-fingered and deleted the reply... Original reply is here for future reference)

Do you happen to use xelatex? From the package documentation:

Unfortunately a primitive like \pdffilemoddate is missing for XeTeX, so with this engine, the behaviour will be the same as inkscape=forced

Is this possibly the cause?

mrpiggi commented 5 years ago

XeTeX now provides \filemoddate which will be supported with svg version v2.03

garyng commented 5 years ago

~Seems like the new version is still regenerating pdfs... I updated to texlive 2019 (on Ubuntu 19.10), the svg package is up-to-date right?~

It's not. My bad! image