# VS Code, Latex Workshop: saving a chapter imported with \input recompiles everything

I'm editing a long document with VS Code and Latex Workshop (my master's thesis). It is split into 7 chapters, each in its own .tex file. They are imported into an overarching thesis.tex file with \input.

Saving one of the chapter .tex files results in 3 build runs that recompile everything and take rather long. Can I avoid this?

There are many references sprinkled throughout the document. Both to citations from the bib file and to other chapters. The operating system is 64bit Windows 10.

• see \include and \includeonly Jul 29 '19 at 14:07
• you could use \include but there is no need to run latex three times on every save, just once. You may need to run latex document three times in total before the final draft is complete to ensure cross references are resolved but there is no need to do it every time. Jul 29 '19 at 15:09

Instead of \input{chapter1}, \input{chapter2}, etc., where your chapters are in chapter1.tex etc., use \include{chapter1}, \include{chapter2} and so on.

\documentclass[...]{...}
\includeonly{%
chapter1,
chapter2,
%     etc
chapter7
}
\begin{document}
%     preliminary stuff
\include{chapter1}
\include{chapter2}
%     etc
\include{chapter7}
%     end stuff
\end{document}


You can control which chapters get processed by commenting out entries in the \includeonly listing. For instance if you comment out everything except chapter2 then only chapter2.tex will be processed without disturbing any previously processed chapters. It is only right at the end when all chapters have been processed that you have to go through the bibliography and index processing.