0

I'm making a lot of use of beamers "pop-up" [<+->] functionality. And I'd like to make also lstlisting envrionments pop-up. How can I do so?

Displaying listings works fine (thanks to [fragile]), but I can not pass [<+->] to \begin{lstlisting}[<+->] because it's interpreted as code to be listed (verbatim).

The listing is within a \column if this is important here.

\documentclass{beamer}
\usepackage{listings}

\begin{document}
\begin{frame}[fragile]
  \begin{columns}
    \column{.5\columnwidth}
    \begin{itemize}[<+->]
      \item one
      \item two
    \end{itemize}

    \column{.5\columnwidth}
    \begin{lstlisting}
mycode
    \end{lstlisting}
  \end{columns}
\end{frame}
\end{document}
2

You can use onlyenv:

\documentclass{beamer}
\usepackage{listings}

\begin{document}
  \begin{frame}[fragile]
    \begin{columns}
       \column{.5\columnwidth}
         \begin{itemize}[<+->]
           \item one
           \item two
         \end{itemize}

       \column{.5\columnwidth}
         \begin{onlyenv}<+->
           \begin{lstlisting}
mycode
           \end{lstlisting}
        \end{onlyenv}
    \end{columns}
  \end{frame}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.