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.
Best Answer
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.
\input
to include your files, you can simply comment out the relevant command for the file which you do not want to\input
.\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,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
.