ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 06 Jun 2011 18:21:25 +0200How to change _latex_ of log to \ln ?https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/And also more changes, for example: tan to \tg, sin to \sen etc. It's very common to use this small differences in classes in Portugal.Fri, 03 Jun 2011 08:23:33 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/Answer by cswiercz for <p>And also more changes, for example: tan to \tg, sin to \sen etc. It's very common to use this small differences in classes in Portugal.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?answer=12415#post-id-12415I'm not exactly sure how this is a Sage question but in your LaTeX preamble you can write
\DeclareMathOperator*{\tg}{tan}
so that whenever you write "`\tg`" in the LaTeX code is will appear as "tan" in the document.Fri, 03 Jun 2011 13:59:49 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?answer=12415#post-id-12415Comment by Pedro for <p>I'm not exactly sure how this is a Sage question but in your LaTeX preamble you can write</p>
<pre><code>\DeclareMathOperator*{\tg}{tan}
</code></pre>
<p>so that whenever you write "<code>\tg</code>" in the LaTeX code is will appear as "tan" in the document.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21627#post-id-21627Thank you for the tex declaration. This is a good solution. The other could be something changing the _latex_ method but I don't know how to do it avoiding changes in latex "preamble". I seems to me that one has to forget \log and then redefine it. \let\tan\undefined
\DeclareMathOperator*{\tan}{tg}
Fri, 03 Jun 2011 14:06:43 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21627#post-id-21627Comment by cswiercz for <p>I'm not exactly sure how this is a Sage question but in your LaTeX preamble you can write</p>
<pre><code>\DeclareMathOperator*{\tg}{tan}
</code></pre>
<p>so that whenever you write "<code>\tg</code>" in the LaTeX code is will appear as "tan" in the document.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21626#post-id-21626No worries. I think kcrisman's answer is at least starting to head in the direction of what you're looking for.Fri, 03 Jun 2011 15:44:58 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21626#post-id-21626Answer by kcrisman for <p>And also more changes, for example: tan to \tg, sin to \sen etc. It's very common to use this small differences in classes in Portugal.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?answer=12416#post-id-12416You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.
sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
So if you changed that to `latex_name=r"\tg"` you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for `sage.symbolic.function.Function` should have much info.
You'd have to build your changes, of course.
I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for `Function_tan` than for `GinacFunction`.
Edit:
No matter how many ways I try to do things like
sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
it doesn't seem to quite work. I just can't get it it initialize this.Fri, 03 Jun 2011 15:30:34 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?answer=12416#post-id-12416Comment by Simon King for <p>You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.</p>
<pre><code>sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
</code></pre>
<p>So if you changed that to <code>latex_name=r"\tg"</code> you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for <code>sage.symbolic.function.Function</code> should have much info. </p>
<p>You'd have to build your changes, of course. </p>
<p>I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for <code>Function_tan</code> than for <code>GinacFunction</code>.</p>
<p>Edit: <br/>
No matter how many ways I try to do things like</p>
<pre><code>sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
</code></pre>
<p>it doesn't seem to quite work. I just can't get it it initialize this.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21613#post-id-21613For the record: Meanwhile my preliminary patch is uploaded to the ticket.Mon, 06 Jun 2011 18:21:25 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21613#post-id-21613Comment by Simon King for <p>You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.</p>
<pre><code>sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
</code></pre>
<p>So if you changed that to <code>latex_name=r"\tg"</code> you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for <code>sage.symbolic.function.Function</code> should have much info. </p>
<p>You'd have to build your changes, of course. </p>
<p>I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for <code>Function_tan</code> than for <code>GinacFunction</code>.</p>
<p>Edit: <br/>
No matter how many ways I try to do things like</p>
<pre><code>sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
</code></pre>
<p>it doesn't seem to quite work. I just can't get it it initialize this.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21619#post-id-21619The ticket is #11428. I didn't upload a patch, because I can only make latex(tan) customizable, but then latex(tan(x)) won't change, sadly.Sat, 04 Jun 2011 13:54:35 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21619#post-id-21619Comment by Pedro for <p>You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.</p>
<pre><code>sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
</code></pre>
<p>So if you changed that to <code>latex_name=r"\tg"</code> you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for <code>sage.symbolic.function.Function</code> should have much info. </p>
<p>You'd have to build your changes, of course. </p>
<p>I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for <code>Function_tan</code> than for <code>GinacFunction</code>.</p>
<p>Edit: <br/>
No matter how many ways I try to do things like</p>
<pre><code>sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
</code></pre>
<p>it doesn't seem to quite work. I just can't get it it initialize this.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21621#post-id-21621Related to this: http://ask.sagemath.org/question/538/how-do-i-change-the-default-latex-output-of-a ; And in particular this comment: "...there should be a class _latex_() method to override, I just can't find it at the moment. Maybe someone with more familiarity can chime in. - benjaminfjones (May 09)"Sat, 04 Jun 2011 10:26:41 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21621#post-id-21621Comment by Simon King for <p>You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.</p>
<pre><code>sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
</code></pre>
<p>So if you changed that to <code>latex_name=r"\tg"</code> you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for <code>sage.symbolic.function.Function</code> should have much info. </p>
<p>You'd have to build your changes, of course. </p>
<p>I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for <code>Function_tan</code> than for <code>GinacFunction</code>.</p>
<p>Edit: <br/>
No matter how many ways I try to do things like</p>
<pre><code>sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
</code></pre>
<p>it doesn't seem to quite work. I just can't get it it initialize this.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21623#post-id-21623If I am not mistaken, the attribute _latex_name is a cdef attribute, so, not easily overridden. So, it looks like a missing feature to me: There *should* be methods set_name() and set_latex_name(), that can be used to determine how a function is printed on screen resp. how it appears in LaTeX. Shall I open a ticket for it?Sat, 04 Jun 2011 04:58:15 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21623#post-id-21623Comment by kcrisman for <p>You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.</p>
<pre><code>sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
</code></pre>
<p>So if you changed that to <code>latex_name=r"\tg"</code> you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for <code>sage.symbolic.function.Function</code> should have much info. </p>
<p>You'd have to build your changes, of course. </p>
<p>I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for <code>Function_tan</code> than for <code>GinacFunction</code>.</p>
<p>Edit: <br/>
No matter how many ways I try to do things like</p>
<pre><code>sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
</code></pre>
<p>it doesn't seem to quite work. I just can't get it it initialize this.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21622#post-id-21622That's a great idea.Sat, 04 Jun 2011 09:17:49 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21622#post-id-21622Comment by kcrisman for <p>You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.</p>
<pre><code>sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
</code></pre>
<p>So if you changed that to <code>latex_name=r"\tg"</code> you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for <code>sage.symbolic.function.Function</code> should have much info. </p>
<p>You'd have to build your changes, of course. </p>
<p>I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for <code>Function_tan</code> than for <code>GinacFunction</code>.</p>
<p>Edit: <br/>
No matter how many ways I try to do things like</p>
<pre><code>sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
</code></pre>
<p>it doesn't seem to quite work. I just can't get it it initialize this.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21618#post-id-21618Thanks. Remember, always put code on the ticket, no matter how preliminary :)Sun, 05 Jun 2011 00:17:14 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21618#post-id-21618Comment by Simon King for <p>You'd have to probably change the code slightly. Of course, in the long run this sort of thing should be fully localizable, but for now it's not done so easily.</p>
<pre><code>sage: sage.functions.trig.Function_tan??
<snip>
GinacFunction.__init__(self, "tan", latex_name=r"\tan")
</code></pre>
<p>So if you changed that to <code>latex_name=r"\tg"</code> you might be in business! That would work for the name as well to some extent, though one might have to be careful with making sure one actually got it back to Ginac - the code for <code>sage.symbolic.function.Function</code> should have much info. </p>
<p>You'd have to build your changes, of course. </p>
<p>I'll try to see if one can do this in a running session; one might have to reinitialize it, but the init signature is different for <code>Function_tan</code> than for <code>GinacFunction</code>.</p>
<p>Edit: <br/>
No matter how many ways I try to do things like</p>
<pre><code>sage: tan.__setattr__('_latex_name',r"\tg")
sage: tan._latex_name
'\\tg'
sage: latex(tan)
\tan
</code></pre>
<p>it doesn't seem to quite work. I just can't get it it initialize this.</p>
https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21620#post-id-21620It is a bit disappointing that the latex name (or the name) are not used when evaluating the function: Using a new method set_name() and set_latex_name(), I changed the names of tan such that it is printed `tg` on screen and `\tg` in latex. But when I did `tan(x)` or `latex(tan(x))`, the new name "tg" was not used. Does someone have an idea how that can be solved?Sat, 04 Jun 2011 11:03:56 +0200https://ask.sagemath.org/question/8149/how-to-change-_latex_-of-log-to-ln/?comment=21620#post-id-21620