Home > Uncategorized > Conditions in LaTeX

Conditions in LaTeX

July 1st, 2009

You can use the ifthen LaTeX package to add conditions to your LaTeX document that affect the generated output. I used it to achieve behavior similar to the C preprocessor macros #define and #ifdef. Below is an example.

I wanted something that worked like (in psuedocode):

#define var
#ifdef var
\section{Included Section}
#else
\section{Excluded Section}
#endif

The actual LaTeX is:

\newboolean{var}
\setboolean{var}{true}
\ifthenelse{\boolean{var}}
{ \section{Included Section} }
{ \section{Excluded Section} }

Uncategorized

Comments are closed.