Opened 4 years ago

Closed 3 years ago

# Bad latex translation of output

Reported by: Owned by: gh-nasser1 minor sage-8.7 user interface latex, beginner rws, tscrim, alexjbest Durgesh Agrawal Alex J. Best N/A 97e08e2 97e08e277bfe1fd1b600fce511803073e15e31d5

### Description

sage 8.3 beta 6.

    sage: var('t')
sage: anti=integrate(exp(t)*log(1+t),t)
sage: anti
e^(-1)*exp_integral_e(1, -t - 1) + e^t*log(t + 1)

sage: latex(anti)
e^{\left(-1\right)} exp_integral_e\left(1, -t - 1\right) + e^{t} \log\left(t + 1\right)



The latex above is not good at all. It renders as (do not know how to inser images here).

Which is not good. May be sage needs to use a \DeclareMathOperator on exp_integral_e

### comment:1 Changed 4 years ago by gh-nasser1

• Type changed from PLEASE CHANGE to enhancement

### comment:2 Changed 4 years ago by alexjbest

• Component changed from PLEASE CHANGE to user interface

It seems this can be accomplished by adding a custom _print_latex_ method such as this one from Bessel to the classes in src/sage/functions/exp_integral.pyc, it looks like E_n is a pretty accepted notation for it.

    def _print_latex_(self, n, z):
"""
Custom _print_latex_ method.

EXAMPLES::

sage: latex(bessel_J(1, x))
J_{1}(x)
"""
return r"J_{%s}(%s)" % (latex(n), latex(z))


Possibly the arguments like latex_name=r'exp_integral_e', should also be removed in the same file then.

### comment:4 Changed 3 years ago by gh-durgeshra

• Commit set to cf9ed20c7b4ec3a58a5cd9b9dcdda78c39f062bc
• Status changed from new to needs_review

New commits:

 ​cf9ed20 Add custom _print_latex_ methods to exp_integral

### comment:5 Changed 3 years ago by gh-durgeshra

• Authors set to Durgesh Agrawal

### comment:6 Changed 3 years ago by tscrim

• Milestone changed from sage-8.3 to sage-8.6

The patchbot says there are 3 failing doctests:

sage -t --long src/sage/functions/other.py  # 3 doctests failed


Ralf, I was wondering if you could quickly confirm that this is the correct thing to do.

### comment:7 Changed 3 years ago by git

• Commit changed from cf9ed20c7b4ec3a58a5cd9b9dcdda78c39f062bc to 45483912e352ca9d9855d02a9ec65d8b9942bf0f

Branch pushed to git repo; I updated commit sha1. New commits:

 ​4548391 Fix failing doctests

### comment:8 Changed 3 years ago by gh-durgeshra

@tscrim The doctest failures were due to change in LaTeX translation. I have fixed them and they work fine now. :-)

### comment:10 Changed 3 years ago by gh-durgeshra

@tscrim @rws Any reviews on the commit, please?

### comment:11 follow-up: ↓ 12 Changed 3 years ago by alexjbest

Some of these look good, but others seem like the code has been made more complicated and the output worse looking, for example before this patch

sage: latex(sin_integral(x))
\operatorname{Si}\left(x\right)



which renders in latex with roman Si which looks better than without the operatorname.

### comment:12 in reply to: ↑ 11 Changed 3 years ago by gh-durgeshra

Then is it okay if I change the first two classes only (the ones whose LaTeX output is not rendered properly at all without the patch)?

Some of these look good, but others seem like the code has been made more complicated and the output worse looking, for example before this patch

sage: latex(sin_integral(x))
\operatorname{Si}\left(x\right)



which renders in latex with roman Si which looks better than without the operatorname.

Last edited 3 years ago by gh-durgeshra (previous) (diff)

### comment:13 Changed 3 years ago by git

• Commit changed from 45483912e352ca9d9855d02a9ec65d8b9942bf0f to 97e08e277bfe1fd1b600fce511803073e15e31d5

Branch pushed to git repo; I updated commit sha1. New commits:

 ​97e08e2 Revert back the previous latex output in some classes

### comment:14 Changed 3 years ago by gh-durgeshra

@alexjbest Now, the present diff improves the latex output of exp_integral_e and exp_integral_e1 without affecting the rest. :-)

### comment:15 Changed 3 years ago by alexjbest

• Reviewers set to Alex J. Best
• Status changed from needs_review to positive_review

Okay this looks good to me now. Thanks.

### comment:16 Changed 3 years ago by embray

• Milestone changed from sage-8.6 to sage-8.7

Retarging tickets optimistically to the next milestone. If you are responsible for this ticket (either its reporter or owner) and don't believe you are likely to complete this ticket before the next release (8.7) please retarget this ticket's milestone to sage-pending or sage-wishlist.

### comment:17 Changed 3 years ago by vbraun

• Branch changed from u/gh-durgeshra/bad_latex_translation_of_output to 97e08e277bfe1fd1b600fce511803073e15e31d5
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.