/arraytex

Convert NDArray and more to LaTeX

Primary LanguagePythonMIT LicenseMIT

ArrayTeX

PyPI Status Python Version License

Read the documentation at https://arraytex.readthedocs.io/ Tests Codecov

pre-commit Black

Convert a numpy.NDArray to various LaTeX forms.

>>> import numpy as np
>>> import arraytex as atx
>>> A = np.array([[1, 2, 3], [4, 5, 6]])
>>> print(atx.to_matrix(A))
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
\end{bmatrix}
>>> print(atx.to_tabular(A))
\begin{tabular}{c c c}
\toprule
Col 1 & Col 2 & Col 3 \\
\midrule
1 & 2 & 3 \\
4 & 5 & 6 \\
\bottomrule
\end{tabular}

Inspired by @josephcslater's array_to_latex.

Features

  • Support for matrix environments with different delimiters (bmatrix, pmatrix, etc.).
  • Support for tabular environments.
  • Support for builtin number formats (:.2f, :.3e, etc.).
  • Fully tested and typed.

Requirements

  • python >= 3.8

Installation

You can install ArrayTeX via pip from PyPI:

$ pip install arraytex

Usage

Please see the docs for more information.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, ArrayTeX is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

This project was generated from @cjolowicz's Hypermodern Python Cookiecutter template.