scitex-tex
LaTeX helpers — export to .tex, compile to PDF, preview images, vector formatting.
Full Documentation · uv pip install scitex-tex[all]
Problem and Solution
| # | Problem | Solution |
|---|---|---|
| 1 | Brittle authoring — hand-written .tex needs manual escaping of _ / & / % plus the right pdflatex flags |
Two calls — export_tex writes .tex, compile_tex builds .pdf; CompileResult holds the pdf path + log |
| 2 | Slow previews — checking one math snippet means opening a full LaTeX project | One call — preview renders snippets to a matplotlib Figure, no system TeX needed |
| 3 | Manual vectors — wrapping labels in vector notation by hand is error-prone | One call — to_vec("AB") returns vector form with automatic fallback |
Quick Start
import scitex_tex as tx
# Convert a SciTeX-style writer doc → .tex
tx.export_tex(doc, "manuscript.tex")
# Compile .tex → .pdf (returns CompileResult)
result = tx.compile_tex("manuscript.tex")
# Render LaTeX snippets to a matplotlib Figure
fig = tx.preview([r"$\sum_{i=1}^N x_i$", r"$\alpha + \beta$"])
# Convert a string to LaTeX vector notation
tx.to_vec("AB") # → \overrightarrow{\mathrm{AB}}
Demo
import scitex_tex as tx
# 1) Render a math preview to a matplotlib Figure (no system TeX required)
fig = tx.preview([r"$\hat{\beta} = (X^\top X)^{-1} X^\top y$"])
fig.savefig("preview.png")
# 2) Export + compile a manuscript end-to-end
tx.export_tex(doc, "manuscript.tex")
result = tx.compile_tex("manuscript.tex")
print(result.pdf_path) # → manuscript.pdf
flowchart LR
A[Python writer doc] -->|export_tex| B[manuscript.tex]
B -->|compile_tex| C[manuscript.pdf]
D["r'\$\\hat\\beta\$'"] -->|preview| E[matplotlib Figure]
style C fill:#27ae60,stroke:#2c3e50,color:#fff
style E fill:#27ae60,stroke:#2c3e50,color:#fff
Figure 2. Demo flow. preview is matplotlib-only; compile_tex shells out to pdflatex/xelatex.
Installation
uv pip install "scitex-tex[all]"
Per-module extras
| Extra | Pulls in |
|---|---|
all |
dev + docs (recommended) |
dev |
pytest, pytest-cov, ruff |
docs |
Sphinx + RTD theme + myst-parser (docs build only) |
uv pip install -e ".[dev]" # editable install for contributors
scitex_tex/
├── _export.py # writer doc → .tex string + file; .tex → .pdf via pdflatex/xelatex
├── _preview.py # snippet → matplotlib Figure (no system TeX needed)
└── _to_vec.py # string → LaTeX \overrightarrow form
flowchart LR
Doc[Writer Doc<br/>Python dict/object] --> Exp[export_tex]
Exp --> Tex[manuscript.tex]
Tex --> Cmp[compile_tex]
Cmp --> Pdf[manuscript.pdf]
Snip[r'\$\\sum x_i\$'] --> Prv[preview]
Prv --> Fig[matplotlib Figure]
Label[AB] --> Vec[to_vec]
Vec --> Latex[r'\overrightarrow{\mathrm{AB}}']
Figure 1. Module layout. Three modules — export+compile, preview, vector notation — each callable independently.
1 Interfaces
Python API
import scitex_tex as tx
# Export — writer doc → .tex string + file
tx.export_tex(doc, "manuscript.tex")
# Compile — .tex → .pdf via pdflatex/xelatex; returns CompileResult
res = tx.compile_tex("manuscript.tex")
print(res.pdf_path, res.stdout)
# Preview — render LaTeX strings to a matplotlib Figure
fig = tx.preview([r"$\frac{1}{2}\sum x_i$", r"$\hat{\beta}$"])
fig.savefig("preview.png")
# Convert a string to LaTeX vector notation
tx.to_vec("AB") # → \overrightarrow{\mathrm{AB}}
Status
Standalone module from the SciTeX ecosystem. Dependencies: numpy, matplotlib,
scitex-plt, and scitex-dev (for optional imports). The umbrella package's scitex.tex import path
is preserved via a sys.modules-alias bridge.
Part of SciTeX
scitex-tex is part of SciTeX. Install via
the umbrella with pip install scitex[tex] to use as
scitex.tex (Python) or scitex tex ... (CLI).
Four Freedoms for Research
- The freedom to run your research anywhere — your machine, your terms.
- The freedom to study how every step works — from raw data to final manuscript.
- The freedom to redistribute your workflows, not just your papers.
- The freedom to modify any module and share improvements with the community.
AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.
License
AGPL-3.0-only (see LICENSE).
Metadata
Release files for scitex-tex 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| scitex_tex-0.1.8.tar.gz | 30.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scitex_tex-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.4 kB
Release files / scitex_tex-0.1.8.tar.gz
| Download URL | scitex_tex-0.1.8.tar.gz |
|---|---|
| Size | 30.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e27cda6a8b2c9ccfe9e9bc5a931b8c9ad1371eeb8c82bfaed0dacbaf076ee7f0
|
|
BLAKE2b-256 checksum How to use checksums |
31f4e471a49c7b511d9b2ddaa63b5fd6503e95c0737c6c34f93df8e8d78c1eb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / scitex_tex-0.1.8-py3-none-any.whl
| Download URL | scitex_tex-0.1.8-py3-none-any.whl |
|---|---|
| Size | 30.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23647378613fa95afbdb2d8123cc8320acdf5d39ecc82d03114a4f8b16098191
|
|
BLAKE2b-256 checksum How to use checksums |
cb9f8ce0ea3ab2641bb54244b969411249691930c21a4db65a981240a594bda8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|