Ask Your Question

Revision history [back]

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:

  1. Typeset vectors as column vectors rather than row vectors.
  2. 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!