2

I am trying to come up with a beamer frame where some listing appears at the left column on overlay 1 and some other stuff appears in its place in overlay 2, while some stuff appears in the right column for both overlays. I came up with this minimal example, which doesn't work, giving me an error

Missing } inserted.
<inserted text> 
                }

If I comment out the \only<1>{}, it works, but not with it and I can't figure it out. Any help would be much appreciated.

\documentclass{beamer}
\usetheme{Madrid}
\usecolortheme{whale}
\beamertemplatenavigationsymbolsempty

\usepackage{listings}

\begin{document}
\begin{frame}[t,fragile]
    \frametitle{Test}

\begin{columns}
\begin{column}{0.4\textwidth}
\only<1>{
\vspace{1cm}
\begin{lstlisting}[language=SQL,mathescape, showstringspaces=false]
SELECT ENAME
FROM PROJ, ASG, EMP
\end{lstlisting}
}

\only<2>{
There is another line of text that I want to appear in left column in the \alert{second} overlay.
}
\end{column}

\begin{column}{0.4\textwidth}
\begin{center}

Some stuff that I want to appear on the right column on both overlays.

\end{center}
\end{column}

\end{columns}


\end{frame}
\end{document}
  • I should have also added that if I take out the listing and put in a regular text or something, it works. It seems to be a combination of overlays and listing (and perhaps even columns). – ozsu Jul 2 '15 at 13:40
1

Here a solution from this answer

\documentclass{beamer}
\usetheme{Madrid}
\usecolortheme{whale}
\usepackage{listings}

\setbeamertemplate{navigationsymbols}{}

\newsavebox{\mysavebox}


\begin{document}

\begin{lrbox}{\mysavebox}
\begin{lstlisting}[language=SQL,mathescape, showstringspaces=false]
SELECT ENAME
FROM PROJ, ASG, EMP
\end{lstlisting}
\end{lrbox}

\begin{frame}[t,fragile]
    \frametitle{Test}

\begin{columns}
\begin{column}{0.4\textwidth}

\only<1>{
\vspace{1cm}
\usebox{\mysavebox}
}
\only<2>{
There is another line of text that I want to appear in left column in the \alert{second} overlay.
}
\end{column}

\begin{column}{0.4\textwidth}
\begin{center}

Some stuff that I want to appear on the right column on both overlays.

\end{center}
\end{column}

\end{columns}


\end{frame}
\end{document}
  • Thank you. So, the solution is to make use of \lrbox construct. I'll try that. – ozsu Jul 2 '15 at 17:34

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.