Render LaTeX math and Sympy expressions to Sixel Terminal Graphics. Suuports any Math-enabled font, no LaTeX installation required.
Project description
sixelmath
Render LaTeX Math expressions or Sympy objects in the terminal using sixel graphics. Math rendering is done using ziamath, a pure-Python LaTeX math renderer that does not require a Latex installation. Any math-enabled truetype/opentype font may be used; STIXTwoMath-Regular is included and used by default. Also uses cairosvg, timg, and Pillow.
See list of sixel-supported terminal emulators here.
Usage
Command Line
Render a LaTeX expression:
sixelmath "\frac{1}{1+x}"
Options include:
- '-s': Font size in points
- '-f': Path to font file (must include MATH table)
- '-c': Color as a supported named color, or hex value such as
#FFFFFF - '-b': Background color as a supported named color, or hex value such as
#FFFFFF - '-m': Margin width in pixels
In POSIX environments, the font and background color are detected automatically if not manually specified.
Python
To render LaTeX from Python code:
from sixelmath import sixelmath
sixelmath(r'\frac{1}{1+x}')
Keyword arguments may be passed to sixelmath to change options:
color: Font color. A named terminal color like 'white', or RGB hex color such as#FFFFFFbgcolor: Background color.font: Path to a TTF or OTF font file. Must contain a MATH table. STIXTwoMath-Regular is used by default.fontsize: Font size in pixelsmargin: Pixel margin around the euqation
Sympy
Import the sixelmath.sympysixel module to install a Sympy Printer that automatically displays Sympy expressions as sixel graphics.
import sympy
from sixelmath import sympysixel
sympy.sympify('A * exp(-x^2)')
To change display format, use sixelmath.sixel_defaults, with the same keyword arguments listed above for sixelmath.
The sixel printer may be turned off using sympysixel.disable() and turned on with sympysixel.enable().
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sixelmath-0.1.tar.gz.
File metadata
- Download URL: sixelmath-0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bbb8b9687e62cd62ae4cf6d0d5551a16fab5913276691b53c670ddd20c77611
|
|
| MD5 |
50811d67382d096c28c0c5b45c70d234
|
|
| BLAKE2b-256 |
f54ea494845c430d9905982556028f80163f5079bcfe02f313385c65cca0b834
|
File details
Details for the file sixelmath-0.1-py3-none-any.whl.
File metadata
- Download URL: sixelmath-0.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5fbaeb416d88eb78ad3bd818b90ce2836ac135bbdca11aad8d1d7d543fdf5e7
|
|
| MD5 |
228d6df9fa3aabd7240a9fa98543a552
|
|
| BLAKE2b-256 |
ba94eecb89aa8ceab7527a71d52f5f6f3702e629a36968f4d01e53b3cf9b231a
|