[texhax] multiple pdfs from one dtx (Arno Trautmann)

Niall Mansfield texhax at uit.co.uk
Thu Dec 30 16:25:25 CET 2010

  On Sat, Dec 25, 2010 at 11:03:11PM +0100, Arno Trautmann wrote:
  > I want to produce two different sty files and
  > corresponding documentations (pdfs). As the
  > sty files belong together (say, an internal
  > and external version), I want to keep
  > maintainance as easy as possible and therefore
  > use one dtx file for everything. Now, is there
  > a possibility to produce two pdfs from one dtx
  > file?

We had a related requirement -- how to produce two different
versions of a book from the same source files.  We tried
(La)TeX-specific approaches but abandoned these because the
syntax was too messy and it was too hard (for us at least)
to make sure that the conditional code was handled
correctly, and not changed by the if/else mechanism and that
we wouldn't have to worry about when expressions were
evaluated, escaped, etc.

So instead we pre-process the LaTeX files:

- source file is, say, simple.texpp
  (where 'pp' stands for 'preprocessor').

- use 'unifdef' to handle the conditionals.  unifdef is
  very basic which is great -- it leaves just about
  everything completely untouched apart from handling
  if/else.  Here's an example:



	#ifdef MME









  If we are producing the "mass market edition" (MME) we get
  one output tex file; on the other hand if MME is undefined we get a
  different variant -- the "normal" version of the book.

  We send the output of unifdef to simple.tex in this
  example, which we then process as normal.

- A full example, with Makefile, is at


  (size is 0.5K).


More information about the texhax mailing list