[Tex/LaTex] Avoiding recompilation of unchanged part of a document

arabiccompilinginclude

I am currently editing a relatively long document in arabic with the package arabtex, everything is going quite fine but the compilation takes several minutes. As I need to edit only small parts at once, I need to recompile only modified parts. I can accept pagebreaks between these parts.

I already tried input, include and subfiles packages, but they all seem to recompile the whole document even if nothing changed.

I would like to precise that I need, at any time, the whole document to be complete as

  1. my contributions are only comments that can be inserted anywhere in the document
  2. the editing is intended to be a collaborative with other persons on several platforms. So I cannot consider the includeonly solution.

I considered using several separate documents and merging the pdfs in a single one, but the compilation process becomes a bit more tedious and not easy to use.

Is there an elegant way to do so ?

Best Answer

Here is a MWE which employs the standalone package. The main file main.tex is the following:

\documentclass{article}
\usepackage{standalone}
\begin{document}

\input{file1}

\pagebreak

\input{file2}

\end{document}

In turn, file1.tex is:

\documentclass{standalone}

\begin{document}
Hello world!
\end{document}

and file2.tex is:

\documentclass{standalone}

\begin{document}
Foo bar
\end{document}

Both fil1.tex and file2.tex can be compiled as standalone documents, and the main file can be compiled as well.

I'm not sure whether this will solve the problem of the OP, but it might be a starting point.