python, pythontex and plots

Piet van Oostrum piet at vanoostrum.org
Tue Sep 24 14:38:00 EDT 2013


chitturk at uah.edu writes:

> True, I did not explain what I was trying to do.
>
> pythontex is a package that allows the inclusion of python code within a
> LaTeX document - (sort of like python.sty, but IMO, better) - I use
> it along with noweb to create documents that contain documentation,
> code and output of the code - and pythontex allows me to access variables
> within the python code embedded in the LaTeX - except for the case
> I mentioned ... Within the python code (inside the LaTeX document) I had
> a "savefig(outputfile)" and I was trying to reference the outputfile
> using \py{outputfile}

It could be that \includegraphics needs an expandable TeX form for its
filename, and \py probably isn't. I haven't tried pythontex yet (I
didn't know about it before your posting), so I can only guess. I am
going to try it out later. But if I am correct then the following might
work:

\newcommand{\filename}{}
\edef\filename{\py{outputfile}}

\includegraphics[scale=0.75]{\filename}

-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]



More information about the Python-list mailing list