Pysnip is a small project that I wrote for running
Python code from LaTeX. I found this workflow useful for autogenerating tables and reports on the fly, as in Chapter 13 of my dissertation.
Pysnip is based on python.sty
, which calls the Python executable directly from latex. That package is good and recommended for small jobs.
Pysnip instead generates external Python files, and these are run (possibly in parallel) using compmake (another project of mine which was essential to survival).
With pysnip you include arbitrary Python code using the \\py
command:
\usepackage{pysnip}
\py{ print('hello'); }
and then execute it as follows:
# creates files in snippets/
$ pdflatex file.tex
# run snippets
$ pysnip-make
# compile final file
$ pdflatex file.tex