# algebraixlib.util.latexprinter module¶

Conversion utilities that present a MathObject as LaTeX markup.

The main entry point is the function math_object_to_latex; it delegates to the appropriate conversion function according to the argument type.

class algebraixlib.util.latexprinter.Config[source]

Bases: object

A static class with module configuration values.

colorize_output = True

If True, add colors to the output. If False, print black only.

short_atom_len = 10

Number of characters to print for ‘short’ length of Atom values. The remainder of the elements is represented by an ellipsis (‘...’). See math_object_to_latex and iprint_latex.

short_set_len = 4

Number of elements to print for ‘short’ length of Sets and Multisets. The remainder of the elements is represented by an ellipsis, followed by the number of not shown elements in parentheses (for example ‘... (15)’). See math_object_to_latex and iprint_latex.

algebraixlib.util.latexprinter.math_object_to_latex(mobj, short: bool = False, _depth: int = 0)[source]

Return a string that represents a MathObject on Undef() in LaTeX markup.

This function sorts the input mobj if it is a Set or a Multiset to make the output consistent, so be careful with big (multi)sets. (Such large (multi)sets where this is a problem may not be suitable to display in LaTeX anyway.)

Parameters: mobj – The instance that you want to translate into LaTeX. It must be a MathObject or Undef(). short – (Optional) When set to True, a short version of the content is generated. Longer parts are abbreviated with ellipses (‘...’). Defaults to False. See also Config.short_atom_len and Config.short_set_len. _depth – (Optional) Internal use only. Indicate levels of nested (multi)sets. Is incremented for every nesting level. Default is 0.
algebraixlib.util.latexprinter.iprint_latex(variable_name: str, variable_value=None, short: bool = False)[source]

Display variables in IPython notebooks using LaTeX markup. Uses math_object_to_latex.

This function sorts the input mobj if it is a Set or a Multiset to make the output consistent, so be careful with big (multi)sets. (Such large (multi)sets where this is a problem may not be suitable to display in LaTeX anyway.)

Parameters: variable_name – The name of the variable to display. variable_value – (Optional) The value of the variable. If it is missing, the variable value is fetched from the caller’s frame; a variable with the name variable_name is assumed to exist in this case. short – (Optional) When set to True, a short version of the content is generated. Longer parts are abbreviated with ellipses (‘...’). Defaults to False. See also Config.short_atom_len and Config.short_set_len.

Note

This function imports from IPython and expects IPython to be installed. This is generally given when running in an IPython notebook.

algebraixlib.util.latexprinter.atom_to_latex(atom: algebraixlib.mathobjects.atom.Atom, short: bool = False)[source]

Return a string that represents the value of an Atom in LaTeX markup.

Parameters: atom – The Atom to be represented in LaTeX markup. short – (Optional) When set to True, a short version of the content is generated. Longer parts are abbreviated with ellipses (‘...’). Defaults to False. See also Config.short_atom_len.
algebraixlib.util.latexprinter.couplet_to_latex(couplet: algebraixlib.mathobjects.couplet.Couplet, short: bool = False)[source]

Return a string that represents a Couplet in LaTeX markup.

Parameters: couplet – The Couplet to be represented in LaTeX markup. short – (Optional) When set to True, a short version of the content is generated. Longer parts are abbreviated with ellipses (‘...’). Defaults to False. See also Config.short_atom_len and Config.short_set_len. (Even though this doesn’t affect a Couplet directly, it may affect the left and right components of it.)
algebraixlib.util.latexprinter.set_to_latex(set_: algebraixlib.mathobjects.set.Set, short: bool = False, _depth: int = 0)[source]

Return a string that represents a Set in LaTeX markup.

This function sorts the input set_ to make the output consistent, so be careful with big sets. (Such large sets where this is a problem may not be suitable to display in LaTeX anyway.)

Parameters: set – The Set to be represented in LaTeX markup. short – (Optional) When set to True, a short version of the content is generated. Longer parts are abbreviated with ellipses (‘...’). Defaults to False. See also Config.short_set_len. _depth – (Optional) Internal use only. Indicate levels of nested (multi)sets. Is incremented for every nesting level. Default is 0.
algebraixlib.util.latexprinter.mset_to_latex(mset: algebraixlib.mathobjects.multiset.Multiset, short: bool = False, _depth: int = 0)[source]

Return a string that represents a Multiset in LaTeX markup.

This function sorts the input mset to make the output consistent, so be careful with big sets. (Such large multisets where this is a problem may not be suitable to display in LaTeX anyway.)

Parameters: mset – The Multiset to be represented in LaTeX markup. short – (Optional) When set to True, a short version of the content is generated. Longer parts are abbreviated with ellipses (‘...’). Defaults to False. See also Config.short_set_len. _depth – (Optional) Internal use only. Indicate levels of nested (multi)sets. Is incremented for every nesting level. Default is 0.