I would like to create a small Python script that will guess the number of compilations needed for one TEX file myfile.tex.

Here is my algorithm.

  1. Start with a folder containing only myfile.tex.

  2. Compile myfile.tex one 1st time to produce myfile-v1.pdf.

  3. Compile myfile.tex a 2nd time to produce myfile-v2.pdf for example.

  4. Compare the PDF to look for a change.

  5. Go to step 3 as many times as something has changed.

  • 1
    LaTeX usually tells you that you need to rerun (that's how, for example, latexmk knows when to stop). You can use some arara directives to do that (for example), or you can do it manually by diffing the PDF (make sure that there is no variable data in the pdf; see here) Commented Mar 8, 2021 at 12:33
  • Thanks for pointing latexmk. For diffìng, I will look at your link. :-)
    – projetmbc
    Commented Mar 8, 2021 at 12:38
  • arara looks very intersting!
    – projetmbc
    Commented Mar 8, 2021 at 12:45
  • 2
    @projetmbc No problem at all! It's a really nice tool. I'm just not a big user of it because it is “too clever” for my taste. It automates the entire build process and I don't like that because I don't have much control of what happens behind the scenes, and I personally don't like that and I prefer the kind of control that arara gives. But if you just want to build the document without worries, latexmk is really good! Commented Mar 8, 2021 at 13:09
  • 1
    @PhelypeOleinik For me the killer feature in latexmk is the continuous preview mode which I use constantly. Then I just have to save and everything is done. Mind, though that much of my latex work nowadays is editing other people's stuff
    – daleif
    Commented Mar 8, 2021 at 13:13


You must log in to answer this question.

Browse other questions tagged .