| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This package enables you to embed Python code (www.python.org) in LaTeX and insert the output into your LaTeX document.
Copy python.sty and runpy.py side by side with your document.
In you LaTeX document insert:
\usepackage{python}
...
\begin{python}
print("42")
\end{python}
Compile the document with the shell escape option and of course Python installed:
$ latex -shell-escape document.tex
or insert/change "shell_escape = t" in your texmf.cnf
Note: By default LaTeX and its variants disallowing calling of arbitrary shell commands. python.sty requires unrestricted to the shell in order to execute embedded Python scripts. When running python.sty you must execute latex or pdftex with either the -enable-write18 or -shell-escape command line argument to enabled access to the Python executable.
The package takes an optional key-value option (bin) that can be used to specify the python binary to use. (If not present python is used):
\usepackage[bin=python2.6]{python}
Python scripts, output, error and return files are saved by default in the same folder as the documents and the folder gets crowded quite easily, If the word subfolder is added to the options, these files will be served to a subfolder named py:
\usepackage[subfolder]{python}
Original discussion and examples at http://web.archive.org/web/20120423051102/http://pycurious.org/2011/12/the-ultimate-python-latex-environment/
| Back | FazBrowse Home | New Git URL |