Skip to main content
https://github.com/josephcslater/array_to_latex/actions/workflows/test.yml/badge.svg https://badge.fury.io/py/array-to-latex.png/ https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg PyPi Download stats https://mybinder.org/badge_logo.svg

The module array_to_latex converts a NumPy/SciPy array or Pandas Numerical DataFrame to a LaTeX array or table using Python 3.x style formatting of the result or a format usable for plotting within LaTeX using pgfplots. Note that as of 0.83 it does add the column formatting arguments (for example, {ccc…}) when the user chooses to use array. I’m happy to have someone create a better solution but this at least makes a copied array immediately usable. I prefer bmatrix or similar. `

Play with it on mybinder.org!

A NumPy-focused re-envisioned converter based, in part, on this is numpyarray_to_latex. Also, available pip install. It incorporates more sophisticated “sub” markup capabilities. Check it out!

1.0.1: Fix empty-array/DataFrame LaTeX corruption bug, migrate packaging to
pyproject.toml, add type hints, ruff linting, and coverage reporting.
1.0.0: Validate arraytype, fix docstring/doctest inaccuracies, remove unused
nargout parameter (breaking), make clipboard an optional install
extra, add unit tests and GitHub Actions CI.

See CHANGELOG.md for the full version history.

Install using pip install --user array_to_latex from your command prompt, not the Python prompt. If you want to use to_clp to copy results directly to your clipboard, install the optional extra with pip install --user array_to_latex[clipboard].

Please read the help. It explains all options. To try it, see the online mybinder.org demo. It documents illustrates application to numerical Pandas DataFrames.

import numpy as np
import array_to_latex as a2l
A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'array')

will print the LaTeX code to your output.

import numpy as np
import array_to_latex as a2l
A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
latex_code = a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'bmatrix', print_out=False)

will put the LaTeX code into variable latex_code.

import numpy as np
import array_to_latex as a2l
A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
a2l.to_clp(A, frmt = '{:6.2f}', arraytype = 'bmatrix')

will put the array onto your clipboard.

If you will be using the same conversion over and over, you can define your own by using a lambda function:

to_tex = lambda A : a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'bmatrix', mathform=True)
to_tex(A)

so you can now use your function to_tex repeatedly with your specified settings. More detailed information on usage is in the help.

import array_to_latex as a2l
help(a2l.to_ltx)

Interesting alternative approaches are np_array_to_latex and tab2latex (convert numpy array to longtable file).

Like this module, buy me a coffee!.

Metadata

Release files for array-to-latex 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for array-to-latex 1.0.1
File Size Uploaded
array_to_latex-1.0.1.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for array-to-latex 1.0.1
File Interpreter ABI Platform
array_to_latex-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / array_to_latex-1.0.1.tar.gz

Download URL array_to_latex-1.0.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c0a36db0a4c60fca6089937e47448396a9a53275c1ae330f8cb09a1abf4e994a
BLAKE2b-256 checksum
How to use checksums
b993f080f3b30b0bf6a259fc7b5865da5358165d33d2607689f7f497e0d01802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / array_to_latex-1.0.1-py3-none-any.whl

Download URL array_to_latex-1.0.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d1d327cc069720baa061099f04d350c57cd65c909b2479cc2cb7324d5525b40
BLAKE2b-256 checksum
How to use checksums
c33bbe9d7e54de2f4ffd160b9e4944d26203dc17f66866084b2d25f317573791
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.92

1 release file

0.91

1 release file

0.90

1 release file

0.83

1 release file

0.82

1 release file

0.81

1 release file

0.80

1 release file

0.76

1 release file

0.75

1 release file

0.73

1 release file

0.72

1 release file

0.71

1 release file

0.70

1 release file

0.61

1 release file

0.60

1 release file

0.52

2 release files

0.51

1 release file

0.50

1 release file

0.43

1 release file

0.42

1 release file

0.41

1 release file

0.40

1 release file

0.38

1 release file

0.37

1 release file

0.36

1 release file

0.35

1 release file

0.10

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page