[Tex/LaTex] Splitting a large document into several files

best practicesincludeinput

Why is it recommended to split a large document into several parts and include them with \include? Is it only a relic of the past times when computers and LaTeX compilers were slower, or is it still up-to-date? What are the pros and cons of this practice, also in terms of interaction with other external tools (version control, find/replace, et cetera)?

Motivation: I've found a recent discussion that mentions this practice ( Writing and Managing Thesis in LaTeX, Everyday LaTeX and workflow?), as well as a comment that criticizes it in an answer to Everyday LaTeX and workflow?. A couple of months ago, I asked the same question in a comment to Techniques and packages to keep up with good practices, but it's probably better to ask this here again as a "real question".

Best Answer

Splitting a large document into parts is A Good Thing; with today's front-ends or editors it's quite easy to jump from one part to the other.

The choice between \include and \input is very subjective. \include was born when computers were slow and typesetting a complete book could be a good occasion for having a coffee, maybe two. It has its uses now also, because it can solve cross references even when the chapter is not \included. (See also CountZero's answer for another use.)

Personally I don't mind if some references are not solved during trial typesetting sessions, when I'm more interested in the overall shape than in precise line and page breaks. It's easy to comment out some lines in a well-structured main file, but the same can be said about strings passed to \includeonly; however using \input and commenting doesn't require to duplicate the list of files. Not a big deal, of course, but when the chapters are many, it might be a nuisance; on the other hand, writing and reading from .aux files adds a little overhead.

With a modern computer, the times needed to typeset a chapter or an entire book are not very different, unless the book is very large, or it has many graphics using TikZ or PSTricks that slow down the process. In these cases, using \include can save your time.

Related Question