Yes, you can do this by subclassing the LatexPrinter in sympy.printing.latex, redefining the methods for the classes you want to print, and using YourSubclass().doprint() instead of latex(). Or if you are using init_printing, using init_printing(latex_printer=YourSubclass().doprint). There's some basic docs on how define a subclass of a printer here https://docs.sympy.org/latest/modules/printing.html, but really the best bet is to just look at the original source code for LatexPrinter and go from there.
Aaron Meurer On Thu, Dec 8, 2022 at 7:43 AM brombo <[email protected]> wrote: > > I understand how to create a custom latex printer for my classes using > _latex(). My question is there an acceptable way for me to create a custom > latex printer for sympy class objects? For example a custom latex printer > for sympy functions or derivatives that would override the sympy printer > functions when printing my objects? > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/ff57da55-7311-4375-adfe-d61434fc5393n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6KLdzN2bL6f4J9tnn-kYCL6_VbE6nW9rxy%3DqHj77XUU5Q%40mail.gmail.com.
