Declared in module PyLaTeX
class CallPython(Content) class Content class Input(Content) class Interactive(Content) class Plain(Content) class Python(Content) def PyLaTeX(value) def main(filename, outname=None) def split(text) string BI = '\\begin{interactive}\012' string BO = '\\begin{interactiveoutput}\012' string BP = '\\begin{Python}\012' string CP = '\\CallPython' instance CP_R = re.RegexObject instance string EI = '\\end{interactive}' string EO = '\\end{interactiveoutput}' string EP = '\\end{Python}' string IB = '\\input{' string IE = '}' instance IR = re.RegexObject instance list LaTeX_specials = [(<re.RegexObject instance at 81bb8a0>, '\\textbackslash'), (<re.RegexObject instance at 81bb9c8>, '\\{'), (<re.RegexObject instance at 81bbb08>, '\\}'), (<re.RegexObject instance at 81bbc48>, '\\_')] instance RI = re.RegexObject instance instance RO = re.RegexObject instance instance RP = re.RegexObject instance string __author__ = 'Berthold H\366llmann, bhoel@starship.python.net' string __file__ = '../PyLaTeX/LaTeXPy.pyc' string __version__ = '1.5' instance _interp = code.InteractiveConsole instance instance loopR = re.RegexObject instance instance tot_R = re.RegexObject instance alias RE = re.escape (type function)
Latex Python Preprocessor For Interactive Accuracy and Inline Calculation
This code was inspired from proc.py ((c) 1999 David Ascher)
\begin{interactive}
x = 3
print x
x / 0
\end{interactive}
\begin{interactive}
x = 3
print x # here's a comment
x / 0
\end{interactive} \begin{interactiveoutput}
>>> \textbf{x = 3}
>>> \textbf{print x }\textit{\# here's a comment}
3
>>> \textbf{x / 0}
Traceback (innermost last):
File "<console>", line 1, in ?
ZeroDivisionError: integer division or modulo
\end{interactiveoutput}
...
\usepackage{python}
...
\begin{Python}
from math import *
\end{Python}
...
This is a TEST: $\sin{\pi/4} = \CallPython{sin(PI/4)}$
...
...
\usepackage{python}
...
\begin{Python}
from math import *
\end{Python}
...
This is a TEST: $\sin{\pi/4} = \CallPython[{0.707106781187}]{sin(PI/4)}$
...
\usepackage{alltt}
\usepackage{verbatim}
\newenvironment{interactive}{\comment}{\endcomment}
\newenvironment{interactiveoutput}{\alltt}{\endalltt}
\newenvironment{Python}{\comment}{\endcomment}
\DeclareRobustCommand{\CallPython}[2][{}]{{#1}}
The environments must not contain LaTeX comments, but python comments are allowed.
The use of loops and class or function definitions are a bit tricky.
The code lines ate handeled like keyd in at the python promt. This
means the the definitions have to be closed by an empty line. Leading
and trailing empty lines are removed in interactive. So when the
definition is placed at the end of an interaction environment it has
to be saved by a comment.
LaTeXPy handels the \input command by also parsing the file
included. You can use all variables definde in the master file, they
are avaible in the subfile.
LaTeX_specials. LaTeX_specials is a list of pairs,
the first element beeing a regular expression object, the second the
string to insert. A tuple is for example:(re.compile(r"_"), r"\_")
This entry replaces all occurences of an underscore _ with the LaTeX
escape sequence for the underscpre \_.
The mainloop for proccessing. This can be called after importing LaTeXPy.
Split the text.