Featured Book

LaTeX Beginners Guide

Who is online

In total there are 17 users online :: 1 registered, 0 hidden and 16 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 16 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Conditional Statements in Latex

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

Conditional Statements in Latex

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

Re: Conditional Statements in Latex

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

Re: Conditional Statements in Latex

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: 578
Joined: Tue Oct 21st, 2008


Return to General

Who is online

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