version 1.9, 2005/02/24 09:06:14
|
version 1.14, 2005/06/09 02:35:55
|
Line 547 sub tolatex {
|
Line 547 sub tolatex {
|
return ($args[0] . $p1 . $args[1]->tolatex() . $p2); |
return ($args[0] . $p1 . $args[1]->tolatex() . $p2); |
}; |
}; |
/binop2/ && do { |
/binop2/ && do { |
my ($p1, $p2, $p3, $p4) = ('','','',''); |
my ($lop,$rop) = ($args[1]->tolatex,$args[2]->tolatex); |
if ($args[0] =~ /implicit/) { |
|
if ( (($args[1]->head eq qq(number)) && |
|
($args[2]->head eq qq(number))) || |
|
(($args[1]->head eq qq(binop2)) && |
|
($args[1]->[2]->head eq qq(number))) ) { |
|
$args[0] = '\\,'; |
|
} else { |
|
$args[0] = ' '; |
|
} |
|
} |
|
if ($args[1]->[0] =~ /binop1|numberE/) |
|
{($p1,$p2)=qw{ \left( \right) };} |
|
# if ($args[2]->[0] =~ /binop[12]|numberE/) |
|
if ($args[2]->[0] =~ /binop[12]|numberE|unop1/) |
|
{($p3,$p4)=qw{ \left( \right) };} |
|
if ($args[0] eq '/'){ |
if ($args[0] eq '/'){ |
# return('\frac{' . $p1 . $args[1]->tolatex() . $p2 . '}'. |
return('\frac{'.$lop.'}{'.$rop.'}'); |
# '{' . $p3 . $args[2]->tolatex() . $p4 . '}' ); |
|
return('\frac{' . $args[1]->tolatex() . '}'. |
|
'{' . $args[2]->tolatex() . '}' ); |
|
} |
} |
elsif ($args[0] eq '*'){ |
elsif ($args[0] eq '*'){ |
return($args[1]->tolatex() . '\cdot ' . $args[2]->tolatex() ); |
return($lop. '\cdot ' .$rop); |
} |
} |
else{ |
else{ |
return ($p1 . $args[1]->tolatex() . $p2 . $args[0] . $p3 . |
$lop = '\left('.$lop.'\right)' if ($args[1]->[0] =~ /binop1|numberE/); |
$args[2]->tolatex() . $p4); |
$rop = '\left('.$rop.'\right)' if ($args[2]->[0] =~ /binop[12]|numberE|unop1/); |
|
if ($args[0] =~ /implicit/) { |
|
$args[0] = ($lop =~ m/[.0-9]$/ && $rop =~ m/^[-+.0-9]/) ? '\cdot ' : ' '; |
|
} |
|
return ($lop.$args[0].$rop); |
} |
} |
}; |
}; |
/binop3/ && do { |
/binop3/ && do { |
Line 588 sub tolatex {
|
Line 574 sub tolatex {
|
}; |
}; |
/func1/ && do { |
/func1/ && do { |
my($p1,$p2); |
my($p1,$p2); |
if($args[0] eq "sqrt"){($p1,$p2)=qw{ \left{ \right} };} |
if($args[0] eq "sqrt"){($p1,$p2)=('{','}');} |
else {($p1,$p2)=qw{ \left( \right) };} |
else {($p1,$p2)=qw{ \left( \right) };} |
|
|
# |
# |
Line 596 sub tolatex {
|
Line 582 sub tolatex {
|
# added missing trig functions |
# added missing trig functions |
# |
# |
#$specialfunc = '(?:abs|logten|asin|acos|atan|sech|sgn|step|fact)'; |
#$specialfunc = '(?:abs|logten|asin|acos|atan|sech|sgn|step|fact)'; |
my $specialfunc = '(?:abs|(logten)|a(sin|cos|tan|sec|csc|cot)(h)?|sgn|step|fact)'; |
my $specialfunc = '(?:(logten)|a(sin|cos|tan|sec|csc|cot)(h)?|sgn|step|fact|(abs))'; |
# |
# |
# End DPVC |
# End DPVC |
# |
# |
|
|
if ($args[0] =~ /$specialfunc/) { |
if ($args[0] =~ /$specialfunc/) { |
if (defined($1)) { |
if (defined($1)) { |
return ('\mbox{log}_{10}'. $p1 . $args[1]->tolatex() . $p2); |
return ('\log_{10}'. $p1 . $args[1]->tolatex() . $p2); |
} |
} |
elsif (defined($2)) { |
elsif (defined($2)) { |
return ('\mbox{' . $2.$3 .'}^{-1}'. $p1 . $args[1]->tolatex() . $p2); |
if (defined($3) && ($2 eq 'sec' || $2 eq 'csc' || $2 eq 'cot')) { |
|
return ('\mathrm{' . $2.$3 .'}^{-1}'. $p1 . $args[1]->tolatex() . $p2); |
|
} else { |
|
return ('\\' . $2.$3 .'^{-1}'. $p1 . $args[1]->tolatex() . $p2); |
|
} |
|
} |
|
elsif (defined($4)) { |
|
return ('|' . $args[1]->tolatex() . '|'); |
} |
} |
else { |
else { |
return ('\mbox{' . $args[0] .'}'. $p1 . $args[1]->tolatex() . $p2); |
return ('\mbox{' . $args[0] .'}'. $p1 . $args[1]->tolatex() . $p2); |
} |
} |
} |
} |
else { |
else { |
return ('\\' . $args[0] . $p1 . $args[1]->tolatex() . $p2); |
if ($args[0] =~/(sec|csc|cot)h/) { |
|
return ('\mathrm{' . $args[0] . '}' . $p1 . $args[1]->tolatex() . $p2); |
|
} else { |
|
return ('\\' . $args[0] . $p1 . $args[1]->tolatex() . $p2); |
|
} |
} |
} |
}; |
}; |
/special/ && do { |
/special/ && do { |