## LaTeX forum ⇒ General ⇒ \setboolean in \if statement Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
ziggo1879
Posts: 2
Joined: Sun Feb 03, 2013 11:29 pm

### \setboolean in \if statement

Hey Guys,

I try to set a boolean in a if-statement but Latex seems to ignore my input.


I thought the \activate{17} statement would set the boolean "istest" to true, but it dosen't, \test returns FALSE.

Any idea why the \setboolean statement not works correctly in the \ifnum statement?

Ziggo
Last edited by ziggo1879 on Mon Feb 04, 2013 7:26 pm, edited 3 times in total.

Tags:

sommerfee
Posts: 500
Joined: Mon Apr 09, 2007 4:20 pm
ziggo1879 wrote:\newcommand{\activate}[1]{
\ifnum#1>0{\setboolean{istest}{true}}\fi }

This keeps the effect of \setboolean local to the group (opened right before \setboolean with { ), but since you close the group right after \setboolean this code has actually no effect.

So change it to
\newcommand{\activate}[1]{%   \ifnum#1>0 \setboolean{istest}{true}\fi}

and it should work as expected.
Last edited by cgnieder on Mon Feb 04, 2013 12:02 pm, edited 1 time in total.

ziggo1879
Posts: 2
Joined: Sun Feb 03, 2013 11:29 pm
and it should work as expected.

Now it works fine :-).