# Revision history [back]

This is an idea: with

latex_formula = latex(g); latex_formula


you get x \ {\mapsto}\ \sin\left(x\right)^{5}.

Doing

new_formula = LatexExpr(latex_formula.replace('\\sin\\left(x\\right)^{5}', '\\sin^{5}\\left(x\\right)'))
pretty_print(new_formula)


returns the display you want. Further string manipulations should do the job in general. It may be useful to note that dir(sage.functions.trig) returns a list with all trig functions (and other things).

This is an idea: with

latex_formula = latex(g); latex_formula


you get x \ {\mapsto}\ \sin\left(x\right)^{5}.

Doing

new_formula new_latex_formula = LatexExpr(latex_formula.replace('\\sin\\left(x\\right)^{5}', '\\sin^{5}\\left(x\\right)'))
pretty_print(new_formula)
pretty_print(new_latex_formula)


returns the display you want. Further string manipulations should do the job in general. It may be useful to note that dir(sage.functions.trig) returns a list with all trig functions (and other things).

This is an idea: with

latex_formula = latex(g); latex_formula


you get x \ {\mapsto}\ \sin\left(x\right)^{5}.

Doing

new_latex_formula = LatexExpr(latex_formula.replace('\\sin\\left(x\\right)^{5}', '\\sin^{5}\\left(x\\right)'))
pretty_print(new_latex_formula)


returns the display you want. Further string manipulations should do the job in general. It may be useful to note that dir(sage.functions.trig) returns a list of strings with all trig functions (and other things).

This is an idea: with

latex_formula = latex(g); latex_formula


you get x \ {\mapsto}\ \sin\left(x\right)^{5}.

Doing

new_latex_formula = LatexExpr(latex_formula.replace('\\sin\\left(x\\right)^{5}', '\\sin^{5}\\left(x\\right)'))
pretty_print(new_latex_formula)


returns the display you want. Further string manipulations should do the job in general. It may be useful to note that dir(sage.functions.trig) returns a list of strings with all trig functions (and other things).

Also relevant: Sage, LaTeX and Friends.