Skip to main content

Displays clear, colorful LaTeX expressions directly in the terminal.

Project description

Terminatex

GitHub Repo License: MIT

Display beautiful, high-fidelity LaTeX expressions and web images directly in your terminal.

terminatex is a Python utility that renders any LaTeX string or web image and displays it in modern terminals, providing a seamless way to visualize mathematical formulas and remote images without leaving your command-line environment.

Terminatex Demo

Features

  • High-Quality LaTeX Rendering using matplotlib
  • Display web images from any URL
  • True-color terminal display via term-image
  • Customizable LaTeX color options
  • Simple and intuitive API

Requirements

  • Python 3.8+
  • A modern terminal that supports true color (24-bit) and terminal graphics protocol
    • Recommended on Windows: Windows Terminal
    • Recommended on macOS: iTerm2, WezTerm
    • Recommended on Linux: Konsole, WezTerm, kitty

Installation

Install terminatex from PyPI:

pip install terminatex

Usage

Here's a complete example demonstrating how to render both LaTeX and a web image directly in your terminal:

# examples.py

from terminatex import display, display_from_url

def main():
    """
    Demonstrates both LaTeX and URL-based image rendering in the terminal using terminatex.
    """

    # --- 1. Display LaTeX from a string ---

    # Render Euler's Identity using white color
    print("--- Rendering LaTeX: Euler's Identity (in white) ---")
    display(r"e^{i\pi} + 1 = 0", color='white')

    # Render the Quadratic Formula in cyan
    print("\n--- Rendering LaTeX: The Quadratic Formula (in cyan) ---")
    display(r"x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}", color='cyan')

    # --- 2. Display an image from a URL ---

    # Render an image from the web: E = MC² illustration
    print("\n--- Rendering Image from URL: E = MC² ---")
    image_url = "https://media.istockphoto.com/id/515369312/id/vektor/kesetaraan-energi-massal.jpg?s=612x612&w=0&k=20&c=bvDzBI-X3joclfryFpMAhGDyD2-3nf6Y8wprtT0k7YU="
    display_from_url(image_url)

    print("\nDone.")

if __name__ == "__main__":
    main()

How It Works

For LaTeX (display):

  • matplotlib renders your LaTeX string into a high-resolution PNG image
  • This image is saved to a temporary file in your operating system's temp directory

For URLs (display_from_url):

  • requests fetches the image data from the web
  • The downloaded data is written to a temporary file

Display:

  • In both cases, the path to the temporary file is passed to the term-image library
  • term-image intelligently detects your terminal's capabilities and draws the image directly in your console

Cleanup:

  • Immediately after the image is drawn, the temporary file is deleted to avoid cluttering your disk

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terminatex-1.2.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terminatex-1.2.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file terminatex-1.2.0.tar.gz.

File metadata

  • Download URL: terminatex-1.2.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for terminatex-1.2.0.tar.gz
Algorithm Hash digest
SHA256 9f6c0b334ee9b6f209c2517c639e7eb1197d756a52e3e72836195df017f8a236
MD5 21029da1bf51b0d6fac943801a25eac5
BLAKE2b-256 a1f878acae8efe666b2e99423d36a340cab3647f13f1c8cc21e99233829f751e

See more details on using hashes here.

File details

Details for the file terminatex-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: terminatex-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for terminatex-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 632852d90ed01276c7957bac930ac521bb7b2a84314f08438cb8cc3e14d7d387
MD5 4f495cff3e669bea808faa91c9feb85c
BLAKE2b-256 17aa11ea2e2e3102959c9fad05ed7a277cbf38c627228061f701bfc56d23a3da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page