Im writing my thesis with latex and I used different files for the chapters, inserted in the main one with the \input command.

Sometimes, I need to compile just 1 chapter (to send it to a reader, or to see rapidly the modifications that im doing). To do so, i comment/uncomment the related "input" commands.

But i would like to keep in the compiled chapter, the cross-references to the uncompiled chapters (sections, figures, tables,...). If i do first a compilation of the whole document, is it possible to keep the cross-references after, by avoiding destroying the old toc file, are something like that ?

Im using cleverref, but i dont know if it is useful for the present issue.

A MWE is not very usefull, but it could be as follows



%\section{Uncompiled section}\label{thelabel}
%Hello world!

\section{Compiled section}
See \cref{thelabel} to get the Hello World.

  • 3
    You can separate your document into several subfiles using \includeonly and \include. There are several explanations about how to use it on the net as well as how to avoid pagebreaks that are inserted automatically.
    – AndiW
    Feb 18, 2019 at 11:15

1 Answer 1


Use the \include set of commands. For example:

\includeonly{chap1,chap3} % only process chap1.tex and chap3.tex
\include{chap1}    % input chap1.tex
\include{chap2}    % input chap2.tex
\include{chap3}    % input chap3.tex
\include{chap4}    % input chap4.tex

which will only process chap1.tex and chap3.tex but will keep all crossreferences to previously included files. To process the whole lot comment out the \includeonly macro.

  • god this is so simple !
    – Viv
    Feb 18, 2019 at 20:21
  • And the page numbers are kept as well! incredible
    – Viv
    Feb 18, 2019 at 20:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .