Module: sage.misc.latex
Latex printing support
In order to support latex formating, an object should define a special method _latex_(self) that returns a string.
Module-level Functions
| c) |
| ) |
| x, [mode=display]) |
Attempt to nicely render an arbitrary SAGE object wih jsmath typesetting. Tries to call ._latex_() on x. If that fails, it will render a string representation of x.
Input:
sage: f = maxima('1/(x^2+1)')
sage: g = f.integrate()
sage: jsmath(f)
<html><div class="math">\frac{1}{x^2+1}</div></html>
sage: jsmath(g, 'inline')
<html><span class="math">\tan^{-1} x</span></html>
sage: jsmath('\int' + latex(f) + '\ dx=' + latex(g))
<html><div class="math">\int\frac{1}{x^2+1}\ dx=\tan^{-1} x</div></html>
Author Log:
| x) |
| x) |
Return latex version of a variable name.
Here are some guiding principles for usage of this function: 1) If the variable is a single letter, that is the latex version. 2) If the variable name is suffixed by a number, we put the number in the subscript. 3) If the variable name contains an '_' we start the subscript at the underscore. Note that #3 trumps rule #2. 4) If a component of the variable is a greek letter, escape it properly. 5) Recurse nicely with subscripts.
Refer to the examples section for how these rules might play out in practice.
sage: import sage.misc.latex as latex_module
sage: latex_variable_name = latex_module.latex_variable_name
sage: latex_variable_name('a')
'a'
sage: latex_variable_name('abc')
'\\mbox{abc}'
sage: latex_variable_name('sigma')
'\\sigma'
sage: latex_variable_name('sigma_k')
'\\sigma_{k}'
sage: latex_variable_name('sigma389')
'\\sigma_{389}'
sage: latex_variable_name('beta_00')
'\\beta_{00}'
sage: latex_variable_name('Omega84')
'\\Omega_{84}'
sage: latex_variable_name('sigma_alpha')
'\\sigma_{\\alpha}'
sage: latex_variable_name('nothing1')
'\\mbox{nothing}_{1}'
sage: latex_variable_name('nothing_abc')
'\\mbox{nothing}_{\\mbox{abc}}'
sage: latex_variable_name('alpha_beta_gamma12')
'\\alpha_{\\beta_{\\gamma_{12}}}'
Author Log:
| a) |
| x, filename, [density=150], [debug=False], [brk=0], [do_in_background=True], [tiny=False]) |
Create a png image representation of x and save to the given filename.
| object) |
Try to pretty print the object in an intelligent way. For many things, this will convert the object to latex inside of html and rely on a latex-aware front end (like jsMath) to render the text
| [enable=True]) |
Enable or disable default pretty printing. Pretty printing means rendering things so that jsMath or some other latex-aware front end can render real math.
| symbols, coeffs) |
Compute a latex representation of a linear combination of some formal symbols.
Input:
sage: t = PolynomialRing(QQ, 't').0
sage: from sage.misc.latex import repr_lincomb
sage: repr_lincomb(['a', 's', ''], [-t, t - 2, t^12 + 2])
'-t\text{a} + \left(t - 2\right)\text{s} + \left(t^{12} + 2\right)\text{}'
| x) |
| objects, [title=SAGE], [zoom=4], [expert=True], [debug=False], [sep=displaymath ], [tiny=False], [center=False]) |
Compute a latex representation of each object in objects, compile, and display using xdvi. (Requires latex and xdvi be installed.)
NOTE: In notebook mode this function simply embeds a png image in the output and doesn't do any of the following.
Input:
Class: JSMath
Functions: eval
Special Functions: __call__
Class: JSMathExpr
| self, y) |
Special Functions: __add__,
__init__,
__radd__,
__repr__
Class: Latex
%latex
The equation $y^2 = x^3 + x$ defines an elliptic curve.
We have $2006 = \sage{factor(2006)}$.
%latex_debug to get debugging output.
Use latex(...) to typeset a SAGE object.
Use %slide instead to typeset slides.
| self, [debug=False], [slide=False], [density=150]) |
Functions: eval
| self, x, [strip=False], [filename=None], [debug=None], [density=None], [locals=]) |
Input:
Special Functions: __call__,
__init__,
_latex_preparse
Class: LatexExpr
| self, x) |
Special Functions: __init__,
__repr__,
_latex_
See About this document... for information on suggesting changes.