Type-safe LaTeX document generation with Python
Project description
pytex
Install
python -m venv venv && . venv/bin/activate
pip install -e . # add [dev] for pytest
SVG conversion needs inkscape. Compiling to PDF needs tectonic — if it
is not on PATH, pytex --build downloads a self-contained binary into a
temp folder and reuses it on later runs. Resolving glossaries/acronyms needs
makeindex from a TeX distribution (e.g. TeX Live).
The pytex command
pytex example.tex.py # render -> example.out.tex
pytex example.tex.py --build # render + compile -> build/example.out.pdf
The input is either:
- a
.pyfile exposing a module-level__pytex__variable that is aTeXnode (e.g. aDocument) — it is rendered, or - a
.texfile — wrapped inIncludeTeX(so\iffalse pytex(...) \fireplacements are evaluated) and rendered.
Options
| Flag | Default | Meaning |
|---|---|---|
-o, --output |
<input>.out.tex |
rendered LaTeX output path |
-b, --build |
off | compile the rendered .tex to PDF with tectonic |
--build-dir DIR |
build |
directory for artifacts and tectonic output |
--no-shell-escape |
shell-escape on | disable shell-escape |
Shell-escape is enabled by default because inline images decode their base64
payloads at compile time. The build runs tectonic, then makeindex (for
glossaries/acronyms), then reruns tectonic when an index changed.
Output is minimal and color-tagged (==>, note:, warning:, error:),
following tectonic's style; on failure it points at the likely cause and the
log file. Set NO_COLOR to disable color.
Markdown
pytex_markdown converts Markdown to native TeX nodes (via marko):
from pytex_markdown import Markdown, IncludeMarkdown
body = Markdown("# Title\n\nText with **bold**, `code`, [a link](https://x).")
body = IncludeMarkdown("notes.md", base_level=-1) # base_level=-1: # -> \chapter
Headings, emphasis, inline/fenced code, lists, links, images, block quotes and
thematic breaks map to the standard pytex library; text is LaTeX-escaped.
GitHub-style callouts become HSRT colored boxes (so the module depends on
pytex_hsrtreport):
> [!NOTE] -> InfoBox > [!IMPORTANT] -> ImportantBox
> [!TIP] -> SuccessBox > [!WARNING] -> WarningBox
Both factories are registered, so they are usable from \iffalse pytex(...) \fi
replacements in .tex sources too.
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 pytex_preprocessor-0.1.3.tar.gz.
File metadata
- Download URL: pytex_preprocessor-0.1.3.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12c8b942924b6c8a3dece59b1b24326dfad4b70547c251eb749a0a3f55d6db29
|
|
| MD5 |
a1803cdf15fd9f3a96cd20a3eeccb423
|
|
| BLAKE2b-256 |
3316a5d86048bb181aacca2c2a8b7abd258ec9e1a97f9943a1f4310ba83e3311
|
Provenance
The following attestation bundles were made for pytex_preprocessor-0.1.3.tar.gz:
Publisher:
release.yml on frederikbeimgraben/PyTeX-Preprocessor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytex_preprocessor-0.1.3.tar.gz -
Subject digest:
12c8b942924b6c8a3dece59b1b24326dfad4b70547c251eb749a0a3f55d6db29 - Sigstore transparency entry: 1699040130
- Sigstore integration time:
-
Permalink:
frederikbeimgraben/PyTeX-Preprocessor@9168a5e7a16f0ab9859b2efa8341bde121a7d162 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/frederikbeimgraben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9168a5e7a16f0ab9859b2efa8341bde121a7d162 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytex_preprocessor-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pytex_preprocessor-0.1.3-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e48cdbbc5c4c149e0dc60c283e088bc6406c96f25eb7187b691020a526dc1664
|
|
| MD5 |
dedf114db07727a427853512008c00e4
|
|
| BLAKE2b-256 |
07c4c683fe9c0641e72f2ee2e13b62661c54d72f4df64918920d3eaa5849ffb6
|
Provenance
The following attestation bundles were made for pytex_preprocessor-0.1.3-py3-none-any.whl:
Publisher:
release.yml on frederikbeimgraben/PyTeX-Preprocessor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytex_preprocessor-0.1.3-py3-none-any.whl -
Subject digest:
e48cdbbc5c4c149e0dc60c283e088bc6406c96f25eb7187b691020a526dc1664 - Sigstore transparency entry: 1699040566
- Sigstore integration time:
-
Permalink:
frederikbeimgraben/PyTeX-Preprocessor@9168a5e7a16f0ab9859b2efa8341bde121a7d162 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/frederikbeimgraben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9168a5e7a16f0ab9859b2efa8341bde121a7d162 -
Trigger Event:
push
-
Statement type: