[system] / trunk / pg / macros / PGbasicmacros.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGbasicmacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 6850 Revision 6851
1400Then mathematical formulas in TeX are evaluated within the 1400Then mathematical formulas in TeX are evaluated within the
1401C<\( tex math mode \)> and 1401C<\( tex math mode \)> and
1402C<\[ tex display math mode \] > 1402C<\[ tex display math mode \] >
1403constructions, in that order: 1403constructions, in that order:
1404 1404
1405
1406=head3 refreshEquations
1407
1408 refreshEquations(1);
1409
1410Prevents equations generated in "image mode" from being cached. This can be useful for debugging.
1411It has no effect in the other modes.
1412
1413=cut
1414
1415sub refreshEquations{
1416 my $in = shift;
1417 if ($displayMode eq "HTML_dpng") {
1418 $envir->{imagegen}->refresh($in);
1419 }
1420}
1421
1422=head3 addToTeXPreamble
1423
1424 addToTeXPreamble("\newcommand{\myVec}[1]{\vec{#1}} ");
1425
1426Defines C<\myVec > for all the equations in the file. You can change the vector notation for an entire PG question
1427by changing just this line.
1428
1429For consistent behavior with hardcopy place this macro before any text is generated for the question.
1430This should work for short TeX macro definitions such as the one above. It is very likely
1431to break if you try to use it for complicated TeX commands. YMMV.
1432
1433If you place this macro in PGcourse.pl remember to use double backslashes because it is a .pl file.
1434In .pg files use single backslashes. This is in accordance with the usual rules for backslash
1435in PG.
1436
1437
1438=cut
1439
1440sub addToTeXPreamble {
1441 my $str = shift;
1442 if ($displayMode eq "HTML_dpng") {
1443 $envir->{imagegen}->addToTeXPreamble($str."\n" ) ;
1444 } else {
1445 TEXT($str."\n");
1446 }
1447
1448}
1449
1450
1405=head3 FEQ 1451=head3 FEQ
1406 1452
1407 FEQ($string); # processes and outputs the string 1453 FEQ($string); # processes and outputs the string
1408 1454
1409 1455
1552 $in =~ s/\+\s*\+/ + /g; 1598 $in =~ s/\+\s*\+/ + /g;
1553 $in =~ s/\-\s*\-/ + /g; 1599 $in =~ s/\-\s*\-/ + /g;
1554 $in; 1600 $in;
1555} 1601}
1556 1602
1557#sub math_ev3 {
1558# my $in = shift; #print "in=$in<BR>";
1559# my ($out,$PG_eval_errors,$PG_full_error_report);
1560# $in = FEQ($in);
1561# $in =~ s/%/\\%/g; # % causes trouble in TeX and HTML_tth it usually (always?) indicates an error, not comment
1562# return("$BM $in $EM") unless ($displayMode eq 'HTML_tth');
1563# $in = "\\(" . $in . "\\)";
1564# $out = tth($in);
1565# ($out,$PG_eval_errors,$PG_full_error_report);
1566#
1567#}
1568#
1569#sub display_math_ev3 {
1570# my $in = shift; #print "in=$in<BR>";
1571# my ($out,$PG_eval_errors,$PG_full_error_report);
1572# $in = FEQ($in);
1573# $in =~ s/%/\\%/g;
1574# return("$main::BDM $in $main::EDM") unless $displayMode eq 'HTML_tth' ;
1575# $in = "\\[" . $in . "\\]";
1576# $out =tth($in);
1577# ($out,$PG_eval_errors,$PG_full_error_report);
1578#}
1579 1603
1580sub math_ev3 { 1604sub math_ev3 {
1581 my $in = shift; 1605 my $in = shift;
1582 return general_math_ev3($in, "inline"); 1606 return general_math_ev3($in, "inline");
1583} 1607}
1611 if($displayMode eq "HTML_MathJax") { 1635 if($displayMode eq "HTML_MathJax") {
1612 $out = '<span class="MathJax_Preview">[math]</span><script type="math/tex">'.$in.'</script>' if $mode eq "inline"; 1636 $out = '<span class="MathJax_Preview">[math]</span><script type="math/tex">'.$in.'</script>' if $mode eq "inline";
1613 $out = '<span class="MathJax_Preview">[math]</span><script type="math/tex; mode=display">'.$in.'</script>' if $mode eq "display"; 1637 $out = '<span class="MathJax_Preview">[math]</span><script type="math/tex; mode=display">'.$in.'</script>' if $mode eq "display";
1614 } elsif ($displayMode eq "HTML_dpng") { 1638 } elsif ($displayMode eq "HTML_dpng") {
1615 # for jj's version of ImageGenerator 1639 # for jj's version of ImageGenerator
1616 $out = $envir->{'imagegen'}->add($in_delim); 1640 #$out = $envir->{'imagegen'}->add($in_delim);
1617 # for my version of ImageGenerator 1641 # for my version of ImageGenerator
1618 #$out = $envir->{'imagegen'}->add($in, $mode); 1642 $out = $envir->{'imagegen'}->add($in, $mode);
1619 } elsif ($displayMode eq "HTML_tth") { 1643 } elsif ($displayMode eq "HTML_tth") {
1620 $out = tth($in_delim); 1644 $out = tth($in_delim);
1621 ## remove leading and trailing spaces as per Davide Cervone. 1645 ## remove leading and trailing spaces as per Davide Cervone.
1622 $out =~ s/^\s+//; 1646 $out =~ s/^\s+//;
1623 $out =~ s/\s+$//; 1647 $out =~ s/\s+$//;

Legend:
Removed from v.6850  
changed lines
  Added in v.6851

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9