0

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.

projetmbc
  • 13,315
  • 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) – Phelype Oleinik Mar 08 '21 at 12:33
  • Thanks for pointing latexmk. For diffìng, I will look at your link. :-) – projetmbc Mar 08 '21 at 12:38
  • arara looks very intersting! – projetmbc Mar 08 '21 at 12:45
  • It is! That's what I usually use to build my documents (I'm not a fan of latexmk), with a rule set similar to the one in the answer I linked – Phelype Oleinik Mar 08 '21 at 12:50
  • Unless you make a big effort, every PDF will always be different (= has a different hash value), since values such as PDF date etc. will always be different. See https://tex.stackexchange.com/questions/440270/ for (much) more info. – Ingmar Mar 08 '21 at 12:58
  • @PhelypeOleinik What is the problem with latexmk? – projetmbc Mar 08 '21 at 12:59
  • @Ingmar The link given by Phelype Oleinik says that we can ask pdflatexto avoid that can àf little changes. – projetmbc Mar 08 '21 at 13:01
  • That's the “effort” part, yes. Not really worth it outside of special use cases in my book. YMMV. – Ingmar Mar 08 '21 at 13:03
  • 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! – Phelype Oleinik Mar 08 '21 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 Mar 08 '21 at 13:13
  • @daleif Can you explain the continuous preview mode? – projetmbc Mar 08 '21 at 13:22
  • Latexmk goes into a loop after the compilation and keeps a look on all the files used by the project, then recompile if one changes. I generally combine it with a feature to stop compilation on first error. You loose the error parsing in the editor, but I can live with that – daleif Mar 08 '21 at 13:25
  • @daleif I keep that in my mind to be more efficient. Thanks for sharing! – projetmbc Mar 08 '21 at 13:27

0 Answers0