Skip to main content
100%

Selectively Compile Latex Documents

✓ Published0🌍 Public
NN0taN3rd
Last edited Apr 23, 2018
Created on Apr 23, 2018

This example shows a LaTeX document workflow that selectively compiles only the chapters, appendix, abstract, and vita sections the author needs, using boolean flags declared in the main file. The code defines custom macros with the `xparse` and `xstring` packages, such as `\displayOnlyChapters{1,2}` and `\displayIf`, to control inclusion of each subfile. Each chapter or section, like `chapter1.tex` and `appendices.tex`, is a separate file included via the `subfiles` package, and the `ifthen` package evaluates the flags to decide which content is typeset. The setup relies on the `wsdlthesis` document class and includes the `lipsum` package for placeholder text.

AI-generated description

The subfile package is a much more efficient way to bring in the sub parts of a large latex document.

Each part of the complete document that is split up into its own text file brought is added to the document from the main tex file via

\subfile{file} 

Each subfile has the following structure

\documentclass[main.tex]{subfiles}
\begin{document}
% content
\end{document}

And each subfile has access to all packages included in the preable of the main document.

I think there is an package option for subfiles that allows each subfile to use its own preamble.

Best pratice I found is include everything used by your subfiles in the main tex files preamble

Particulars as to the setup and macros documented as comments in the main.tex file included in this gist

The wrapping of figures, tables is optional!! And is only included in this MWE as an example as to what can be done using this approach

Similar vizzes