# What are your best practices to compile only a part of the document or presentation (or how do you prepare the big ones)?

I see that there a number of questions (A, B, C, D, E) on best practices, none of them answer the issue I am going to talk about.

We all need to prepare large documents (or slides) from time-to-time. And once you have reached a certain number of pages, you find that compiling the whole document takes a substantial time, which you need to do to check that the part you have written is error free, specially if it contains a number of images.

To circumvent the situation, I have used the following practices over years to keep compile time at minimum.

• Divide the document in to many chapters: The chapters are put in separate files. Only the one I am working one is uncommented.

\documentclass{book}

\begin{document}

%\input {chapterone.tex}
\input {chaptertwo.tex}
%\input {chapterthree.tex}
%\input {chapterfour.tex}

\end{document}


The above technique can also be used for \include.

• Keep a preamble replica of the main file in a temporary file (build file): I use this technique when I am preparing a presentation with many slides, say a hundred. Prepare a main file, copy it to another build file. Delete everything between \begin{document} and \end{document} in the build file. Prepare a slide (or a group of slides) in the build file. Cut and paste the contents between \begin{document} and \end{document} in the build file to relevant location in the main file only when satisfied with the output (image locations, overfull boxes etc.)

We can hear your inputs about the best practices you practice when a you are preparing a document or presentation from scratch.

Now, I have failed to find a good answer in the case when you have finished the whole document or presentation and now you need tweaking the small things, may be edit a text here, add an image there. What will be your best practice?

Perhaps, again keeping only one chapter uncommented will be usable here. But what about large presentations? May be adding a \end{document} just after the point-of-change will be beneficial, but only if you can put that before midpoint of the file.

Commenting a part of the file will also work, but that is error-prone, at least for me.

-
To mark lines inside lists as code, indent them by 8 spaces instead of 4 ;-) (sorry for the late comment, my connection is not very good today...) –  karlkoeller Nov 5 '13 at 16:11
–  cmhughes Nov 5 '13 at 16:41
The standalone package can help... –  Paul Gaborit Nov 5 '13 at 17:17
Please read some LaTeX documentation about \includeonly. –  Martin Schröder Nov 6 '13 at 12:01

There has not been any answer per se to the question so far. But we got some very helpful comments (and links). The following is an accumulated version of responses received so far (with further link traversals where necessary).

The following are not mutually exclusive and definitely not categorizations. Once you get the hang of them (all or some), you are free exercise your own styles and tricks to get your work done, a little faster.

Divide the document into individual files: Rather than preparing single large file, the document should be divided into separate .tex files

There are number of ways to choose from.

• If you are using \input to include your files, you can simply comment out the relevant command for the file which you do not want to \input.
• If you are using \include, the scenario is almost similar to the above. But the added benefit will be that this allow you to include specific files using \includeonly{filename,filename2,...} to save times.

An excellent discussion on LaTeX modular documents can be found here. Relative benefits of \input versus \include have been further elaborated in this question.

Effectively Build only a Part of the Presentation File: This is more applicable when you are making minor changes to your presentations. Your friend here is the \includeonlyframes command, which allows you to selectively include some frames. The following is an excerpt from the The beamer Class User Guide,

\includeonlyframes{⟨frame label list⟩}

This command behaves a little bit like the \includeonly command: Only the frames mentioned in the list are included. All other frames are suppressed. Nevertheless, the section and subsection commands are still executed, so that you still have the correct navigation bars. By labeling the current frame as, say, current and then saying \includeonlyframes{current}, you can work on a single frame quickly. The ⟨frame label list⟩ is a comma-separated list (without spaces) of the names of frames that have been labeled. To label a frame, you must pass the option label=⟨name⟩ to the \frame command or frame environment.

Example:

\includeonlyframes{example1,example3}
\frame[label=example1]
{This frame will be included. }
\frame[label=example2]
{This frame will not be included. }
\frame{This frame will not be included.}
\againframe{example1} % Will be included


See this answer to get some very helpful examples. Also do not miss this interesting idea of modifying \includeonlyframes to take a wild card. Do you see the prospect here? You can label your similar (group of) slides with names which can be represented as <string>*. Someone even suggested that this feature should be added to the next beamer release.

Use a Temporary/Work File: This method is mostly applicable when you are working (most likely building for the first time) on a presentation or something like a chess puzzle.

For presentations, prepare a main file, copy it to another build file. Delete everything between \begin{document} and \end{document} in the build file. Prepare a slide (or a group of slides) in the build file. Cut and paste the contents between \begin{document} and \end{document} in the build file to relevant location in the main file only when satisfied with the output (image locations, overfull boxes etc.)

For chess puzzles, use a work file (with templates for cut and paste), then copy each slide to a file until it fills to a number of puzzles, then start another file.

standalone package: This package allows TeX pictures or other TeX code in sub-files to be compiled standalone or as part of a main document. It also provides support for pictures with beamer overlays.

A detailed description of this package will make the answer very lengthy. You will get more help reading the documentation. I found this answer facilitating a quick learning. Also, see this interesting discussion on floats in standalone.

-