[texhax] writing about 2 parallel developments of a product withthe same base code

Hartmut Henkel hartmut_henkel at gmx.de
Wed Jan 31 06:45:57 CET 2007


On Tue, 30 Jan 2007, Philip G. Ratcliffe wrote:

> > Hi, can someone tell me how can I write 2 documents that have 90% of
> > the content the same, the rest 10% modified, some sections added, some
> > modified and some deleted?
> > Basically I need to write about 2 parallel developments of a product
> > with the same base code.
>
> Simply put the content in separate subfiles and have two main files that
> \input or \include (N.B. \include starts a new page) the various subfiles as
> necessary.
>
> Alternatively to maintain just a single main file, or if you wish to
> interleave pieces for one or other document inside the subfiles, put
>
>   \newif\ifdocA
>
> in the main files' preambles, followed by either \docAtrue or \docAfalse
> accordingly.
>
> In your subfiles you can then simply put things like:
>
> This product is \ifdocAtrue really wonderful\else absolutely useless\fi. We
> \ifdocAtrue\else cannot \fi recommend it.

you can also create one master document (e. g. doc.tex) for editing and
make links with different names to it (e. g. doc-a.tex and doc-b.tex (or
only doc-a.tex)):

$ ln -s doc.tex doc-a.tex
$ ln -s doc.tex doc-b.tex

Then prepare file doc.tex like the following for automatic switching
between document variants based on the document name:

\documentclass{article}

\newif\ifdocA
\expandafter\def\csname doc-a\endcsname{\docAtrue}
\expandafter\def\csname doc-b\endcsname{\docAfalse}
\csname\jobname\endcsname

\begin{document}
This is the  \ifdocA original \else alternate \fi version.
\end{document}

Regards, Hartmut


More information about the texhax mailing list