Opened 13 years ago
Closed 13 years ago
#7406 closed defect (fixed)
bug in conversion powers in to LaTeX
Reported by: | robert.marik | Owned by: | burcin |
---|---|---|---|
Priority: | major | Milestone: | sage-4.3 |
Component: | symbolics | Keywords: | latex, power, jsmath, pynac |
Cc: | Merged in: | sage-4.3.rc0 | |
Authors: | Burcin Erocal | Reviewers: | Karl-Dieter Crisman |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
The LaTeX representation of (xpi)e is not valid TeX string and is not rendered by jsmath
sage: latex((x^pi)^e) {(x)}^{\pi}^{e}
Burcin suggested how to fix this and get output like
{{(x)}^{\pi}}^{e}
The code for printing symbolic expressions is in pynac (C++). The fix can be as simple as printing an extra set of braces around power objects. If anybody wants to try fixing this, the relevant function is power::do_print_latex() in power.cpp. To get to the file (using the instructions I wrote in another message just now), go to your SAGE_ROOT and do: ./sage -f -s spkg/standard/pynac-0.1.9.p0.spkg cd spkg/build/pynac-0.1.9/src/ginac Edit power.cpp. To compile and make your changes effective, go to your SAGE_ROOT again, and do ./sage -sh cd spkg/build/pynac-0.1.9/src make install
However a better fix would be to get
{x}^{a}
if the base is an atom (or not power) and
\left({x^a}\right)^{b}
if the base is a power. This allows to distinguish easily between
x^(a^b)
and
(x^a)^b
A workaround is to remove powers of powers by simplification. For example radcan function from Maxima perfoms such simplifications
sage: latex(maxima((x^pi)^e).radcan().sage()) x^{\pi e}
Attachments (1)
Change History (7)
comment:1 Changed 13 years ago by
- Description modified (diff)
comment:2 Changed 13 years ago by
- Keywords pynac added
comment:3 Changed 13 years ago by
comment:4 Changed 13 years ago by
- Report Upstream set to N/A
- Status changed from new to needs_review
The new pynac package here
http://sage.math.washington.edu/home/burcin/pynac/pynac-0.1.10.spkg
contains fixes for both the problem in the description and the one in comment:3.
attachment:trac_7406-power_latex.patch contains doctests for the fix.
Note that the new pynac version also contains fixes for #7508 and #7264. Tests should be run with the patches from those tickets also applied in this order:
comment:5 Changed 13 years ago by
- Status changed from needs_review to positive_review
Positive review - they look great in show()! Obviously pending #7264 or a rebase.
comment:6 Changed 13 years ago by
- Merged in set to sage-4.3.rc0
- Resolution set to fixed
- Reviewers set to Karl-Dieter Crisman
- Status changed from positive_review to closed
Perhaps close problem is
Note missing \left and \right at outside parentheses which makes the rendering of the expression far from perfect. Should look like