Menu

#76 latex will not render for exponents of asin, acos, atan

open
nobody
Maxima/CAS (8)
5
2014-08-18
2012-02-27
Anonymous
No

The problem is with the latex that is generated, it is the same for asin, acos, and atan. For example (asin(x))^3 is rendered as sin^{-1]^3(x) which causes problems due to the double exponent. One possibile fix would be to simply represent sin^{-1} as arcsin. I do not pretend to know your source code very well but I did manage to implement this by changing the file displayCASText to be:
else // Assume STACK returns raw LaTeX for subsequent processing, e.g. with JSMath.
{
$this->strin = $str->wrapAround();
$this->captureFeedbackTags();
$this->capturePRTFeedbackTags();
$this->applyFilters();
$this->restoreLatexValues();
$this->insertPlaceHolders();
$this->strin = str_replace('$ !html[','!html[',$this->strin); //another modification. Stops <html> tags from being given $ tags and therefore breaking tth
$this->strin = str_replace(']! $',']!',$this->strin); //bug occurs when maxima returns <html>tags in output, eg plots or div by 0 errors
$this-> JSMath_LaTeXtoHTML();
//BEGIN CHANGE
$trigin = array("sin^{-1}", "cos^{-1}", "tan^{-1}");
$trigout = array("arcsin", "arccos", "arctan");
$this->mathmlString = str_replace($trigin, $trigout, $this->strin);
//END CHANGE
$this->mathmlString = $this->strin;

$this->restoreHTML();
$this->restoreFeedback();
$this->restorePRTFeedback();
}

Discussion