Description

The LaTeX document preparation system is frequently used to create
scientific documents and presentations. This process is often
inefficient. The user must switch back and forth between the document
and external scientific software that is used for performing
calculations and creating figures.
PythonTeX is a LaTeX package
that allows Python code to be entered directly within a LaTeX document.
The code is automatically executed and its output is included within the
original document. The code may also be typeset within the document with
syntax highlighting provided by Pygments.

PythonTeX is fast and user-friendly. Python code is separated into user-
defined sessions, and each session is only executed when its code is
modified. When code is executed, sessions run in parallel. The contents
of stdout and stderr are synchronized with the LaTeX document, so that
printed content is easily accessible and error messages have meaningful
line numbering.

PythonTeX greatly simplifies scientific document creation with LaTeX.
For example, SymPy can be used to automatically solve and typeset
step-by-step mathematical derivations. It can also be used to automate
the creation of mathematical tables. Plots can be created with
matplotlib and then easily customized in place. Python code and its
output can be typeset side by side. The full power of Python is
conveniently available for programming LaTeX macros and customizing and
automating LaTeX documents.