Skip to main content

LaTeX <-> JSON parser/generator for structured math documents

Project description

The library transforms raw LaTeX files into a structured JSON format based on logical blocks. This allows LLMs to process mathematical content without being overwhelmed by LaTeX formatting commands. JSON Structure Produced

The parser outputs a consistent hierarchical structure:

env = "other": Capture plain text or LaTeX commands located outside any \begin...\end environment.

env = "theorem", "definition", "equation", etc.: Capture structured content from specific LaTeX environments.

Preamble Configuration 🛠️

The generator can prepend a LaTeX preamble to ensure the output is a stand-alone, compilable document. By default, it looks for a file named preambule.tex. Example preambule.tex

Create a preambule.tex in your working directory:

Note: Including \begin{document} in your preamble is required if you want the generated output to be directly compilable.

Usage (Python API) 🐍

  1. Parse a LaTeX file to JSON
  2. Parse raw LaTeX text directly
  3. Generate LaTeX from a JSON file
  4. Generate LaTeX from an in-memory JSON dictionary Command Line Interface (CLI) 💻

If enabled in your pyproject.toml, you can use the library directly from your terminal:

Convert LaTeX to JSON:

Convert JSON to LaTeX: Notes & Current Limitations ⚠️

Scope: The parser currently targets standard environments of the form \begin{ENV} ... \end{ENV}.

Metadata: Environment options (e.g., \begin{theorem}[Optional title]) are currently kept within the content block and not yet extracted as separate metadata.

Applications: This library is ideal for:

    RAG / AI Search: Indexing mathematical proofs by semantic chunks.

    Educational Platforms: Segmenting long courses into manageable units.

    Automated Publishing: Programmatically generating LaTeX documents from structured data.

Development 🛠️ License 📄

MIT

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

laguchori_latex-0.1.5.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

laguchori_latex-0.1.5-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file laguchori_latex-0.1.5.tar.gz.

File metadata

  • Download URL: laguchori_latex-0.1.5.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for laguchori_latex-0.1.5.tar.gz
Algorithm Hash digest
SHA256 4acff3cc2ee307eaf9c66183f1bb1724855822b64f1ffc4c59f015839c6c2224
MD5 6d736c4d8af342d02e092a41d10fb695
BLAKE2b-256 e6fd67d7f554b5566c9f16293a726d4d738b026431bc9f285b62b2827fb73066

See more details on using hashes here.

Provenance

The following attestation bundles were made for laguchori_latex-0.1.5.tar.gz:

Publisher: publish.yml on laguchoritarik/laguchori-latex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file laguchori_latex-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for laguchori_latex-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ff19efc8543a255977ec1dff9e4b8d8fad43078fc3c36ab1a59757bb726d732f
MD5 f331df1521735cf23406416372c6ff35
BLAKE2b-256 4c26706dea064086dd7581d94e0649bf7dcc86b86564dfdc6959cabcc178bbac

See more details on using hashes here.

Provenance

The following attestation bundles were made for laguchori_latex-0.1.5-py3-none-any.whl:

Publisher: publish.yml on laguchoritarik/laguchori-latex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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