[texhax] TeX and make

Niall Mansfield nmm at uit.co.uk
Tue Oct 28 12:29:11 CET 2008


  > From: Michael Dexter <dexter at bsdfund.org>
  > Subject: [texhax] TeX and make
  > The question came up of how TeX plays friendly with make and incremental 
  > compiling. 

This question comes up regularly.  There are two answers:

1. LaTeX (we don't use TeX per se) on a useful but 8-year old server
   can process one of our books, 750 pages long, in
   36 seconds.  In fact this involves running LaTeX three times
   (for indexing reasons), so it's typesetting 60 pages/second.
   (Even more, in fact, because the 36s includes index processing,
   which is done twice.)
   On a recent laptop it runs at twice this speed, say 100pp/s,
   and on a fast new server you might get twice this again.

   This high speed means that in practice you don't need subsidiary
   .o files or the like for normal typesetting tasks.  It would be
   *nice* to have something like that, but given that the hardware
   is continually removing the imperative, I don't think it's likely.

2. In the Old Days, when running on Sun 3/50's and the like, it
   *was* necessary to divide LaTeX processing into chunks.  Here's
   how we did it.  The same approach works today.  It means you
   can typically process a chapter (30 pages, say) in less than a second.

	- Treat each chapter as a separate document.  You glue
	  the individual PDFs together at the end, to form
	  the complete book.

	- Run LaTeX on each chapter, to get an estimate of
	  its extent (i.e. no. of pages in it).

	- Compile a table of start page numbers for each 
	  chapter.  (We combined this with other definitions
	  for each chapter, so we could easily move chapters
	  within the book.)  Here's an example.
	  (See www.uit.co.uk/latex/latex-and-make-example.tex
	  for a longer example.)

	\definechap{TOOLKITS}{6}{149}{Look and Feel --- Toolkits}{`Look And Feel' Part 1 --- Toolkits for Application Programs}

	  This is Chap 6, and it starts on p149.  (\definechap
	  is our own macro.)

	- We used Imake to reduce the tedium of writing
	  the dependencies for each Make target, i.e. for
	  each chapter.

   Then we could say, e.g. "make TOOLKITS", to
   LaTeX that chapter, and incorporate the necessary
   bits of TOOLKITS.aux and TOOLKITS.idx etc. into the overall
   .aux and .idx, for cross-refs, indexing, etc.

   The obvious problem here is that tracking page numbers is manual.
   While tedious, this was unimportant in real life.  (a) By the time you're anywhere
   near a final draft of a book, your material is very stable, and pagination
   is unlikely to change.  (b) Even if it does, changing the table isn't a
   big deal.  But I'm sure it could be automated by programmers cleverer
   than me.

	Niall Mansfield

More information about the texhax mailing list