# Ticket #12156: 12156_extra_doc.patch

File 12156_extra_doc.patch, 2.9 KB (added by jdemeyer, 10 years ago)
• ## sage/misc/latex.py

# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1324302231 0
# Node ID 5c85a106274748bdc69dd92585932f768b032c08
# Parent  12dbe7027b7b3dff43192ff7e069ba8363de2660
Additional changes to "latex" and "LatexExpr" documentation

diff --git a/sage/misc/latex.py b/sage/misc/latex.py
 a class LatexExpr(str): """ r""" A class for LaTeX expressions. Normally, objects of this class are created by a :func:latex call. It is also possible to generate :class:LatexExpr directly from a string, which must contain a valid LaTeX code for typesetting in math mode. Strings are wrapped into verbatim environment for typeset output, while LaTeX expressions are left as-is (see :func:pretty_print). must contain valid LaTeX code for typesetting in math mode (without dollar signs). In the Sage Notebook, use :func:pretty_print or the "Typeset" checkbox to actually see the typeset LaTeX code. INPUT: - anything convertible to a string of valid math mode LaTeX code. - str -- a string with valid math mode LaTeX code (or something which can be converted to such a string). OUTPUT: x^{20} + 1 sage: type(L) A LatexExpr can be converted to a plain string:: sage: str(latex(x^20 + 1)) 'x^{20} + 1' """ def __add__(self, other): r""" :: %latex The equation $y^2 = x^3 + x$ defines an elliptic curve. We have $2006 = \sage{factor(2006)}$. %latex The equation $y^2 = x^3 + x$ defines an elliptic curve. We have $2006 = \sage{factor(2006)}$. in an input cell in the notebook to get a typeset version. Use %latex_debug to get debugging output. Use latex(...) to typeset a Sage object. Use latex(...) to typeset a Sage object.  Use :class:LatexExpr to typeset LaTeX code that you created by hand. Use %slide instead to typeset slides. You must have dvipng (or dvips and convert) installed on your operating system, or this command won't work. EXAMPLES:: sage: latex(x^20 + 1) x^{20} + 1 sage: latex(FiniteField(25,'a')) \Bold{F}_{5^{2}} sage: latex("hello") \verb|hello| sage: LatexExpr(r"\frac{x^2 - 1}{x + 1} = x - 1") \frac{x^2 - 1}{x + 1} = x - 1 LaTeX expressions can be added, note that a space is automatically added:: sage: LatexExpr(r"y \neq") + latex(x^20 + 1) y \neq x^{20} + 1 """ def __init__(self, debug=False, slide=False, density=150, pdflatex=None, engine=None): self.__debug = debug