I've noticed that in SymPy, the default LaTeX representation for positive infinity is \infty. I'm seeking a method to customize this representation to show +\infty instead.
I've explored here https://docs.sympy.org/latest/modules/printing.html sympy.printing.pretty.pretty_symbology, which maps SymPy objects to their respective LaTeX representations. However, I couldn't find a way to modify the representation for the infinity symbol.
Is there a specific configuration or setting within SymPy that permits users to customize the LaTeX representation of positive infinity?
Your question mention Latex and pretty print: those are two separate features of SymPy. This answer is about Latex: if you need to modify pretty printing it should be similar.
The official way to customize printing is to create a new printer by sub-classing the one you intend to modify.
However, this is a case where it doesn't work, because
sympy.core.numbers.Infinity(the class representing +infinity), defines the method_latex.When
LatexPrinter(or a sub-class of it) parses an object which defines this method, it executes it, no matter if you defined a custom method on the printer for that specific object. This, I believe, should not be the case. Please, consider opening an issue on Sympy.So, we are forced to override a private method on the specific class. Here's how: