Posts tagged ‘include exclude text’

Conditional compilation in Latex

The ifthen package allows conditional blocks on Latex documents. This is very useful if you want to include or exclude some parts of the text. To use the package add the following to the document preamble:

\usepackage{ifthen}
\newboolean{DEBUG}
\setboolean{DEBUG}{false}

Then you can use \ifthenelse commands within the document to include/exclude parts of text. In this example, as the DEBUG variable is set to false, the debug text won’t appear in the final document. If we switch its value to true, the debug text will appear again.

\ifthenelse {\boolean{DEBUG}}
{This is some debug text} {This is the other text}