Forum archive 2000-2006

Zbigniew Fiedorowicz - dvipng and Latex pictures

Zbigniew Fiedorowicz - dvipng and Latex pictures

by Arnold Pizer -
Number of replies: 0
inactiveTopic dvipng and Latex pictures topic started 1/4/2003; 10:54:40 AM
last post 1/9/2003; 7:50:20 AM
user Zbigniew Fiedorowicz - dvipng and Latex pictures  blueArrow
1/4/2003; 10:54:40 AM (reads: 2753, responses: 4)
Following up on a suggestion of Mike's, I've developed an extension to
PGbasicmacros.pl to enable the display of Latex pictures in dvipng mode
(which produces much crisper graphics than the GD library). The new
routine is EV4(), whose source I attach below. [I hope it doesn't get
munged by the discussion board editor.]



It is used in problems in the following way:



TEXT(EV4(<<'END_TEXT'));
begin{picture}
....
end{picture}
END_TEXT



If we are in dvipng mode, then EV4() evaluates all Perl variables in
the text block and then ships the resulting Latex text off to dvipng.
Otherwise EV4() calls EV3().



Happy New Year to all,
Zig Fiedorowicz



sub EV4{<br /> if ($displayMode eq "HTML_dpng") {<br /> my $string = join(" ",@_);<br /> my ($evaluated_string,$PG_eval_errors,$PG_full_errors) = <br />PG_restricted_eval("</>/g;<br /> $evaluated_string = "</p><pre>$main::PAR % ERROR in $0:EV3, PGbasicmacros.pl: $main::PAR % There is an error occuring in the following <br />code:$main::BR $string $main::BR % $main::BR % $errorLines[0]n % <br />$errorLines[1]$main::BR % $main::BR % $main::BR </pre> ";<br /> }
$string = $evaluated_string;



$string = $envir{'imagegen'}->add($string);
$string;
} else {EV3(@_);}
}



<| Post or View Comments |>


user Zbigniew Fiedorowicz - Re: dvipng and Latex pictures  blueArrow
1/4/2003; 11:04:33 AM (reads: 3079, responses: 1)
Here's a related question. Looking through PGbasicmacros.pl I noticed
the following lines in the function general_math_ev3():



} elsif ($displayMode eq "HTML_img") {<br /> $out = math2img($in, $mode);</p><p><br /><br />Grepping through all the WeBWorK scripts, I could find no other<br />references to either HTML_img or math2img(). What is this code<br />supposed to do?</p><p><br /><br />Zig<br /></p> <p><a href="http://webhost.math.rochester.edu/webworkdocs/discuss/msgReader$1326?mode=day"><| Post or View Comments |></a></p> </td> </tr> </tbody></table> </td> </tr> </tbody></table><br /><table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#666666"> <tbody><tr> <td> <table width="100%" cellspacing="1" cellpadding="5" border="0"> <tbody><tr> <td bgcolor="#F5F5DC"><img width="16" height="16" border="0" alt="user" src="http://webhost.math.rochester.edu/mainResponderResources/icons/user" /> <a href="http://webhost.math.rochester.edu/webworkdocs/profiles/$1">Zbigniew Fiedorowicz</a> - <b>Re: dvipng and Latex pictures</b> <a> </a><a title="Permanent link to this message in archives." href="http://webhost.math.rochester.edu/webworkdocs/discuss/msgReader$1327?y=2006&m=11&d=30"><img width="11" height="9" border="0" alt="blueArrow" src="http://webhost.math.rochester.edu/mainResponderResources/icons/leftArrow" /></a><br /> <font size="-2" class="dgsmall">1/4/2003; 11:22:31 AM (reads: 3188, responses: 0)</font> </td> </tr> <tr bgcolor="#ffffff"> <td><pre>I've posted problems using the above-mentioned constructions on our<br />web site at</pre><p><br /><br /><a href="https://webwork.math.ohio-state.edu/examples/151demo.tar.gz">https://webwork.math.ohio-state.edu/examples/151demo.tar.gz</a><br /><a href="https://webwork.math.ohio-state.edu/examples/152demo.tar.gz">https://webwork.math.ohio-state.edu/examples/152demo.tar.gz</a></p><p><br /><br />Mike, could you add them to the CVS problem repository?</p><p><br /><br />Let me add one other comment about Latex constructions and dvipng,<br />which doesn't seem to be documented. Here's how to do tables<br />so as come out right both in hard copy and dvipng (typeset2):</p><p><br /><br />if ($main::displayMode ne 'HTML_dpng') {<br />#not dvipng mode: eg. hard copy or latex2html(typeset)<br />BEGIN_TEXT<br />\centerline{<br />\begin{tabular}{l|l}
\(x\) &\(F(x)\) \\
\hline
0 &\{ans_rule()\}\\



..........
\end{tabular}
}
END_TEXT
} else {<br />#dvipng(typeset2) mode<br />BEGIN_TEXT<br /><center><br /><table border=2><br /><tr><th width="40">\(x\)</th><th>\(F(x)\)</th></tr><br /><tr><td align="center">0</td><td>{ans_rule()}</td></tr>
.......
</table>
</center>
END_TEXT
}



Zig

<| Post or View Comments |>


user Michael Gage - Re: dvipng and Latex pictures  blueArrow
1/8/2003; 11:42:51 PM (reads: 3398, responses: 0)
This code makes the PGbasicmacros.pl package compatible with both the CGI driven version of WeBWorK and the mod_perl version of WeBWorK, currently close to its preview release phase. (I'll be using it in a calculus class this next semester to try to squash as many bugs as possible. Perhaps there won't be any. :-) )

There will be a few more changes that need to be made. The goal is to have a common set of macro files that can be used either by those using the current CGI driven version of WeBWorK or the new, available RSN mod_perl version.

I'll try to post your examples before I head out to the AMS meeting and if not as soon as I get back. As evidenced by my late posting I'm running more behind than usual.

-- Mike

<| Post or View Comments |>


user Zbigniew Fiedorowicz - Re: dvipng and Latex pictures  blueArrow
1/9/2003; 7:50:20 AM (reads: 3041, responses: 0)
OK then. This brings up another question. What changes do I need to make to my EV4() routine to also make it compatible with the mod_perl version. Also can I be assured that the name EV4() is reserved for this routine (or something functionally equivalent) in future versions of WeBWorK (so I don't have to keep rewriting my latex picture problems)?

Zig

<| Post or View Comments |>