2

I'm trying to print the value of str from the pycode environment, however, it doesn't work. Interestingly \pyc{print(str)} works. Can someone please show me how to get the pycode environment to work.

\documentclass{article}
\usepackage{pythontex}

\newcommand{\setstring}[1]{\pyc{str="#1"}}

\begin{document}
\setstring{hello pluto}

The value of str is:
\begin{pycode}
  print(str)
\end{pycode}
\end{document}
Andrew
  • 73

1 Answers1

2

You need to run a second pass, after you compile it with pythontex, like this

pdflatex foo.tex
/usr/local/texlive/2014/texmf-dist/scripts/pythontex/pythontex.py  foo.tex
pdflatex foo.tex

Now it should show up.

Change the path to pythontex.py as need per your installation

Nasser
  • 20,220