Flags -- more on conditional compilation Contents Index

## Flags -- more on conditional compilation

You can also have sections of your document that are included depending on the setting of a flag:

\begin{ifset}{flag}
Flag flag is set!
\end{ifset}

\begin{ifclear}{flag}
Flag flag is not set!
\end{ifset}

A flag is simply the name of a TeX command. A flag is considered set if the command is defined and its expansion is neither empty nor the single character "0" (zero).

You could for instance select in the preamble which parts of a document you want included (in this example, parts A and D are included in the processed document):

\newcommand{\IncludePartA}{1}
\newcommand{\IncludePartB}{0}
\newcommand{\IncludePartC}{0}
\newcommand{\IncludePartD}{1}
...
\begin{ifset}{IncludePartA}
Text of part A
\end{ifset}
...
\begin{ifset}{IncludePartB}
Text of part B
\end{ifset}
...
\begin{ifset}{IncludePartC}
Text of part C
\end{ifset}
...
\begin{ifset}{IncludePartD}
Text of part D
\end{ifset}
...

Note that it is permitted to redefine a flag (using \renewcommand) in the document. That is particularly useful if you use these environments in a macro.

July 13, 2005

 Flags -- more on conditional compilation Contents Index