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:
objectA static class with module configuration values.
-
colorize_output= True¶ If
True, add colors to the output. IfFalse, print black only.
-
short_atom_len= 10¶ Number of characters to print for ‘short’ length of
Atomvalues. The remainder of the elements is represented by an ellipsis (‘...’). Seemath_object_to_latexandiprint_latex.
-
short_set_len= 4¶ Number of elements to print for ‘short’ length of
Sets andMultisets. The remainder of the elements is represented by an ellipsis, followed by the number of not shown elements in parentheses (for example ‘... (15)’). Seemath_object_to_latexandiprint_latex.
-
-
algebraixlib.util.latexprinter.math_object_to_latex(mobj, short: bool = False, _depth: int = 0)[source]¶ Return a
stringthat represents aMathObjectonUndef()in LaTeX markup.This function sorts the input
mobjif it is aSetor aMultisetto 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
MathObjectorUndef(). - short – (Optional) When set to
True, a short version of the content is generated. Longer parts are abbreviated with ellipses (‘...’). Defaults toFalse. See alsoConfig.short_atom_lenandConfig.short_set_len. - _depth – (Optional) Internal use only. Indicate levels of nested (multi)sets. Is incremented for every nesting level. Default is 0.
- mobj – The instance that you want to translate into LaTeX. It must be a
-
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
mobjif it is aSetor aMultisetto 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_nameis 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 toFalse. See alsoConfig.short_atom_lenandConfig.short_set_len.
Note
This function imports from
IPythonand 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
stringthat represents the value of an Atom in LaTeX markup.Parameters: - atom – The
Atomto 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 toFalse. See alsoConfig.short_atom_len.
- atom – The
-
algebraixlib.util.latexprinter.couplet_to_latex(couplet: algebraixlib.mathobjects.couplet.Couplet, short: bool = False)[source]¶ Return a
stringthat represents a Couplet in LaTeX markup.Parameters: - couplet – The
Coupletto 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 toFalse. See alsoConfig.short_atom_lenandConfig.short_set_len. (Even though this doesn’t affect aCoupletdirectly, it may affect the left and right components of it.)
- couplet – The
-
algebraixlib.util.latexprinter.set_to_latex(set_: algebraixlib.mathobjects.set.Set, short: bool = False, _depth: int = 0)[source]¶ Return a
stringthat 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
Setto 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 toFalse. See alsoConfig.short_set_len. - _depth – (Optional) Internal use only. Indicate levels of nested (multi)sets. Is incremented for every nesting level. Default is 0.
- set – The
-
algebraixlib.util.latexprinter.mset_to_latex(mset: algebraixlib.mathobjects.multiset.Multiset, short: bool = False, _depth: int = 0)[source]¶ Return a
stringthat represents a Multiset in LaTeX markup.This function sorts the input
msetto 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
Multisetto 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 toFalse. See alsoConfig.short_set_len. - _depth – (Optional) Internal use only. Indicate levels of nested (multi)sets. Is incremented for every nesting level. Default is 0.
- mset – The