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
>>> 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.
A printer class which converts an expression into its LaTeX equivalent. This class extends the LatexPrinter class currently in sympy in the following ways:
- 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
- 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.
- 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.
- Some standard function names have been improved such as asin is now denoted by sin^{-1} and log by ln.
- Several LaTeX formats for multivectors are available:
- Print multivector on one line
- Print each grade of multivector on one line
- Print each base of multivector on one line
- A LaTeX output for numpy arrays containing sympy expressions is implemented for up to a three dimensional array.
- LaTeX formatting for raw LaTeX, eqnarray, and array is available in simple output strings.
- 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.
- 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.
- 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.
- Additional formats for partial derivatives:
- Same as sympy latex module
- 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 |
0 or 1 - Print multivector on one line
2 - Print each multivector grade on one line
3 - Print each multivector base on one line
0 - Default sympy latex format
Try to find ‘executable’ in the directories listed in ‘path’ (a string listing directories separated by ‘os.pathsep’; defaults to os.environ[‘PATH’]). Returns the complete filename or None if not found
0 - Use default sympy partial derivative format
1 - Contracted derivative format (no fraction symbols)
Prints LaTeX representation of the given expression.
0 - Use default sympy format