If the versions differ only for the \include
d files, you can put in your preamble something like
\newcommand\programmers{\includeonly{chap1,chap3}}
\newcommand\riskanalyst{\includeonly{chap1,chap4}}
\newcommand\DBadmin{\includeonly{chap1,chap2}}
Compile the whole document, so every reference is correct. In order to produce the "programmers version", call pdflatex
as
pdflatex "\nofiles\AtBeginDocument{\programmers}\input{doc.tex}"
(assuming your main document is doc.tex
). Similarly for the other categories. The \nofiles
is used to avoid clobbering the already final .aux
files.
This method has limitations: the page numbers reflect the presence of the omitted chapters, for example.
Different implementation with the comment package
\documentclass{article}
\usepackage{comment}
\includecomment{1}\includecomment{2}\includecomment{3}\includecomment{4}
\newcommand\programmers{%
\includecomment{1}\excludecomment{2}\excludecomment{3}\includecomment{4}}
\newcommand\riskanalyst{%
\includecomment{1}\excludecomment{2}\includecomment{3}\excludecomment{4}}
\newcommand\DBadmin{%
\includecomment{1}\includecomment{2}\excludecomment{3}\excludecomment{4}}
\begin{document}
\begin{1}
\input{chap1}
\end{1}
\begin{2}
\input{chap2}
\end{2}
\begin{3}
\input{chap3}
\end{3}
\begin{4}
\input{chap4}
\end{4}
\end{document}
The first line after loading comment will define the environments. As before you can produce the "programmers" version by saying from the command line
pdflatex "\AtBeginDocument{\programmers}\input{doc.tex}"
and similarly for the other versions. This will renumber chapters and pages. If you don't want to clobber the aux files, you can assign a different job name:
pdflatex --jobname=doc-programmers "\AtBeginDocument{\programmers}\input{doc.tex}"
comment
package to define environments which can be enabled and disabled e.g. depending on a macro set in the command line. There are some answer around here showing this. (looking ...)comment
package). That question is very similar to yours just about text in different languages not different content\if
I decide which environment to include. Correct?