Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

First of all, when you define a_ij=var('a_ij') then you define symbolic variables. But when you later do (with inject_on()) PolynomialRing(QQ,a_ij), then a_ij becomes a generator of a polynomial ring.

It is a very common mistake to confuse these two very different objects, and I recommend that you carefully decide whether you want to work with polynomials (i.e., you have a polynomial ring, ideals, want to compute Gröbner bases and those things) or with symbolic expressions (they may happen to look like a polynomial, but provide largely different features).

In particular, since a_ij has completely changed its meaning, it is no surprise that the latex name has gone.

You could do:

sage: R.<a_12,a_23> = QQ[]  # you don't need inject_on()
sage: type(a_12)  # It is not a symbolic variable!
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
sage: latex(a_12)  # This is not how you like it
sage: R._latex_names  # This is where the names are stored
['a_{12}', 'a_{23}']
sage: R._latex_names = ['a_{1,2}','a_{2,3}'] # Override it...
sage: latex(a_12)  # ... and enjoy

I think it is a hack, and there should be a method, say, R.set_latex_names(), but unfortunately there isn't, yet.