LeanTeX lets you embed Lean 4 code snippets directly in LaTeX and render both Lean output and diagnostics inside your compiled PDF.
Before continuing, make sure you have all required tools installed (see the Requirements tab).
git clone https://github.com/rgrossharv/LeanTeX.git
cd LeanTeX
python3 -m pip install .
Developer install:
python3 -m pip install -e .
If older pip errors on bdist_wheel:
python3 -m pip install --upgrade pip setuptools wheel
leantex install-tex
\usepackage{leantex}
Build once:
leantex build path/to/file.tex
Watch mode:
leantex watch path/to/file.tex
Without global install:
PYTHONPATH=. python3 -m leantex build path/to/file.tex
\begin{lean}[name=demo,show=both]
#check Nat.succ
\end{lean}
Shared-context mode:
\usepackage[onefile]{leantex}
# or
\usepackage{leantexonefile}
Examples live in examples/minimal. Use the dedicated examples page to view source and output: open examples page.
minimal.tex — small demotest4.tex — larger sample using Mathlib importsFor full details, see the README.
Before installing LeanTeX, make sure your machine has:
pip)latexmk, listings, tcolorbox, and commentOptional but recommended for larger examples (such as test4.tex): run lake update and lake exe cache get in examples/minimal.
This page shows example source and rendered PDFs from examples/minimal.