有没有办法在\only
Beamer 演示文稿的各个部分中使用列表?
以下是我想要实现的一个示例:
\documentclass{beamer}
\usetheme[height=7mm]{Boadilla}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]
\frametitle{Brokenframe}
\begin{columns}[c]
\column{0.25\textwidth}
\column{.5\textwidth}
\centering
\only<1>{
\lstset{language=Haskell}
\begin{lstlisting}<1>
data SM m = CSR m | COO m | Dense M
\end{lstlisting}
}
\only<2>{
\begin{align*}
M &= \begin{bmatrix}
1 & 1 & \cdots & 1
\end{bmatrix}
\end{align*}
}
\column{0.25\textwidth}
\end{columns}
\end{frame}
\end{document}
但是,当我尝试编译它时,它出现以下错误:
./broken.tex:30: Missing } inserted. [ \end{frame}]
./broken.tex:30: LaTeX Error: \begin{lstlisting} on input line 14 ended by \end{beamer@framepauses}. [ \end{frame}]
./broken.tex:30: Extra }, or forgotten \endgroup. [ \end{frame}]
./broken.tex:30: LaTeX Error: \begin{lstlisting} on input line 14 ended by \end{beamer@frameslide}. [ \end{frame}]
./broken.tex:32: LaTeX Error: \begin{minipage} on input line 6 ended by \end{document}. [ \end{document}]
./broken.tex:32: You can't use `\end' in internal vertical mode. [ \end{document}]
./broken.tex:32: LaTeX Error: \begin{minipage} on input line 6 ended by \end{document}. [ \end{document}]
\only<1>{
我可以通过删除列表块周围的线条来修复上述错误}
,但是这会删除整个块的要点!
有人有办法解决这个问题吗?
答案1
只需替换\only<1>{...}
为\begin{onlyenv}<1>...\end{onlyenv}
。
这里:
\documentclass{beamer}
\usetheme[height=7mm]{Boadilla}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]
\frametitle{Brokenframe}
\begin{columns}[c]
\column{0.25\textwidth}
\column{.5\textwidth}
\centering
\begin{onlyenv}<1>
\lstset{language=Haskell}
\begin{lstlisting}
data SM m = CSR m | COO m | Dense M
\end{lstlisting}
\end{onlyenv}
\only<2>{
\begin{align*}
M &= \begin{bmatrix}
1 & 1 & \cdots & 1
\end{bmatrix}
\end{align*}
}
\column{0.25\textwidth}
\end{columns}
\end{frame}
\end{document}