qalgebra.printing.latexprinter module

Routines for rendering expressions to LaTeX

Summary

Classes:

QalgebraLatexPrinter

Printer for a LaTeX representation.

Functions:

render_latex_sub_super

Assemble a string from the primary name and the given sub- and superscripts.

Reference

class qalgebra.printing.latexprinter.QalgebraLatexPrinter(*, cache=None, settings=None)[source]

Bases: qalgebra.printing.asciiprinter.QalgebraAsciiPrinter

Printer for a LaTeX representation.

See qalgebra.printing.latex() for documentation of settings.

sympy_printer_cls

alias of qalgebra.printing.sympy.SympyLatexPrinter

printmethod: str = '_latex'
qalgebra.printing.latexprinter.render_latex_sub_super(name, subs=None, supers=None, translate_symbols=True, sep=',')[source]

Assemble a string from the primary name and the given sub- and superscripts:

>>> render_latex_sub_super(name='alpha', subs=['mu', 'nu'], supers=[2])
'\\alpha_{\\mu,\\nu}^{2}'

>>> render_latex_sub_super(
...     name='alpha', subs=['1', '2'], supers=['(1)'], sep='')
'\\alpha_{12}^{(1)}'
Parameters
  • name (str) – the string without the subscript/superscript

  • subs (list or None) – list of subscripts

  • supers (list or None) – list of superscripts

  • translate_symbols (bool) – If True, try to translate (Greek) symbols in name, `subs, and supers to unicode

  • sep (str) – Separator to use if there are multiple subscripts/superscripts