1 Answer
1

You may be interested in my PythonTeX package. It only executes Python code when it is modified, saves all Python-generated results, and provides persistence between environments/commands.

I expect that part of the problem you were running into in your example relates to the internal workings of \draw. I couldn't get an equivalent example to work with my package either, and received similar errors. However, the following example does work. Note that the pycode environment currently cannot be indented, so the formatting is a little different than your example. Also, the \py and \pyc are for inline use, when you don't need a whole environment. \pyc executes code, and \py returns a string representation of whatever it is given.

This is exactly what I was looking for. Thanks.
–
Neil GJul 31 '12 at 4:24

2

This works great. Is there any way to make it so that pythontex3 is automatically called by latexmk?
–
Neil GJul 31 '12 at 4:51

I don't use latexmk, but a quick glance at its documentation indicates this should be possible. See page 13 of the online pdf documentation, the section following the phrase "Advanced tricks". You would want to run LaTeX, then PythonTeX, then LaTeX again in each cycle.
–
G. PooreJul 31 '12 at 12:46

Yeah, an integration with latexmk would be really nice.
–
Frederick NordApr 30 '13 at 8:38