WeBWorK Problems

Unicode "theta" in PGgraphmacros

Unicode "theta" in PGgraphmacros

by Andrew Parker -
Number of replies: 0
I'm trying to dynamically generate an image of a triangle with \theta as a label for one of the angles.

I was successful at getting a unicode degree symbol using:
$thirty = "30~~x{00B0}"; 
as a label:
$gr->lb( new Label(xPos,yPos,"$thirty",color,etc) );

However, the same trick is not working when I try to generate a theta label.
Both:
$theta = "~~x{03B8}";
and
$theta = "θ";
yield a circumflexed capital I with a comma instead of the desired theta.

I'm guessing this has something to do with the extra byte required for theta? I couldn't find any other dynamically generated images with theta as a label in the OPL - so is this even do-able?

Sample code: 
########################################################################

DOCUMENT();      

loadMacros(
   "PGstandard.pl",     # Standard macros for PG language
   "MathObjects.pl",
   "PGML.pl",
   "PGgraphmacros.pl",
);

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

# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;

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

$xmin = 0;
$xmax = 1;
$ymin = 0;
$ymax = 0.7;

$theta = "~~x{03B8}";
#$theta = "θ";

$gr = init_graph(-0.15,-0.3,1.15,1,size=>[300,300]);
$gr->lb('reset');
$gr->lb( new Label($xmin,$ymin,'A','black','center','top'));
$gr->lb( new Label($xmax,$ymin,'B','black','center','top'));
$gr->lb( new Label($xmin,$ymax,'C','black','center','bottom'));

$gr->lb( new Label($xmin+0.05,$ymax-0.13,"$theta",'blue','center','middle'));

$gr->moveTo($xmin,$ymin);
$gr->lineTo($xmax,$ymin,"black",2); 
$gr->lineTo($xmin,$ymax,"black",2);
$gr->lineTo($xmin,$ymin,"black",2);

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

BEGIN_PGML

[@ image( insertGraph($gr), width=>400, height=>400, tex_size=>800 ) @]*

END_PGML

ENDDOCUMENT();