I am writing a rather large document of which I am planning on using multiple input files. I have previous work that I would like to reuse without copying the data (for purposes of maintainability).

For example, I have a document linear_algebra.tex, and I would only like to include the section Eigen Value Decomposition (label eigenDecomp).

Is there a package that would allow me only to include the labeled section eigenDecomp instead of the whole document?

Thank you


I'd like to suggest something that doesn't require extra packages.

Break your document into separate files for each of the sections. Make sure that one of these files is the section you want to show / hide; let's call it eigenDecomp.tex, and assume it follows the main section of the document. You can include those files in linear_algebra.tex, using \include{}. Then, you use the \includeonly{} command in the preamble to include only the sections you need.

So, building on the example I gave here for a similar question, you'd do something like this:





Then, when you only want to include a few sections, you do this:


Note that the only drawback of this is that you can't nest \include{} commands, so you might have quite a complex file structure in linear_algebra.tex.

There are also other options you could consider such as the package Comment that allow you to selectively hide or reveal text based on labels.

  • 1
    Note that \include needs to add pagebreaks around the included part, so using it on something lower than a \chapter might give unexpected results. – Ulrich Schwarz Jun 3 '13 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.