Main
Provides to_ltx to convert numpy arrays to LaTeX.
- numpyarray_to_latex.main.to_ltx(a, fmt='{:6.4f}', latexarraytype='array', imstring='i', is_row_vector=True, mathform=True, brackets='()', mark_elements=[], mark_color='pink', separate_columns=[], separate_rows=[])[source]
Return a LaTeX array given a numpy array.
- Parameters
a (numpy.ndarray) --
fmt (str, default = '{:6.2f}') -- python 3 formatter, optional- https://mkaz.tech/python-string-format.html
latexarraytype (str, default = 'array') --
Any of
"array" "pmatrix" "bmatrix" "vmatrix" "Vmatrix" "Bmatrix"
if "array", you can specifiy the brackets with the keyword
brackets
.imstring (str, default = 'i') -- Character to use to represent the imaginary unit. Usually
'i'
or'j'
is_row_vector (bool, default = True) -- If the array is 1D, should the output be a row (True) or column (False) vector?
mathform (bool, default = True) -- whether to convert strings like
1e+05
to1\times10^{5}
.brackets (iterable, default = '()') -- which brackets to use to wrap the matrix (must be two elements long). Use
brackets = None
if you don't want any brackets around the array.mark_elements (list, default = []) -- list of tuples containing element indices that should be marked with a colorbox.
mark_color (str, default = 'pink') -- The color with which to mark matrix elements.
separate_columns (list, default = []) -- list of column indices before which a vertical line should be drawn
separate_rows (list, default = []) -- list of row indices before which a horizontal line should be drawn
- Returns
out -- Formatted LaTeX string
- Return type
Examples
>>> from numpyarray_to_latex import to_ltx >>> tex = to_ltx([[2.,2.],[2.,2.]]) >>> print(tex) \left( \begin{array}{} 2.00 & 2.00\\ 2.00 & 2.00 \end{array} \right)