# Does ConTeXt ever require multiple passes to compile?

When I compile my ConTeXt document with context file.tex, it seems that the compiler compiles the code several times. I have never noticed any messages, common in pdflatex, asking me to compile the code again. Is there ever a need for me to run this command several more times to ensure that everything in the document has settled?

-
context is a Lua script that takes care of all runs necessary to have a document in final form (similar in concept to latexmk. You can try context --once for avoiding multiple runs of the engine during document preparation. –  egreg Feb 26 '12 at 14:05

ConText MkIV uses mtxrun to manage the "run" -- i.e. how many times call luatex with the appropriate switches to complete the job. However, it's smart enough to understand how many runs are needed to actually finish the task. The first time you "compile" (ok, luatex is an interpreter and not a compiler, but let's use this word because is not so wrong, afterall we can say that every *tex is a "document compiler") this example

\starttext
Hello
\stoptext


there are 3 runs, but the second time you compile this one

\starttext
Hello world
\stoptext


there is 1 run (only if you don't erase temporary files) and this

\starttext
\dorecurse{10}{\input knuth\page}
\stoptext


needs 2 runs, always if you don't erase temp files.

On the other side, a bit of experience is needed to recognize that

\starttext
\startTEXpage
\framed{\externalfigure[cow]\externalfigure[mill]}
\stopTEXpage
\stoptext


uses 3 runs the very first time, but here you can safely use context --once --- no references, new pages and so on, --- and save two runs. The same here, if we suppose to have the pictures cow1,..cow100 and mill1,..mill100:

\starttext
\dorecurse{100}{%
\startTEXpage
\framed{\externalfigure[cow\recurselvel]\externalfigure[mill\recurselevel]}
\stopTEXpage
}
\stoptext


As a thumb rule context <file> is ok; avoid context --once if you are not sure, because you can end with unfinished temporary files that can confuse context (eventually use context --purge or context --purgeall).

As a final note, you can always find an "evil" document that modify itself at every run. To avoid endless loop, there is a "hardwire" limit (ok, you can always edit the mtxrun file to change it, of course) which is 8; if your document really need 9 passes or more, then at the end of the last run you see something like "another run is needed" --- for me, it means that I've a bad designed document.

-

No, it doesn't. context takes care of it.

-
+1. Will this answer get the highest ratio of upvotes to character count? –  Bruno Le Floch Feb 27 '12 at 3:10
@BrunoLeFloch I tried to make it less characters, but tex.sx didn't allow me :) –  topskip Feb 27 '12 at 6:54
@BrunoLeFloch It'll be hard to beat this one. –  Torbjørn T. Mar 12 '12 at 20:26