# Are there any Xetex compilers that skip recompiling unchanged \input{ } files?

TexStudio is great, but I notice that the compile time is always the same (~25 seconds). Logically, a compiler should skip recompiling \input files if they have not been edited. Are there any such compilers?

• Xelatex, actually. Oct 12, 2021 at 14:13
• You can just update your question. But IMO it does not really make any sense. how exactly is the compiler suppose to skip stuff if the changes you made in file A causes the page numbers to change for all subsequent pages. That is the page content of an included file can change even if the included file it self does not. Oct 12, 2021 at 14:15
• If you just want a quicker version while drating then use \include and \includeonly to specify the file you are working on, but then only that file appears in the draft pdf. Oct 12, 2021 at 15:02

All xetex implementations will work the same way tex has very few system dependencies so that the same source on the same system will as far as possible produce the same result (xetex accessing system fonts one exception here)

There is no reason to assume that an an unchanged input file will produce unchanged output.

if you have \input{section2.tex} and you have not edited that file recently the resulting page breaking will be different depending on any text earlier in the document changing the point where this is included. Any command within the file may have a different definition, if the file starts \section{Something} but you have loaded a package to make section headings sans serif and blue, then the resulting heading will be sans serif and blue even if that file has not changed.

Basically TeX is not a compiler, it's an interpreted macro expansion language, there is no pre-compilation stage at all; and the entire language is massively context dependent (why we always ask for complete test documents to go with questions). A fragment taken out of context might do anything depending on local definitions.

• Ok. I assumed that there was a stage in which the *.tex file was pre-compiled before the final output. If I can slip in a related question - The interpreter is single pass, right? So, to handle forward references, like, "for reference, look at equation \ref{5.12} in the next chapter", you would run the single-pass interpreter twice. Is that right? ... A test run seems to make that affirmative. Oct 12, 2021 at 23:43
• @ScotParker tex is designed for the memory archtecture of a machine in 1979: it never holds the whole document in memory it only reads as far in to the file as necessary to typeset the next letter and then interleaves file input, tokenization execution and output of the partially written PDF. Oct 13, 2021 at 7:19

As David says, TeX must process all of the included code, every time. This is the case in any interpreted language that does not compile to an intermediate format.

It's also a special feature of a macro-expansion language, where every letter is really a command, and all the commands can continuously be redefined. You could define a whole set of macros in one file and then load a second one that redefined all of them differently; or you can even redefine the syntax of TeX itself, change the control characters, and introduce all sorts of unpredictable behavior.

If an interpreter compiles first to bytecode, then yes, it could do this intermediate compilation on portions as long as they are self-contained. In compiled languages, you can of course compile modules to object code before compiling the main program and linking them all together. In most cases, though, I think the portions need to be self-contained.

The closest TeX comes to using pre-compiled modules is if you compile portions to PDF and then include the PDFs (or likewise for DVI). Many of us do this for graphics or even tables, and this works because in the end the main LaTeX file is just calling \includegraphics, which means making a box of a certain size and putting an image in there. If the box is a fixed size--that is, if you specify all the dimensions to \includegraphics, then changing the input file won't change the layout of the final document. Likewise if you add the draft option to your \documentclass then TeX will just draw a box the size of the picture but not actually include it.

The other possibility in this category is to compile a whole set of macro definitions into a format:

The latexmk utility does keep track of when files are changed to minimize recompilation where it can, and it does have a mode where it continually recompiles the document as you are editing it.