--- loncom/xml/algebra/AlgParser.pm 2005/02/24 09:06:14 1.9 +++ loncom/xml/algebra/AlgParser.pm 2005/06/09 02:17:12 1.13 @@ -588,7 +588,7 @@ sub tolatex { }; /func1/ && do { 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) };} # @@ -596,24 +596,35 @@ sub tolatex { # added missing trig functions # #$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 # if ($args[0] =~ /$specialfunc/) { if (defined($1)) { - return ('\mbox{log}_{10}'. $p1 . $args[1]->tolatex() . $p2); + return ('\log_{10}'. $p1 . $args[1]->tolatex() . $p2); } 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 { return ('\mbox{' . $args[0] .'}'. $p1 . $args[1]->tolatex() . $p2); } } 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 {