Latex_ex

sympy.galgebra.latex_ex.LaTeX(expr, inline=True)[source]

Convert the given expression to LaTeX representation.

You can specify how the generated code will be delimited. If the ‘inline’ keyword is set then inline LaTeX $ $ will be used. Otherwise the resulting code will be enclosed in ‘equation*’ environment (remember to import ‘amsmath’).

>>> from sympy import Rational
>>> from sympy.abc import tau, mu, x, y
>>> from sympy.galgebra.latex_ex import LaTeX
>>> LaTeX((2*tau)**Rational(7,2))
'$8 \\sqrt{2} \\sqrt[7]{\\tau}$'
>>> LaTeX((2*mu)**Rational(7,2), inline=False)
'\\begin{equation*}8 \\sqrt{2} \\sqrt[7]{\\mu}\\end{equation*}'

Besides all Basic based expressions, you can recursively convert Python containers (lists, tuples and dicts) and also SymPy matrices:

>>> LaTeX([2/x, y])
'$\\begin{bmatrix}\\frac{2}{x}, & y\\end{bmatrix}$'

The extended latex printer will also append the output to a string (LatexPrinter.body) that will be processed by xdvi() for immediate display one xdvi() is called.

class sympy.galgebra.latex_ex.LatexPrinter(inline=True)[source]

A printer class which converts an expression into its LaTeX equivalent. This class extends the LatexPrinter class currently in sympy in the following ways:

  1. Variable and function names can now encode multiple Greek symbols, number, Greek, and roman super and subscripts and accents plus bold math in an alphanumeric ASCII string consisting of [A-Za-z0-9_] symbols
    1. Accents and bold math are implemented in reverse notation. For example if you wished the LaTeX output to be \bm{\hat{\sigma}} you would give the variable the name sigmahatbm.
    2. Subscripts are denoted by a single underscore and superscripts by a double underscore so that A_{\rho\beta}^{25} would be input as A_rhobeta__25.
  2. Some standard function names have been improved such as asin is now denoted by sin^{-1} and log by ln.
  3. Several LaTeX formats for multivectors are available:
    1. Print multivector on one line
    2. Print each grade of multivector on one line
    3. Print each base of multivector on one line
  4. A LaTeX output for numpy arrays containing sympy expressions is implemented for up to a three dimensional array.
  5. LaTeX formatting for raw LaTeX, eqnarray, and array is available in simple output strings.
    1. The delimiter for raw LaTeX input is ‘%’. The raw input starts on the line where ‘%’ is first encountered and continues until the next line where ‘%’ is encountered. It does not matter where ‘%’ is in the line.
    2. The delimiter for eqnarray input is ‘@’. The rules are the same as for raw input except that ‘=’ in the first line is replaced be ‘&=&’ and ‘begin{eqnarray*}’ is added before the first line and ‘end{eqnarray*}’ to after the last line in the group of lines.
    3. The delimiter for array input is ‘#’. The rules are the same as for raw input except that ‘begin{equation*}’ is added before the first line and ‘end{equation*}’ to after the last line in the group of lines.
  6. Additional formats for partial derivatives:
    1. Same as sympy latex module
    2. Use subscript notation with partial symbol to indicate which variable the differentiation is with respect to. Symbol is of form partial_{differentiation variable}

Attributes

printmethod  
static latex_bases()[source]

Generate LaTeX strings for multivector bases

sympy.galgebra.latex_ex.MV_format(mv_fmt)[source]

0 or 1 - Print multivector on one line

2 - Print each multivector grade on one line

3 - Print each multivector base on one line

sympy.galgebra.latex_ex.fct_format(fct_fmt)[source]

0 - Default sympy latex format

1 - Do not print arguments of arbitrary functions.
Use symbol font for arbitrary functions. Use enhanced symbol naming for arbitrary functions. Use new names for standard functions (acos -> Cos^{-1})
sympy.galgebra.latex_ex.pdiff_format(pdiff_fmt)[source]

0 - Use default sympy partial derivative format

1 - Contracted derivative format (no fraction symbols)

sympy.galgebra.latex_ex.print_LaTeX(expr)[source]

Prints LaTeX representation of the given expression.

sympy.galgebra.latex_ex.str_format(str_fmt)[source]

0 - Use default sympy format

1 - Use extended symbol format including multiple Greek letters in
basic symbol (symbol preceding sub and superscripts)and in sub and superscripts of basic symbol and accents in basic symbol
sympy.galgebra.latex_ex.sym_format(sym_fmt)[source]

0 - Use default sympy format

1 - Use extended symbol format including multiple Greek letters in
basic symbol (symbol preceding sub and superscripts)and in sub and superscripts of basic symbol and accents in basic symbol
sympy.galgebra.latex_ex.xdvi(filename='tmplatex.tex', debug=False)[source]

Post processes LaTeX output (see comments below), adds preamble and postscript, generates tex file, inputs file to latex, displays resulting dvi file with xdvi or yap.

Previous topic

GAlgebra

Next topic

Geometric Algebra Module for SymPy

This Page