Forum archive 2000-2006

Zbigniew Fiedorowicz - dvipng and Latex pictures

Zbigniew Fiedorowicz - dvipng and Latex pictures

by Arnold Pizer -
Number of replies: 0
inactiveTopicdvipng and Latex pictures topic started 1/4/2003; 10:54:40 AM
last post 1/9/2003; 7:50:20 AM
userZbigniew 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{
if ($displayMode eq "HTML_dpng") {
my $string = join(" ",@_);
my ($evaluated_string,$PG_eval_errors,$PG_full_errors) =
PG_restricted_eval("</>/g;
$evaluated_string = "\n$string\nend_of_evaluation_string\n");>

$main::PAR % ERROR in $0:EV3, PGbasicmacros.pl: $main::PAR % There is an error occuring in the following 
code:$main::BR $string $main::BR % $main::BR % $errorLines[0]n %
$errorLines[1]$main::BR % $main::BR % $main::BR
";
}
$string = $evaluated_string;



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



<| Post or View Comments |>


userZbigniew 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") {
$out = math2img($in, $mode);



Grepping through all the WeBWorK scripts, I could find no other
references to either HTML_img or math2img(). What is this code
supposed to do?



Zig

<| Post or View Comments |>


userZbigniew Fiedorowicz - Re: dvipng and Latex pictures  blueArrow
1/4/2003; 11:22:31 AM (reads: 3188, responses: 0)
I've posted problems using the above-mentioned constructions on our
web site at



https://webwork.math.ohio-state.edu/examples/151demo.tar.gz
https://webwork.math.ohio-state.edu/examples/152demo.tar.gz



Mike, could you add them to the CVS problem repository?



Let me add one other comment about Latex constructions and dvipng,
which doesn't seem to be documented. Here's how to do tables
so as come out right both in hard copy and dvipng (typeset2):



if ($main::displayMode ne 'HTML_dpng') {
#not dvipng mode: eg. hard copy or latex2html(typeset)
BEGIN_TEXT
\centerline{
\begin{tabular}{l|l}
\(x\) &\(F(x)\) \\
\hline
0 &\{ans_rule()\}\\



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



Zig

<| Post or View Comments |>


userMichael 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 |>


userZbigniew 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 |>