WeBWorK Main Forum

Designating Special Characters

Designating Special Characters

by Spyro Roubos -
Number of replies: 0
Hello,

I know there are special ways of writing certain characters that would otherwise confuse TeX or Perl like $DOLLAR for $ and $PERCENT for %.

I was wondering how complicated is it to add others.

I ask this because our textbook uses "~" as the negation symbol unfortunately, and this has very odd effects when passing it through an answer checker or even just writing is a non-TeXed string (like to have in a pop-up menu).  Since I'm attempting to use that in a pop-up menu, I don't have the option of just using \(\sim \).

My question is: Is there an easy way of designating special characters so that they're read just as they are and not as a command?

Or as a compromise, at least display the forbidden symbol in the "answer preview", meaning: it would say something like "neg. p" in the problem, yet display properly as "~p".

Thank you,
Spyro Roubos


Here is my problem below, what I'd like would be to have $np = "~p";

# DeMorgan's Rules

########################################################################

DOCUMENT();      

loadMacros(
   "PGstandard.pl",     # Standard macros for PG language
   "MathObjects.pl",
   "parserPopUp.pl",

   #"source.pl",        # allows code to be displayed on certain sites.
   #"PGcourse.pl",      # Customization file for the course
);


# Print problem number and point value (weight) for the problem
TEXT(beginproblem());

$showPartialCorrectAnswers = 1;


##############################################################
#
#  Setup
#
#
Context("Numeric");

$p = "p";   $np = "$neg. p";
$q = "q";   $nq = "neg. q";

$And = "˄";
$Or = "˅";
$Neg = "neg.";

$popup1 = PopUp(["?", $p, $np, $q, $nq], $p);
$popup2 = PopUp(["?", $And, $Or], $Or);
$popup3 = PopUp(["?", $p, $np, $q, $nq], $q);

$popup4 = PopUp(["?", " ", $Neg], $Neg);
$popup5 = PopUp(["?", $p, $np, $q, $nq], $np);
$popup6 = PopUp(["?", $And, $Or], $And);
$popup7 = PopUp(["?", $p, $np, $q, $nq], $nq);

##############################################################
#
#  Text
#
#

Context()->texStrings;
BEGIN_TEXT

Consider the compound statement: $BR $BR
Your satisfaction is guaranteed or you get your money back.
$BR $BR
Let $BBOLD \(p\) $EBOLD = "Your satisfaction is guaranteed" and $BBOLD \(q\) $EBOLD = "You get your money back".  Translate the compound statement into symbols using the drop-downs: 
$BR $BR
\{ $popup1->menu() \} \{ $popup2->menu() \} \{ $popup3->menu() \}
$BR

Rewrite this as an equivalent statement in symbols using DeMorgan's Rules: $BR $BR

\{ $popup4->menu() \} \(\big(\) \{ $popup5->menu() \} \{ $popup6->menu() \} \{ $popup7->menu() \} \(\big)\)

END_TEXT
Context()->normalStrings;

##############################################################
#
#  Answers
#
#

ANS( $popup1->cmp() );
ANS( $popup2->cmp() );
ANS( $popup3->cmp() );
ANS( $popup4->cmp() );
ANS( $popup5->cmp() );
ANS( $popup6->cmp() );
ANS( $popup7->cmp() );
 
ENDDOCUMENT();