# Ticket #11428(new enhancement)

Opened 2 years ago

## Customizable latex for functions

Reported by: Owned by: SimonKing burcin major sage-5.10 symbolics N/A

### Description

There should be a way to customize how a function is printed and how it is translated into Latex, as requested on  ask-sage.

I suggest, as a first step, to add methods set_name() and set_latex_name() that change the value of the cdefined attributes _name used for printing and _latex_name used for translation to latex. Then, the following would work:

sage: tan.set_name('tg')
sage: tan
tg
sage: tan.set_latex_name(r'\tg')
sage: latex(tan)
\tg


However, that can really only be the first step. Because, when I did so, I still got

sage: tan(x)
tan(x)
sage: latex(tan(x))
\tan\left(x\right)


Hence, in addition to that, the given latex name should be propagated to expressions.

## Change History

### comment:1 Changed 2 years ago by kcrisman

Please upload that preliminary patch so others can work with it!

The SR stuff does come from Ginac, as I thought I remembered. Maybe Burcin will have a brief comment to put us on the right track for that; I don't quite understand how it works, though I think I once nearly figured it out :)

### Changed 2 years ago by SimonKing

Preliminary patch: Change latex/repr of a function. But the custom names are not propagated.

### comment:2 Changed 2 years ago by SimonKing

Patch's up.

With it, this works

sage: tan.set_latex_name(r'\tg')
sage: latex(tan)
\tg
sage: tan.set_name('tg')
sage: tan
tg


but this doesn't

sage: tan(x)
tan(x)
sage: latex(tan(x))
\tan\left(x\right)


### comment:3 Changed 6 months ago by kcrisman

For reference for anyone implementing this correctly, in  this thread on sage-support, Burcin recommends

It needs to go through the
registry of functions stored in Pynac and update the name or the
printing functions there.

Note: See TracTickets for help on using tickets.