Customizing sage objects latex behaviour
I'm a recent user of Sage, and am really enjoing it. I use it through jupyter, mixing a lot of markdown/latex and computations.
After this initial period, I have one major annoyance:
In some cases it would be really nice to be able to modify the latex representation of built-in objects.
I am fully aware one can easily create functions that create the desired latex from an object, but this requires you to type this function every time the given datatype is in play which is impractical. This becomes even worse when using the %display text latex cell magic.
I have two concrete examples to show what kind of behaviour change I'm after:
- Typeset vectors as column vectors rather than row vectors.
- Typeset RealField numbers similar to what you would get from 1.23.str(skip_zeroes=True, truncate=True)
I have googled quite a bit but always come up short, but I am new to sage and might be missing something.
Some select elements can be configured, such as the RealField.scientific_notation method or the latex.matrix_delimiters, but wrapping or modifying the _latex_ method or something to the same effect would be much more flexible, albeit one could argue it would also be more _hacky_ ;)
Thanks for your help!
For vectors: I don't see a non-hacky way to do it currently, but looking at the implementation of
_latex_
withv._latex_??
for a vector objectv
shows that it would be easy to implement. Just to mention some functionality that I wasn't aware of before I searched for it: you can dovector([1,2,3]).column()
.@rburing: Well at least it helps to know that there's nothing to do about it :) I have been using the column method, which works fine. But again it is just extra typing, and makes the code just a little more cluttered.