Open QMeqGR opened 12 months ago
Thanks for reporting the bug.
The file latex.py doesn't do much, because each sage object defines its own latex representation. In the case of a symbolic expression, such as diff(x,t)^2
, the representation is constructed by pynac (an offshoot of ginac), and that's where the bug is. I should be able to upload a PR soon to fix this.
Steps To Reproduce
sage: %display latex sage: t = var('t') sage: x = function('x')(t) sage: latex( diff(x,t)^2 ) \frac{\partial}{\partial t}x\left(t\right)^{2}
This displays essentially as (d/dt)x^2, when it should be (d/dt x)^2.
Expected Behavior
I would expect the output to be something with an extra set of parenthesis like
sage: latex( diff(x,t)^2 ) \left( \frac{\partial}{\partial t}x\left(t\right) \right)^{2}
Actual Behavior
It appears as if the pre-parser in latex.py just concatenates the generated LaTeX code, and adds the square without considering what is to its left.
I.e.... "diff(x,t)" --> \frac{\partial}{\partial t}x\left(t\right) "^2" --> ^{2}
sage: sage.misc.latex.Latex()._latex_preparse(r'\sage{diff(x,t)}', locals()) '\frac{\partial}{\partial t}x\left(t\right)' sage: sage.misc.latex.Latex()._latex_preparse(r'\sage{diff(x,t)^2}', locals()) '\frac{\partial}{\partial t}x\left(t\right)^{2}'
Additional Information
I've stared at the code in latex.py but I'm not confident enough about how it works to make any changes myself.
Environment
Checklist