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 b  
    371371
    372372
    373373class LatexExpr(str):
    374     """
     374    r"""
    375375    A class for LaTeX expressions.
    376376   
    377377    Normally, objects of this class are created by a :func:`latex` call. It is
    378378    also possible to generate :class:`LatexExpr` directly from a string, which
    379     must contain a valid LaTeX code for typesetting in math mode. Strings are
    380     wrapped into verbatim environment for typeset output, while LaTeX
    381     expressions are left as-is (see :func:`pretty_print`).
     379    must contain valid LaTeX code for typesetting in math mode (without dollar
     380    signs). In the Sage Notebook, use :func:`pretty_print` or the "Typeset"
     381    checkbox to actually see the typeset LaTeX code.
    382382   
    383383    INPUT:
    384384   
    385     - anything convertible to a string of valid math mode LaTeX code.
     385    - ``str`` -- a string with valid math mode LaTeX code (or something
     386      which can be converted to such a string).
    386387   
    387388    OUTPUT:
    388389   
     
    410411        x^{20} + 1
    411412        sage: type(L)
    412413        <class 'sage.misc.latex.LatexExpr'>
     414
     415    A ``LatexExpr`` can be converted to a plain string::
     416
     417        sage: str(latex(x^20 + 1))
     418        'x^{20} + 1'
    413419    """
    414420    def __add__(self, other):
    415421        r"""
     
    763769
    764770    ::
    765771
    766                 %latex
    767                 The equation $y^2 = x^3 + x$ defines an elliptic curve.
    768                 We have $2006 = \sage{factor(2006)}$.
    769 
     772        %latex
     773        The equation $y^2 = x^3 + x$ defines an elliptic curve.
     774        We have $2006 = \sage{factor(2006)}$.
    770775
    771776    in an input cell in the notebook to get a typeset version. Use
    772777    ``%latex_debug`` to get debugging output.
    773778
    774     Use ``latex(...)`` to typeset a Sage object.
     779    Use ``latex(...)`` to typeset a Sage object.  Use :class:`LatexExpr`
     780    to typeset LaTeX code that you created by hand.
    775781
    776782    Use ``%slide`` instead to typeset slides.
    777783
     
    780786       You must have dvipng (or dvips and convert) installed
    781787       on your operating system, or this command won't work.
    782788
     789    EXAMPLES::
     790
     791        sage: latex(x^20 + 1)
     792        x^{20} + 1
     793        sage: latex(FiniteField(25,'a'))
     794        \Bold{F}_{5^{2}}
     795        sage: latex("hello")
     796        \verb|hello|
     797        sage: LatexExpr(r"\frac{x^2 - 1}{x + 1} = x - 1")
     798        \frac{x^2 - 1}{x + 1} = x - 1
     799
     800    LaTeX expressions can be added, note that a space is automatically
     801    added::
     802
     803        sage: LatexExpr(r"y \neq") + latex(x^20 + 1)
     804        y \neq x^{20} + 1
    783805    """
    784806    def __init__(self, debug=False, slide=False, density=150, pdflatex=None, engine=None):
    785807        self.__debug = debug