[LON-CAPA-users] ul/li tags and \itemize \item
Seema Ali
sali at vsb.bc.ca
Sun Apr 1 20:11:25 EDT 2012
One problem can't seem to convert into pdf very easily and I'm not sure how to fix it.
Below is a portion of the tex file, which looks like the <li> tags are getting entangled with the \ensuremath{} commands.
\strut \begin{itemize}
\ensuremath{<}li\ensuremath{>}horizontal compression of a factor of \ensuremath{\backslash}ensuremath\{\ensuremath{\backslash}Large\ensuremath{\backslash}frac\{1\}\{10\}\}\ensuremath{<}/li\ensuremath{>}\ensuremath{<}li\ensuremath{>}horizontal translation of 80 units to the right\ensuremath{<}/li\ensuremath{>}\ensuremath{<}li\ensuremath{>}reflection along the line \ensuremath{<}m\ensuremath{>} = x501/m\ensuremath{>}\ensuremath{<}/li\ensuremath{>}\ensuremath{<}li\ensuremath{>}reflection along the x-axis \ensuremath{<}/li\ensuremath{>}
\end{itemize}
Below is the XML document, the <li></li> tags are generated through a script.
<problem>
<script type="loncapa/perl">#(a,b) is the original point
# c is the hz/vt compression/expansion factor
# d is the translation amount
#function obtained from http://perl.active-venture.com/pod/perlfaq4-dataarrays.html
sub fisher_yates_shuffle {
my $deck = shift; # $deck is a reference to an array
my $i = @$deck;
while ($i--) {
my $j = &random(0,$i);
@$deck[$i,$j] = @$deck[$j,$i];
}
}
$a = &random(2,6,1) * &random(-1,1,2);
do{
$b = &random(2,6,1) * &random(-1,1,2);
}while($a==$b or $a==-1*$b);
$c = &random(2,10,1);
#$d = &random(11,20,1);
$d = &random(7,10,1) * $c;
#to ensure integral answers. There is probably a better way but too tired to figure it out
$a = $a * $c;
$b = $b * $c;
$index = &random(1,2,1);
$hvexpcomp = &choose($index, "horizontal ", "vertical ");
$index = &random(1,2,1);
$hvexpcomp = $hvexpcomp.&choose($index, "expansion", "compression");
$index = &random(1,2,1);
$reflectionAxis = &choose($index, "x", "y");
$index = &random(1,2,1);
$hvtranslation = &choose($index, "horizontal", "vertical");
if($hvtranslation eq "horizontal")
{
$index = &random(1,2,1);
$direction = &choose($index,"to the right", "to the left");
}
else
{
$index = &random(1,2,1);
$direction = &choose($index, "downward", "upward");
}
@transformations = ("compression" , "axis", "translation", "y equals x");
fisher_yates_shuffle( \@transformations );
$answerX = $a;
$answerY = $b;
$steps = "";
for($index=0; $index<4; $index++)
{
if($transformations[$index] eq "compression")
{
if($hvexpcomp eq "horizontal compression")
{
#$answerX = $c * $answerX; #not sure if this will work
$answerX = $answerX * $c;
$temp = $hvexpcomp.' of a factor of <m eval=\'on\'>$\Large\frac{1}{'.$c.'}$</m>';
$temp = &xmlparse($temp);
$steps .= "<li>$temp</li>";
}
elsif($hvexpcomp eq "horizontal expansion")
{
#$a = $c * $answerX;
$answerX = $answerX / $c;
$steps .= "<li>$hvexpcomp of a factor of <m eval='on'>$ $c $</m></li>";
}
elsif($hvexpcomp eq "vertical compression")
{
#$b = $c * $answerY;
$answerY = $answerY / $c;
$temp = $hvexpcomp.' of a factor of <m eval=\'on\'>$\Large\frac{1}{'.$c.'}$</m>';
$temp = &xmlparse($temp);
$steps .= "<li>$temp</li>";
}
elsif($hvexpcomp eq "vertical expansion")
{
#$answerY = $c * $answerY;
$answerY = $c * $answerY;
$steps .= "<li>$hvexpcomp of a factor of <m eval='on'>$ $c $</m></li>";
}
}
elsif($transformations[$index] eq "axis")
{
if($reflectionAxis eq "x")
{
$answerY = -1 * $answerY;
}
else
{
$answerX = -1 * $answerX;
}
$steps .= "<li>reflection along the $reflectionAxis-axis </li>";
}
elsif($transformations[$index] eq "translation")
{
if($hvtranslation eq "horizontal" and $direction eq "to the right")
{
$answerX = $answerX + $d;
}
elsif($hvtranslation eq "horizontal" and $direction eq "to the left")
{
$answerX = $answerX - $d;
}
elsif($hvtranslation eq "vertical" and $direction eq "upward")
{
$answerY = $answerY + $d;
}
else
{
$answerY = $answerY - $d;
}
$steps .= "<li>$hvtranslation translation of $d units $direction</li>";
}
else #reflection along y=x
{
$temp = $answerX;
$answerX = $answerY;
$answerY = $temp;
$steps .= "<li>reflection along the line <m>$y = x$</m></li>";
}
#$steps .= "<li> <m eval='on'>$ ($answerX , $answerY)$</m></li>";
}</script><startouttext />The point <m eval='on'>$($a, $b)$</m> is on the graph of a function. What will the co-ordinates of this point be after all of the following transformations are performed, in the order given?
<ul>
$steps
</ul>
<br />
Answer: (<endouttext />
<numericalresponse answer="$answerX">
<responseparam type="tolerance" default="0%" name="tol" description="Numerical Tolerance" />
<responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures" />
<textline readonly="no" />
</numericalresponse><startouttext />,<endouttext />
<numericalresponse answer="$answerY">
<responseparam type="tolerance" default="0%" name="tol" description="Numerical Tolerance" />
<responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures" />
<textline readonly="no" />
</numericalresponse><startouttext />)<endouttext />
</problem>
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20120401/9075acb4/attachment-0001.html>
More information about the LON-CAPA-users
mailing list