version 1.2, 2005/02/24 06:21:10
|
version 1.13, 2005/06/09 02:17:12
|
Line 39 $close{'('} = ')';
|
Line 39 $close{'('} = ')';
|
|
|
my $binoper3 = '(?:\\^|\\*\\*)'; |
my $binoper3 = '(?:\\^|\\*\\*)'; |
my $binoper2 = '[/*_,]'; |
my $binoper2 = '[/*_,]'; |
my $binoper1 = '[-+=><%!#]'; |
my $binoper1 = '(?:<>|<=|>=|[-+=><%!])'; |
my $openparen = '[{(\\[]'; |
my $openparen = '[{(\\[]'; |
my $closeparen = '[})\\]]'; |
my $closeparen = '[})\\]]'; |
my $varname = '[A-Za-z](?:_[0-9]+)?'; |
my $varname = '[A-Za-z](?:_[0-9]+)?'; |
my $specialvalue = '(?:e|pi|da|db|dc|de|df|dg|dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|dy|dz|infty|alpha|bita|gamma|zita|thita|iota|kappa|lambda|mu|nu|xi|rho|sigma|tau|phi|chi|psi|omega|zepslon|zdelta|xeta|zupslon|zeroplace)'; |
my $greek='alpha|(?:(?:(?:var)?(?:[tT]h))|(?:[bz])?)eta|[gG]amma|iota|kappa|[lL]ambda|mu|nu|[xX]i|(?:var)?rho|(?:var)?[sS]igma|tau|(?:var)?(?:[pP])hi|chi|[oO]mega|(?:(?:var)?(?:[eE])|(?:[uU]))psilon|[dD]elta|[pP]si|(?:var)?[pP]i'; |
|
my $delete='zeroplace'; |
|
my $escape='infty'; |
|
my $specialvalue = '(?:'.$escape.'|'.$greek.'|'.$delete.'|d[a-z]|e)'; |
|
|
my $numberplain = '(?:\d+(?:\.\d*)?|\.\d+)'; |
my $numberplain = '(?:\d+(?:\.\d*)?|\.\d+)'; |
my $numberE = '(?:' . $numberplain . 'E[-+]?\d+)'; |
my $numberE = '(?:' . $numberplain . 'E[-+]?\d+)'; |
my $number = '(?:' . $numberE . '|' . $numberplain . ')'; |
my $number = '(?:' . $numberE . '|' . $numberplain . ')'; |
Line 530 sub tolatex {
|
Line 534 sub tolatex {
|
/binop1/ && do { |
/binop1/ && do { |
my ($p1, $p2) = ('',''); |
my ($p1, $p2) = ('',''); |
if ($args[2]->[0] eq 'binop1') {($p1,$p2)=qw{ \left( \right) };} |
if ($args[2]->[0] eq 'binop1') {($p1,$p2)=qw{ \left( \right) };} |
return ($args[1]->tolatex() . $args[0] . $p1 . |
my $cmd=$args[0]; |
|
if ($args[0] eq '<>') { $cmd='\\not= '; } |
|
elsif ($args[0] eq '<=') { $cmd='\\leq '; } |
|
elsif ($args[0] eq '>=') { $cmd='\\geq '; } |
|
return ($args[1]->tolatex() . $cmd . $p1 . |
$args[2]->tolatex() . $p2); |
$args[2]->tolatex() . $p2); |
}; |
}; |
/unop1/ && do { |
/unop1/ && do { |
Line 562 sub tolatex {
|
Line 570 sub tolatex {
|
'{' . $args[2]->tolatex() . '}' ); |
'{' . $args[2]->tolatex() . '}' ); |
} |
} |
elsif ($args[0] eq '*'){ |
elsif ($args[0] eq '*'){ |
# return('\frac{' . $p1 . $args[1]->tolatex() . $p2 . '}'. |
|
# '{' . $p3 . $args[2]->tolatex() . $p4 . '}' ); |
|
return($args[1]->tolatex() . '\cdot ' . $args[2]->tolatex() ); |
return($args[1]->tolatex() . '\cdot ' . $args[2]->tolatex() ); |
} |
} |
else{ |
else{ |
Line 582 sub tolatex {
|
Line 588 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 590 sub tolatex {
|
Line 596 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/) { |
return ('\mbox{' . $args[0] .'}'. $p1 . $args[1]->tolatex() . $p2); |
if (defined($1)) { |
|
return ('\log_{10}'. $p1 . $args[1]->tolatex() . $p2); |
|
} |
|
elsif (defined($2)) { |
|
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 { |
|
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 { |
if ($args[0] eq 'pi') {return '\pi';} else {return $args[0];} |
if ($args[0] =~/($greek|$escape)/) {return '\\'.$1;} |
|
elsif ($args[0] =~/$delete/) {return '';} |
|
else { return $args[0]; } |
}; |
}; |
/varname|(:?number$)/ && return $args[0]; |
/varname|(:?number$)/ && return $args[0]; |
/numberE/ && do { |
/numberE/ && do { |
Line 612 sub tolatex {
|
Line 639 sub tolatex {
|
}; |
}; |
/closep/ && do { |
/closep/ && do { |
my($backslash) = ''; |
my($backslash) = ''; |
my(%close) = %AlgParser::close; |
|
if ($args[0] eq '{') {$backslash = '\\';} |
if ($args[0] eq '{') {$backslash = '\\';} |
#This is for editors to match: } |
#This is for editors to match: } |
return ('\left' . $backslash . $args[0] . $args[1]->tolatex() . |
return ('\left' . $backslash . $args[0] . $args[1]->tolatex() . |