I'm compiling my .tex file using latexmk, because it's the easiest way to have my code compiled multiple times until the final document is stable.

The issue is that such code needs to be executed several times - actually, a random amount of times - because it uses several images that tend to appear in the wrong position unless the code gets executed again and again and again until the following warning goes away from the log:

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

The point is that after several times that the code gets compiled I receive this message in the terminal:

Latexmk: Did not finish processing file 'generatore dossier.tex': 'pdflatex' needed too many passes

Is there a way to change the maximum amount of runs that latexmk does before calling it quits?

  • 1
    Yes, there is a command-line parameter to do that - but I can't remember what it is, and I don't feel like reading the documentation when you can do that yourself! – alephzero Apr 9 '17 at 17:09
  • there are some situations where the changing of labels is pathological. this might be helpful in understanding that situation: tex.stackexchange.com/a/105612/579 – barbara beeton Apr 9 '17 at 17:29
  • You will probably save time by including some more specific "hints" about where to position things in the document - for example specify "top of next page" to a figure which keeps moving around, or add an explicit \linebreak or \pagebreak to keep footnotes from flipping between one page and the next. – alephzero Apr 9 '17 at 22:05
  • That issue can be discussed here tex.stackexchange.com/questions/359772/… – il mietitore Apr 11 '17 at 11:23

You can change the $max_repeat variable with a command line option or in a configuration file.

latexmk -e "$max_repeat=2" test

But the default value (5) is quite large, so you should at first try to find out why your document needs more.

  • this is strange btw because even if I change the initialization document OR I use that command I end up receiving this message after 2 runs: Latexmk: Maximum runs of pdflatex reached without getting stable files Latexmk: All targets (generatore dossier.pdf) are up-to-date Latexmk: Did not finish processing file 'generatore dossier.tex': 'pdflatex' needed too many passes – il mietitore Apr 11 '17 at 13:43
  • My example set the number of run to 2 and this is a rather small value. If you want a larger value use e.g. 10. – Ulrike Fischer Apr 11 '17 at 13:51
  • That's what I did in fact – il mietitore Apr 11 '17 at 13:52
  • Is there a way to pass this as a !TEX parameter = in eg. TeXShop? – Florian Sep 24 '18 at 9:55
  • @UlrikeFischer while 5 is fine for many use cases there are definitely legitimate cases where it is way larger, e.g. when latexmk is used to generate PDF versions of images from *.svg in conjunction with make it requires one pdflatex run per generated image (because make gets aware of the required *.pdf only after pdflatex encounters the respective failing \includegraphics command and writes it out as dependency. I'll probably post a question about it in the future but not time yet for a MWE. :) – stefanct Dec 13 '18 at 13:27

See also from the man page:

       $max_repeat [5]
              The  maximum  number  of  times  latexmk will run latex/pdflatex
              before deciding that there may be an infinite loop and  that  it
              needs to bail out, rather than rerunning latex/pdflatex again to
              resolve cross-references, etc.  The  default  value  covers  all
              normal cases.

              (Note  that  the  "etc"  covers  a lot of cases where one run of
              latex/pdflatex generates files to be read in on a later run.)

Source: man latexmk, also available online on CTAN or from texdoc latexmk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.