## WeBWorK Problems

### How to use variables/tex codes in solutions

by Siman Wong -
Number of replies: 2
One of my problems has two cases depending on the sign of the randomized variable x. I have written out complete solutions for each of the two cases. Question: How can I display only the solution for relevent case? I tried the
obvious "if" statement but it didn't work.

For the record here's my code for solutions, based on http://webwork.maa.org/wiki/PopUpLists :

#Context()->texStrings;
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR SOLUTION$PAR
Solution:
(solution goes here)
END_SOLUTION
#Context()->normalStrings;

--------------

On a related note, how can I use tex mode in solutions? Webwork displays $$x$$ as plain text...

Thanks!
if($m % 2 == 0){ SOLUTION(EV3(<<'END_SOLUTION'));$PAR SOLUTION $PAR $$m$$ is even END_SOLUTION } else{ SOLUTION(EV3(<<'END_SOLUTION'));$PAR SOLUTION $PAR $$m$$ is odd END_SOLUTION } #Context()->normalStrings;  In reply to Siman Wong ### Re: How to use variables/tex codes in solutions by Dick Lane - a,b,c are integers for the following snippet. @EO = ( 'Even' , 'Odd' ) ;$ap = @EO[ $a % 2 ] ;$cp = ($c % 2 == 0) ? 'Even' : 'Odd' ; Context()->texStrings; BEGIN_SOLUTION$SOLUTION
$$a$$ is $ap,$b is @EO[$b % 2], $$c$$ is$cp