结合列、列表和覆盖的 beamer 问题

结合列、列表和覆盖的 beamer 问题

我正在尝试设计一个投影仪框架,其中某些列表出现在覆盖层 1 的左列,而其他一些内容出现在覆盖层 2 中的位置,而某些内容出现在两个覆盖层的右列。我想出了一个最小示例,但它不起作用,并给出了错误

Missing } inserted.
<inserted text> 
                }

如果我注释掉\only<1>{},它就可以工作,但如果注释掉 ,它就不行,我搞不懂。任何帮助都将不胜感激。

\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}

答案1

这里有一个解决方案这个答案

\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}

相关内容