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}

Share this post:

  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
Related posts:
  1. Fix overfull problems when too many consecutive empty sections in Latex
  2. Wrap text around float figures in Latex
  3. Indent first paragraph of the section in Latex
  4. Source code snippets in Latex
  5. Placing subfigures in Latex documents

Leave a Reply