LaTeX Books

Cookbook

LaTeX Beginners Guide

Limited discount 50%
coupon code tDRet6Y

click here to read the whole story

LaTeX users online

In total there are 7 users online :: 1 registered, 0 hidden and 6 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Yahoo [Bot] and 6 guests

Conditional Statements in Latex

LaTeX Forum: General

Add tags LaTeX specific issues not fitting into one of the other forums of this category.

Postby stantestco on Thu Nov 5th, 2009

Hi, how would I go about including conditional statements in Latex?

if

\ifdef DRAFT \else
%%% do some PSTricks stuff in here
\fi


and then I'm able to set DRAFT=1 in some other file, ie a style file.

Thanks!!!
stantestco
 
Posts: 8
Joined: Tue Jul 21st, 2009

Postby lalop on Thu Nov 5th, 2009

That's in tex. In latex, you'd use the ifthen package which provides stuff like

Code: Select all  •  Open in writeLaTeX
\ifthenelse{     }
{


}
{


}


(Spacing changed to be suggestive; by default it's just \ifthenelse{}{}{} )
lalop
 
Posts: 63
Joined: Fri Sep 11th, 2009

Postby phi on Thu Nov 5th, 2009

The etoolbox package offers a solution that is a bit cleaner (no namespace polluting) and faster to type:
Code: Select all  •  Open in writeLaTeX
\usepackage{etoolbox}
\newtoggle{DRAFT}
...
\iftoggle{DRAFT}{yes}{no
}
If you want to check for the draft class option, you should use the ifdraft package instead.
phi
 
Posts: 577
Joined: Tue Oct 21st, 2008


Return to General

LaTeX users online

Users browsing this forum: Yahoo [Bot] and 6 guests