Opened 3 years ago
Closed 2 years ago
#28917 closed defect (fixed)
sagemath should not use math names with underscore when generating Latex
Reported by:  ghnasser1  Owned by:  

Priority:  minor  Milestone:  sage9.1 
Component:  symbolics  Keywords:  latex 
Cc:  Merged in:  
Authors:  Dave Morris  Reviewers:  Markus Wageringel 
Report Upstream:  N/A  Work issues:  
Branch:  77bc7f4 (Commits, GitHub, GitLab)  Commit:  77bc7f493fe82b0eefbcbd0a075040403427b51e 
Dependencies:  Stopgaps: 
Description (last modified by )
seen at https://ask.sagemath.org/question/49232/latexproblemusingresultobtainedfromfricasintegrate/.
Using sagemath 8.9, when asking sagemath for latex of a math expression which contains something like log_integral
, it generates in latex log_integral
which does not typeset well due to underscore. Better translation would be \logintegral
, this allows one to make a math operator using \DeclareMathOperator{\logintegral}{log\_integral}
But it is not possible to do this now as things stands. Here is an example
sage: var('t') sage: result=integrate(1/log(t)^2,t, algorithm="fricas") sage: result (log(t)*log_integral(t)  t)/log(t) sage: latex(result) \frac{\log\left(t\right) log_integral\left(t\right)  t}{\log\left(t\right)}
The latex above would be better as
sage: latex(result) \frac{\log\left(t\right) \logintegral\left(t\right)  t}{\log\left(t\right)}
even though \logintegral
is not known to Latex, it can be made a known math name using \DeclareMathOperator
as shown above.
EDIT: In order to avoid macros that are not known to Latex, we can define the Latex name to be \operatorname{log\_integral}
.
Change History (9)
comment:1 Changed 3 years ago by
 Milestone changed from sage9.0 to sage9.1
comment:2 Changed 2 years ago by
 Branch set to public/28917
comment:3 Changed 2 years ago by
 Commit set to 6fda05daf36531b73ddd2df4ed7c9fdd6ca4c51d
 Component changed from translations to symbolics
 Description modified (diff)
 Status changed from new to needs_review
I changed the Latex name of log_integral
to \operatorname{log\_integral}
so that the resulting Latex code can be pasted directly into a Latex file, without needing to add any macro definitions. (This is the same approach that was already used in the Latex name of exp_polar
.) I made a similar fix to the Latex name of log_integral_offset
, which was the only other place that I found this problem in the sage source.
New commits:
6fda05d  underscore in latex name

comment:4 Changed 2 years ago by
 Reviewers set to Markus Wageringel
 Status changed from needs_review to needs_work
Thank you for fixing this. There is just a small problem with the backslashes in the docstring. These need to be escaped, or (preferably) the docstring should be changed to a raw string:
def __init__(self):  """ + r""" See the docstring for ``Function_log_integral``.
Other than that, this looks good to me. I could not find other instances of this latex problem in Sage, either.
comment:5 Changed 2 years ago by
 Commit changed from 6fda05daf36531b73ddd2df4ed7c9fdd6ca4c51d to 77bc7f493fe82b0eefbcbd0a075040403427b51e
Branch pushed to git repo; I updated commit sha1. New commits:
77bc7f4  need raw strings

comment:6 Changed 2 years ago by
Oops. Thanks for the correction. I also fixed a typo in a docstring (Function_log_integraloffset
> Function_log_integral_offset
).
comment:7 Changed 2 years ago by
 Status changed from needs_work to needs_review
comment:9 Changed 2 years ago by
 Branch changed from public/28917 to 77bc7f493fe82b0eefbcbd0a075040403427b51e
 Resolution set to fixed
 Status changed from positive_review to closed
Ticket retargeted after milestone closed