| 1 |
=================================================================== |
| 2 |
The PythonTeX Package |
| 3 |
=================================================================== |
| 4 |
|
| 5 |
:Author: Geoffrey Poore |
| 6 |
:Version: 0.19 (2026/02/15) |
| 7 |
:License: LPPL v1.3 or later (LaTeX code) and BSD 3-Clause (Python code) |
| 8 |
:Development: https://github.com/gpoore/pythontex |
| 9 |
:Requirements: Python 2.7 or 3.2+; Pygments |
| 10 |
|
| 11 |
|
| 12 |
The PythonTeX package allows you to enter Python code within a LaTeX document, |
| 13 |
execute the code, and access its output in the original document. It also |
| 14 |
supports the Ruby, Julia, Octave, Sage, Bash, Rust, R, Perl, Perl 6, and |
| 15 |
JavaScript languages. |
| 16 |
|
| 17 |
PythonTeX provides fast, user-friendly access to Python from within LaTeX. |
| 18 |
Python code is only executed when it has been modified, or when it meets |
| 19 |
user-specified criteria. Code may be divided into user-defined sessions, |
| 20 |
which automatically run in parallel. Errors and warnings are synchronized |
| 21 |
with the LaTeX document, so that they refer to the document's line numbers. |
| 22 |
External dependencies can be tracked, so that code is re-executed when the |
| 23 |
data it depends on is modified. PythonTeX also provides syntax highlighting |
| 24 |
for code in LaTeX documents via the Pygments syntax highlighter. |
| 25 |
|
| 26 |
PythonTeX includes a "depythontex" utility that creates a copy of a document |
| 27 |
in which all Python code has been replaced by its output. This can be |
| 28 |
convenient for journal submissions, sharing documents, and converting to |
| 29 |
other formats. |
| 30 |
|
| 31 |
Consult pythontex_quickstart.pdf and pythontex_gallery.pdf to get |
| 32 |
started and for examples of what PythonTeX can do. |
| 33 |
|
| 34 |
Compiling a PythonTeX document involves three steps: |
| 35 |
|
| 36 |
1. Run latex (all Python code is saved to an auxiliary file) |
| 37 |
2. Run pythontex.py (all code is executed) |
| 38 |
3. Run latex again (Python output is inputted) |
| 39 |
|
| 40 |
See the main documentation in pythontex.pdf for detailed installation |
| 41 |
instructions. An installation script is provided for TeX Live and MiKTeX. |
| 42 |
Files should be installed in the directories indicated below. In summary, |
| 43 |
all files must be installed, and symlinks or launching wrappers should be |
| 44 |
created for pythontex.py and depythontex.py. |
| 45 |
|
| 46 |
* /doc/latex/pythontex/ |
| 47 |
|
| 48 |
- pythontex.pdf |
| 49 |
- README |
| 50 |
- pythontex_quickstart.tex |
| 51 |
- pythontex_quickstart.pdf |
| 52 |
- pythontex_gallery.tex |
| 53 |
- pythontex_gallery.pdf |
| 54 |
|
| 55 |
* /scripts/pythontex/ |
| 56 |
|
| 57 |
- pythontex.py, pythontex2.py, and pythontex3.py |
| 58 |
- pythontex_engines.py |
| 59 |
- pythontex_utils.py |
| 60 |
- depythontex.py, depythontex2.py, and depythontex3.py |
| 61 |
- syncpdb.py |
| 62 |
|
| 63 |
* /source/latex/pythontex/ |
| 64 |
|
| 65 |
- pythontex.dtx |
| 66 |
- pythontex.ins |
| 67 |
|
| 68 |
* /tex/latex/pythontex/ |
| 69 |
|
| 70 |
- pythontex.sty |