Ondrej Certik wrote: > On Sat, Dec 27, 2008 at 5:44 PM, Alan Bromborsky <abro...@verizon.net> wrote: > >> Sometimes in the html output of Sphinx 'file' in the .rst file is >> printed as 'fle' in the .html file, but not always. If I go into the >> .rst file and change 'file' to fiile' then 'file' is printed out in the >> .html file. >> > > That's a serious bug. Could you append here the file that reproduces > that? Let's report it to the sphinx mailinglist. > > Ondrej > > > > > I have attached latex_ex.rst and latex_ex.html. The problem occurs in the description of the function xdvi near the end of the .html output
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
********************************** Extended LaTeXModule for Sympy ********************************** :Author: Alan Bromborsky .. |release| replace:: 0.10 .. % .. math:: .. % :nowrap: .. % Complete documentation on the extended LaTeX markup used for Python .. % documentation is available in ``Documenting Python'', which is part .. % of the standard documentation for Python. It may be found online .. % at: .. % .. % http://www.python.org/doc/current/doc/doc.html .. % \input{macros} .. % This is a template for short or medium-size Python-related documents, .. % mostly notably the series of HOWTOs, but it can be used for any .. % document you like. .. % The title should be descriptive enough for people to be able to find .. % the relevant document. .. % Increment the release number whenever significant changes are made. .. % The author and/or editor can define 'significant' however they like. .. % At minimum, give your name and an email address. You can include a .. % snail-mail address if you like. .. % This makes the Abstract go on a separate page in the HTML version; .. % if a copyright notice is used, it should go immediately after this. .. % .. _front: ************ Front Matter ************ .. % Copyright statement should go here, if needed. .. % ... .. % The abstract should be a paragraph or two long, and describe the .. % scope of the document. .. topic:: Abstract This document describes the extension of the latex module for :mod:`sympy`. The python module :mod:`latex_ex` extends the capabilities of the current :mod:`latex` (while preserving the current capabilities) to geometric algebra multivectors, :mod:`numpy` array's, and extends the ascii formatting of greek symbols, accents, and subscripts and superscripts. Additionally the module is configured to use the print command to generate a LaTeXoutput file and display it using :program:`xdvi`. Extended Symbol Coding ====================== One of the main extensions in :mod:`latex_ex` is the ability to encode complex symbols (multiple greek letters with accents and superscripts and subscripts) is ascii strings containing only letters, numbers, and underscores. These restrictions allow :mod:`sympy` variable names to represent complex symbols. For example if we use the :mod:`GAsympy` module function ``make_symbols`` as follows:: make_symbols('xalpha Gammavec__1_rho delta__j_k') ``make_symbols`` creates the three :mod:`sympy` symbols ``xalpha``, ``Gammavec__1_rho``, and ``delta__j_k``. If these symbols are printed with the :mod:`latex_ex` modules the results are +---------------------+---------------------+---------------------------------+ | Ascii String | | LaTeX Output | +=====================+=====================+=================================+ | ``xalpha`` | :math:`\rightarrow` | :math:`x\alpha` | +---------------------+---------------------+---------------------------------+ | ``Gammavec__1_rho`` | :math:`\rightarrow` | :math:`\vec{\Gamma}^{1}_{\rho}` | +---------------------+---------------------+---------------------------------+ | ``delta__j_k`` | :math:`\rightarrow` | :math:`\delta^{j}_{k}` | +---------------------+---------------------+---------------------------------+ A single underscore denotes a subscript and a double undscore a superscript. In addition to all normal LaTeXaccents boldmath is supported so that ``omegaomegabm``:math:`\rightarrow \Omega\bm{\Omega}` so an accent (or boldmath) only applies to the character immediately preceeding the accent command. How LaTeXPrinter Works ====================== The actual :class:`LaTeXPrinter` class is hidden with the helper functions :func:`Format`, :func:`LaTeX`, and :func:`xdvi`. :class:`LaTeXPrinter` is setup when :func:`Format` is called. In addition to setting format switches in :class:`LaTeXPrinter`, :func:`Format` does two other critical tasks. Firstly, the :mod:`sympy` function :func:`Basic.__str__` is redirected to the :class:`LaTeXPrinter` helper function :func:`LaTeX`. If nothing more that this were done the python print command would output LaTeXcode. Secondly, *sys.stdout* is redirected to a file until :program:`xdvi` is called. This file is then compiled with the :program:`latex` program and the dvi output file is displayed with the :program:`xdvi` program. Thus for :class:`LaTeXPrinter` to work both :program:`latex` and :program:`xdvi` must be installed on your system and in the execution path. LaTeXPrinter Functions ====================== LaTeXPrinter Class Functions for Extending LatexPrinter Class ------------------------------------------------------------- The :class:`LaTeXPrinter` class functions are not called directly, but rather are called when :func:`print`, :func:`LaTeX`, or :func:`str` are called. The two new fuctions for extending the :mod:`latex` module are :func:`_print_ndarray` and :func:`_print_MV`. Other functions in :class:`LatexPrinter` have been modified to increase there utility. .. function:: _print_ndarray(self,expr) :func:`_print_ndarray` returns a latex formatted string for the *expr* equal to a :class:`numpy` array with elements that can be :class:`sympy` expressions. .. function:: _print_MV(self,expr) :func:`_print_MV` returns a latex formatted string for the *expr* equal to a :class:`GAsympy` multivector. .. function:: str_basic(in_str) :func:`str_basic` returns a string without the latex formatting provided by :class:`LaTeXPrinter`. This is needed since :class:`LaTeXPrinter` takes over the :func:`str` function and there are instances when the unformatted string is needed such as during the automatic generation of variable and function names by the user's python program. Helper Functions for Extending LatexPrinter Class ------------------------------------------------- .. function:: Format(fmt='1 1 1 1') :program:`Format` iniailizes :class:`LaTeXPrinter` and set the format for :mod:`sympy` symbols, functions, and derivatives and for :mod:`GAsympy` multivectors. The switch are encoded in the text string argument of :func:`Format` as follows. It is assumed that the text string *fmt* always contains four integers separated by blanks. +----------------+-------------+--------------------------------+ | Position | Switch | Values | +================+=============+================================+ | 1:math:`^{st}` | symbol | 0: Use symbol encoding in | | | | :mod:`latex.py` | +----------------+-------------+--------------------------------+ | | | 1: Use extended symbol | | | | encoding in :mod:`latex_ex.py` | +----------------+-------------+--------------------------------+ | 2:math:`^{nd}` | function | 0: Use symbol encoding in | | | | :mod:`latex.py`. Print | | | | functions args, use | | | | ``\operator{ }`` format. | +----------------+-------------+--------------------------------+ | | | 1: Do not print function args. | | | | Do not use ``\operator{}`` | | | | format. | +----------------+-------------+--------------------------------+ | 3:math:`^{d}` | partial | 0: Use partial derivative | | | | format in :mod:`latex.py`. | +----------------+-------------+--------------------------------+ | | derivative | 1: Use format | | | | :math:`\partial_{x}` instead | | | | of | | | | :math:`\partial/\partial x`. | +----------------+-------------+--------------------------------+ | 4:math:`^{th}` | multivector | 1: Print entire multivector on | | | | one line. | +----------------+-------------+--------------------------------+ | | | 2: Print each grade of | | | | multivector on one line. | +----------------+-------------+--------------------------------+ | | | 3: Print each base of | | | | multivector on one line. | +----------------+-------------+--------------------------------+ .. function:: LaTeX(expr, inline=True) :func:`LaTeX` returns the latex string for the :mod:`sympy` or :mod:`numpy` expression *expr*. This is needed since :mod:`numpy` cannot be subclassed and hence cannot be used directly with the :func:`print` command and the :mod:`latex_ex` module. Thus if *A* is a :mod:`numpy` array containing :mod:`sympy` expressions one cannot simply say :: print A but rather :: print LaTeX(A) .. function:: xdvi(filename='tmplatex.tex',debug=False) :func:`xdvi` writes a tex file to *filename*. Executes :program:`latex` for that file and then executes :program:`xdvi` for the output of the :program:`latex` program displaying the output on the screen. If *debug=True* the console output of :program:`latex` is sent to *stderr*, otherwise to */dev/null*. This is to aid in debugging during the development of :mod:`latex_ex`. In order for :func:`xdvi` to work both :program:`latex` and :program:`xdvi` must be installed on the system and in the execution path. .. function:: MV_format(mv_fmt) .. function:: fct_format(fct_fmt) .. function:: pdiff_format(pdiff_fmt) .. function:: sym_format(sym_fmt) Examples ========Title: Extended LaTeXModule for Sympy — Geometric Algebra v0.2 documentation
Extended LaTeXModule for Sympy¶
Author: | Alan Bromborsky |
---|
Front Matter¶
Abstract
This document describes the extension of the latex module for sympy. The python module latex_ex extends the capabilities of the current latex (while preserving the current capabilities) to geometric algebra multivectors, numpy array’s, and extends the ascii formatting of greek symbols, accents, and subscripts and superscripts. Additionally the module is configured to use the print command to generate a LaTeXoutput file and display it using xdvi.
Extended Symbol Coding¶
One of the main extensions in latex_ex is the ability to encode complex symbols (multiple greek letters with accents and superscripts and subscripts) is ascii strings containing only letters, numbers, and underscores. These restrictions allow sympy variable names to represent complex symbols. For example if we use the GAsympy module function make_symbols as follows:
make_symbols('xalpha Gammavec__1_rho delta__j_k')
make_symbols creates the three sympy symbols xalpha, Gammavec__1_rho, and delta__j_k. If these symbols are printed with the latex_ex modules the results are
Ascii String | LaTeX Output | |
---|---|---|
xalpha | ||
Gammavec__1_rho | ||
delta__j_k |
A single underscore denotes a subscript and a double undscore a superscript.
In addition to all normal LaTeXaccents boldmath is supported so that
omegaomegabm so an accent (or boldmath)
only applies to the character immediately preceeding the accent command.
How LaTeXPrinter Works¶
The actual LaTeXPrinter class is hidden with the helper functions Format(), LaTeX(), and xdvi(). LaTeXPrinter is setup when Format() is called. In addition to setting format switches in LaTeXPrinter, Format() does two other critical tasks. Firstly, the sympy function Basic.__str__() is redirected to the LaTeXPrinter helper function LaTeX(). If nothing more that this were done the python print command would output LaTeXcode. Secondly, sys.stdout is redirected to a file until xdvi is called. This file is then compiled with the latex program and the dvi output file is displayed with the xdvi program. Thus for LaTeXPrinter to work both latex and xdvi must be installed on your system and in the execution path.
LaTeXPrinter Functions¶
LaTeXPrinter Class Functions for Extending LatexPrinter Class¶
The LaTeXPrinter class functions are not called directly, but rather are called when print(), LaTeX(), or str() are called. The two new fuctions for extending the latex module are _print_ndarray() and _print_MV(). Other functions in LatexPrinter have been modified to increase there utility.
- _print_ndarray(self, expr)¶
- _print_ndarray() returns a latex formatted string for the expr equal to a numpy array with elements that can be sympy expressions.
- _print_MV(self, expr)¶
- _print_MV() returns a latex formatted string for the expr equal to a GAsympy multivector.
- str_basic(in_str)¶
- str_basic() returns a string without the latex formatting provided by LaTeXPrinter. This is needed since LaTeXPrinter takes over the str() function and there are instances when the unformatted string is needed such as during the automatic generation of variable and function names by the user’s python program.
Helper Functions for Extending LatexPrinter Class¶
- Format(fmt='1 1 1 1')¶
Format iniailizes LaTeXPrinter and set the format for sympy symbols, functions, and derivatives and for GAsympy multivectors. The switch are encoded in the text string argument of Format() as follows. It is assumed that the text string fmt always contains four integers separated by blanks.
Position Switch Values 1:math: symbol 0: Use symbol encoding in latex.py 1: Use extended symbol encoding in latex_ex.py 2:math: function 0: Use symbol encoding in latex.py. Print functions args, use \operator{ } format. 1: Do not print function args. Do not use \operator{} format. 3:math: partial 0: Use partial derivative format in latex.py. derivative 1: Use format instead of
.
4:math: multivector 1: Print entire multivector on one line. 2: Print each grade of multivector on one line. 3: Print each base of multivector on one line.
- LaTeX(expr, inline=True)¶
LaTeX() returns the latex string for the sympy or numpy _expression_ expr. This is needed since numpy cannot be subclassed and hence cannot be used directly with the print() command and the latex_ex module. Thus if A is a numpy array containing sympy expressions one cannot simply say
print A
but rather
print LaTeX(A)
- xdvi(filename='tmplatex.tex', debug=False)¶
- xdvi() writes a tex file to filename. Executes latex for that file and then executes xdvi for the output of the latex program displaying the output on the screen. If debug=True the console output of latex is sent to stderr, otherwise to /dev/null. This is to aid in debugging during the development of latex_ex. In order for xdvi() to work both latex and xdvi must be installed on the system and in the execution path.
- MV_format(mv_fmt)¶
- fct_format(fct_fmt)¶
- pdiff_format(pdiff_fmt)¶
- sym_format(sym_fmt)¶