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.
_latex_(self) that returns a
LaTeX representation of your object. It should be something that
can be typeset correctly within math mode. Do not include opening and closing
$'s.
latex function.
For example if
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, or amsfonts, or the ones defined in
SAGE_ROOT/doc/commontex/macros.tex.
An example template for a _latex_ method follows:
class X:
...
def _latex_(self):
r"""
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))
As shown in the example, latex(a) will produce LaTeX code
representing the object a. Calling view(a) will display the
typeset version of this.
See About this document... for information on suggesting changes.