Skip to main content

Displays clear, colorful LaTeX expressions directly in the terminal.

Project description

Terminatex

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. See the LICENSE file for details.

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.1.0.tar.gz (3.7 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.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for terminatex-1.1.0.tar.gz
Algorithm Hash digest
SHA256 728325edd51d75669447abd1a3a38284d4ad411ab60351a0324d87dd8f1db93c
MD5 4be66c726ff72403f350efe5bdc5b3b9
BLAKE2b-256 3bbb2db96a65a3681eb5ef14bca3fd14e3de3e09d4d40e695ebd1ec0f4c18322

See more details on using hashes here.

File details

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

File metadata

  • Download URL: terminatex-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c4fa0271cc877c37f93bdec14973f19d473e14b5b069978cd2c79bd2446d3f0
MD5 e3994a3c538815a2ed56df358b27ec05
BLAKE2b-256 80a39c0c2ef33091ba7cc5a0364cd12d0067a2d70dc229d5d8337994e7ddc54d

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