Skip to main content

Python Preprocessor for (La)TeX

Project description

PypTeX: the Python Preprocessor for TeX

Author: Sébastien Loisel

PypTeX is the Python Preprocessor for LaTeX. It allows one to embed Python code fragments in a LaTeX template file.

An example plot with PypTeX


pip install pyptex

  1. You will also need a LaTeX installation, and the default LaTeX processor is pdflatex.
  2. You need a Python 3 installation.

Hello, world

Put the following in example.tex:

@{from sympy import *}
$$\int x^3\,dx = @{S('integrate(x^3,x)')}+C$$

The command pyptex example.tex will generate example.pdf and an intermediary pure-LaTeX file example.pyptex. The resulting PDF can be found here

  • The pyptex executable tries to locate the Python 3 executable using /usr/bin/env python3. If this is causing you problems, try python -u -m pyptex example.tex instead.

Slightly bigger examples

  • 2d and 3d plotting tex | pdf
  • Matrix inverse exercise tex | pdf
  • The F19NB handout for numerical linear algebra at Heriot-Watt university is generated with PypTeX. pdf


If you want to use TeXShop on Mac, put the following into ~/Library/TeXShop/Engines/pyptex.engine and restart TeXShop:

pyptex $1


Detailed documentation can be found here

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyptex, version 1.3.3
Filename, size File type Python version Upload date Hashes
Filename, size pyptex-1.3.3.tar.gz (13.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page