The SymPy printing is not activated unless your class subclasses from
Basic.  If you won't want to do that, the best way to make your object
print with LaTeX in the notebook is to just use the IPython machinery:

class Test:
    def _repr_latex_(self):
        return r"$$\LaTeX$$"

If all you want is an object that displays LaTeX, you can just use
IPython.display.Math.

If you do subclass from Basic, it would look like this

class Thing(Basic):
    def _latex(self, p):
        return r"\LaTeX"

Two notes

- _repr_latex_ requires the $; _latex does not.
- _latex takes a second argument, which is the LaTeX printer. You
should use this to dispatch printing of subobjects. You can also use
it to get the options that have been set on the LaTeXPrinter and print
accordingly (e.g., inline vs. equation).

Aaron Meurer


On Sun, Jun 2, 2013 at 11:13 AM, Lucas Wilkins
<[email protected]> wrote:
> I have a class that does not extend a sympy object, but I would like it to
> print latex in the ipython shell (%load_ext sympyprinting), so I did
> something like
>
> class Thing:
>     def _latex(self):
>         return r"$\LaTeX$"
>
> I thought this should be enough, but it is not, what else is needed to get
> it to print latex stuff?
>
> --
> 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 post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to