LaTeX forum ⇒ GeneralConditional Statements in Latex

LaTeX specific issues not fitting into one of the other forums of this category.
stantestco
Posts: 8
Joined: Tue Jul 21, 2009 12:13 pm

Conditional Statements in Latex

Postby stantestco » Thu Nov 05, 2009 12:11 pm

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!!!

Link:
BBcode:
HTML:
Hide post links
Show post links

lalop
Posts: 63
Joined: Fri Sep 11, 2009 11:25 pm

Postby lalop » Thu Nov 05, 2009 12:13 pm

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

  1. \ifthenelse{ }
  2. {
  3.  
  4.  
  5. }
  6. {
  7.  
  8.  
  9. }


(Spacing changed to be suggestive; by default it's just \ifthenelse{}{}{} )

Link:
BBcode:
HTML:
Hide post links
Show post links

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Postby phi » Thu Nov 05, 2009 10:08 pm

The etoolbox package offers a solution that is a bit cleaner (no namespace polluting) and faster to type:
  1. \usepackage{etoolbox}
  2. \newtoggle{DRAFT}
  3. ...
  4. \iftoggle{DRAFT}{yes}{no}
If you want to check for the draft class option, you should use the ifdraft package instead.

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 8 guests