12.07.2015 Views

Sage Developer's Guide - Mirrors

Sage Developer's Guide - Mirrors

Sage Developer's Guide - Mirrors

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sage</strong> Developer’s <strong>Guide</strong>, Release 6.1.1Return $\sin(x)$."""You can also use the MATH block to format complicated mathematical expressions:.. MATH::\sum_{i=1}^{\infty} (a_1 a_2 \cdots a_i)^{1/i}\leqe \sum_{i=1}^{\infty} a_iNote that the MATH block is automatically wrapped in a latex math environment (i.e. in \[ \] or $$, etc.). To usealigned equations, use the aligned environment:.. MATH::\begin{aligned}f(x) & = x^2 - 1 \\g(x) & = x^x - f(x - 2)\end{aligned}If you wish to explicitly not wrap the MATH block, make the first line of the indented block :nowrap::.. MATH:::nowrap:This is now plain text so I can do things like $x = 5$.Warning: With or without :nowrap:, the html documentation output currently will work if you use environmentssuch as align which wrap their contents in math mode. However, :nowrap: is necessary for the pdfdocumentation to build correctly.The <strong>Sage</strong> LaTeX style is to typeset standard rings and fields like the integers and the real numbers using thelocally-defined macro \\Bold, as in \\Bold{Z} for the integers. This macro is defined to be ordinary boldface\\mathbf by default, but users can switch to blackboard-bold \\mathbb and back on-the-fly by usinglatex.blackboard_bold(True) and latex.blackboard_bold(False).The docstring will be available interactively (for the “def point...” example above, by typing “point?” at the “sage:”prompt) and also in the reference manual. When viewed interactively, LaTeX code has the backslashes stripped fromit, so “\cos” will appear as “cos”.Because of the dual role of the docstring, you need to strike a balance between readability (for interactive help) andusing perfect LaTeX code (for the reference manual). For instance, instead of using “\frac{a}{b}”, use “a/b” or maybe“a b^{-1}”. Also keep in mind that some users of <strong>Sage</strong> are not familiar with LaTeX; this is another reason to avoidcomplicated LaTeX expressions in docstrings, if at all possible: “\frac{a}{b}” will be obscure to someone who doesn’tknow any LaTeX.Finally, a few non-standard LaTeX macros are available to help achieve this balance, including “\ZZ”, “\RR”,“\CC”, and “\QQ”. These are names of <strong>Sage</strong> rings, and they are typeset using a single boldface character; theyallow the use of “\ZZ” in a docstring, for example, which will appear interactively as “ZZ” while being typesetas “\Bold{Z}” in the reference manual. Other examples are “\GF” and “\Zmod”, each of which takes an argument:“\GF{q}” is typeset as “\Bold{F}_{q}” and “\Zmod{n}” is typeset as “\Bold{Z}/n\Bold{Z}”. See thefile $SAGE_ROOT/src/sage/misc/latex_macros.py for a full list and for details about how to add moremacros.4.1. General Conventions 27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!