CTAN Comprehensive TeX Archive Network

Direc­tory macros/latex/contrib/pythontex

                  The PythonTeX Package

:Author:  Geoffrey Poore
:Version:  0.16 (2017/07/20)
:License:  LPPL v1.3 or later (LaTeX code) and BSD 3-Clause (Python code)
:Development:  https://github.com/gpoore/pythontex
:Requirements:  Python 2.7 or 3.2+; Pygments

The PythonTeX package allows you to enter Python code within a LaTeX
document, execute the code, and access its output in the original document.
It also supports the Ruby, Julia, Octave, Sage, Bash, and Rust languages.

PythonTeX provides fast, user-friendly access to Python from within LaTeX.
Python code is only executed when it has been modified, or when it meets
user-specified criteria.  Code may be divided into user-defined sessions,
which automatically run in parallel.  Errors and warnings are synchronized
with the LaTeX document, so that they refer to the document's line numbers.
External dependencies can be tracked, so that code is re-executed when the
data it depends on is modified.  PythonTeX also provides syntax highlighting
for code in LaTeX documents via the Pygments syntax highlighter.

PythonTeX includes a "depythontex" utility that creates a copy of a document
in which all Python code has been replaced by its output.  This can be
convenient for journal submissions, sharing documents, and converting to
other formats.

Consult pythontex_quickstart.pdf and pythontex_gallery.pdf to get
started and for examples of what PythonTeX can do.

Compiling a PythonTeX document involves three steps:

1. Run latex (all Python code is saved to an auxiliary file)
2. Run pythontex.py (all code is executed)
3. Run latex again (Python output is inputted)

See the main documentation in pythontex.pdf for detailed installation
instructions.  An installation script is provided for TeX Live and MiKTeX.
Files should be installed in the directories indicated below.  In summary,
all files must be installed, and symlinks or launching wrappers should be
created for pythontex.py and depythontex.py.

* /doc/latex/pythontex/

  - pythontex.pdf
  - pythontex_quickstart.tex
  - pythontex_quickstart.pdf
  - pythontex_gallery.tex
  - pythontex_gallery.pdf

* /scripts/pythontex/

  - pythontex.py, pythontex2.py, and pythontex3.py
  - pythontex_engines.py
  - pythontex_utils.py
  - depythontex.py, depythontex2.py, and depythontex3.py
  - syncpdb.py

* /source/latex/pythontex/

  - pythontex.dtx
  - pythontex.ins

* /tex/latex/pythontex/

  - pythontex.sty

Down­load the con­tents of this pack­age in one zip archive (1.7M).

python­tex – Run Python from within a doc­u­ment, type­set­ting the re­sults

The pack­age al­lows you to en­ter Python code within a doc­u­ment, ex­e­cute the code, and ac­cess its out­put in the orig­i­nal doc­u­ment.

Python code is only ex­e­cuted when it has been mod­i­fied, or when it meets user-spec­i­fied cri­te­ria. Code may be di­vided into user-de­fined ses­sions, which au­to­mat­i­cally run in par­al­lel.

Er­rors and warn­ings are syn­chro­nized with the doc­u­ment, so that they re­fer to the doc­u­ment's line num­bers. Ex­ter­nal de­pen­den­cies can be tracked, so that code is re-ex­e­cuted when the data it de­pends on is mod­i­fied. Python also pro­vides syn­tax high­light­ing for code in doc­u­ments via the Pyg­ments syn­tax high­lighter.

The pack­age pro­vides a de­python­tex util­ity, that cre­ates a copy of the doc­u­ment in which all Python code has been re­placed by its out­put. This is use­ful for jour­nal sub­mis­sions, shar­ing doc­u­ments, and con­ver­sion to other for­mats.

Ver­sion0.16 2017-07-20
Li­censesThe Project Public Li­cense 1.3
Copy­right2012–2017 Ge­of­frey M. Poore
Main­tainerGe­of­frey Poore
Con­tained inTeX Live as python­tex
MiKTeX as python­tex
See alsoperltex
Guest Book Sitemap Contact Contact Author