# Avoiding recompilation of unchanged part of a document

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 ?

• Welcome to TeX.sx! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – masu Dec 8 '13 at 11:34
• WinEdt has a tool to compile just a selected part of your text, but you are probably not interested in it... – karlkoeller Dec 8 '13 at 12:11
• Maybe using standalone? Each part is a standalone document, and they can be combined... – Dror Dec 8 '13 at 15:13
• @karlkoeller thank you for the suggestion, even if this is not exactly what I need, being able to precompile some parts may save a lot of time. – Aquadarius Dec 8 '13 at 17:06
• @Dror Good suggestion, however, it seems to not work for an unknown reason (the standalone pdf is empty...). – Aquadarius Dec 8 '13 at 17:32

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.

• aiui, dror's code doesn't meet the requirement; the op seems to want the analogue of code-library binding when linking an executable; this is something that tex simply doesn't do ... ime (which doesn't include context, though i would only be slightly amazed to learn that context has solved the problem, too). – wasteofspace Dec 9 '13 at 11:07
• @wasteofspace that's exaclty what I need. May be you're right and it is completely out of the scope of latex, because now I understand from the latex philosophy that each compilation pass can modify the output document even if the source is not modified. – Aquadarius Dec 9 '13 at 19:55
• @Dror I will try this at home, but is there a way to check if the document has been recompiled or not ? – Aquadarius Dec 9 '13 at 19:59
• No when I think about it again, I believe @wasteofspace is right. This won't do what you want - whenever you compile the main document it will recompile everything as far as I can tell. – Dror Dec 10 '13 at 7:54