# fbox and pythontex

Why this does not work?

\fbox{
\begin{pycode}
print (1+1)
\end{pycode}
}


Is there a way around?

• Could you expand your code to a MWE? – Alenanno Jul 10 '16 at 18:57
• @Alenanno I have been preceded by egreg (see answer below). – Primo Petri Jul 11 '16 at 6:41
• Yes, I saw that. Please remember about it next time. :) – Alenanno Jul 11 '16 at 8:52

You can't use the pycode environment in the argument to another command.

\documentclass{article}
\usepackage{pythontex}

\newsavebox{\pycodebox}

\begin{document}

\begin{lrbox}{\pycodebox}
\begin{pycode}
print (1+1)
\end{pycode}
\end{lrbox}

\fbox{\usebox{\pycodebox}}

\end{document}