# Create transition inside a minted environment

I'm using minted to highlight some code. With the escapeinside I can add custom LaTeX code. For example:

\begin{minted}[escapeinside=||]{py}
def f(x):
y = x|\colorbox{green}{**}|2
return y
\end{minted}


now I'd like to add an efect to the beamer frame:

• show the code without the colorbox
• show the code with the colorbox

that would be a typical beamer transition modifier like <2->.

Trying to merge both features I tried:

...
y = x|<2->\colorbox{green}{**}|2
...


but it didn't worked: the <2-> was rendered as it.

Is it possible to add some effects like <2-> or \pause or equivalent inside a minted environment?

• You can help us to help you by providing the code for a small document that shows your problem. Just edit your question and add the code. Feb 14 '17 at 0:09
• Does the \colorbox{green} work? If yes you could simply use a custom colour and redefine it from white to green between the overlay. Feb 14 '17 at 0:11
• @samcarter, the \colorbox{} works. The text is rendered highlighted and the ** is enclosed in a green box. Feb 14 '17 at 10:02
• Can you make your code compilabale? This would be a great staring point. Feb 14 '17 at 10:08
• I filled a request in GH, check the suggestion there. Mar 2 '17 at 8:21

Instead of trying to bring overlays into minted, maybe redefining the colour between the overlays could be enough:

\documentclass{beamer}

\definecolor{mycolor}{rgb}{1,1,1}

\begin{document}

\begin{frame}<1-2>
\only<2>{\definecolor{mycolor}{rgb}{0,1,0}}
\colorbox{mycolor}{test}
\end{frame}

\end{document}


• the \only<2>{} trick worked for defined a color, any recommendation for conditionally define a command? Feb 28 '17 at 21:44
• @mmoya my recommendation is: tex.stackexchange.com/questions/353740/… Mar 1 '17 at 10:38