3

I use Pythontex for formatting Python source code. I store code in a macro. I need to pass this code to one of the Pythontex commands (e.g. \pyv) and get the formatted code.

Code:

\documentclass{article}
\usepackage{pythontex}

\begin{document}
    \def\foo{x = 3}
    \pyv{\foo}
\end{document}

Result:

\foo

The macro \pys does this, but doesn't format the code.

  • 3
    Welcome to TeX.SE. You can use \expandafter\pyv\expandafter{\foo}. This causes the \foo macro to be expanded before \pyv. – frougon Jan 22 '20 at 18:47

0 Answers0