latex(x)
, so
that any Sage object can be easily and accurately displayed via
LaTeX. Here is how to make a class and therefore its instances
support the command latex
.
import sage.misc.latex as latex
at the top of the
file that defines your class.
_latex_(self)
that returns a
LaTeX representation of your object. It should be something that
can be typeset correctly within math mode.
c
is a coefficient of your object, and you want to typeset
c
using latex, use latex(c)
instead of
c._latex_()
, since c
might not have a _latex_
method, and latex(c)
knows how to deal with this.
amsmath
,
amssymb
, amsfonts
or the ones defined in
SAGE_ROOT/doc/commontex/macros.tex
.
view(x)
to view the typeset version of an object x.
An example template for LaTeX representation follows:
import sage.misc.latex as latex ... class X: ... def _latex_(self): """ Return \Latex representation of X. EXAMPLES: sage: a = X(1,2) sage: latex(a) `\\frac{1}{2}' """ return `\\frac{%s}{%s}''%(latex(self.numer), latex(self.denom))
See About this document... for information on suggesting changes.