我希望这个枚举列表包含以下内容:
- 只有问题标有(a)、(b)、(c)。答案根本不应该标有标签。
这六行应该逐行出现。一开始只显示第一个问题,按下下一页后显示答案。然后是第二个问题,然后是第二个答案……
\documentclass[]{beamer} \begin{document} \begin{frame} \frametitle{Example} \begin{enumerate}[(a)] \item<1-> Q: what is the answer to the first question? \item<2-> A: The answer is A. \item<3-> Q: what is the answer to the second question? \item<4-> A: The answer is B. \item<5-> Q: what is the answer to the second question? \item<6-> A: The answer is C. \end{enumerate} \end{frame} \end{document}
答案1
一种可能性是创建一个自定义的空item
命令:
\documentclass[]{beamer}
\newcommand{\answer}{\item[]} %new code
\begin{document}
\begin{frame}
\frametitle{Example}
\begin{enumerate}[<+->][(a)] %new code
\item Q: what is the answer to the first question?
\answer A: The answer is A.
\item Q: what is the answer to the second question?
\answer A: The answer is B.
\item Q: what is the answer to the second question?
\answer A: The answer is C.
\end{enumerate}
\end{frame}
\end{document}
我还删除了单独的覆盖规范并添加了一个+-
影响整个列表的操作符。
正如 @moewe 的评论所述,通过将重用元素添加到自定义项目定义中可以使代码更加紧凑:
\documentclass[]{beamer}
\newcommand{\answer}[1]{\item[] A: The answer is #1.} %new code
\newcommand{\question}{\item Q:} %new code
\begin{document}
\begin{frame}
\frametitle{Example}
\begin{enumerate}[<+->][(a)]
\question what is the answer to the first question?
\answer{A}
\question what is the answer to the second question?
\answer{B}
\question what is the answer to the second question?
\answer{C}
\end{enumerate}
\end{frame}
\end{document}
结果和以前一样。我没有对“答案是什么...”部分做同样的事情,因为我怀疑这些只是为了 MWE
答案2
只需用于[]
指定空项目标签即可。当然,您也可以为此类项目定义自己的宏。
\documentclass[]{beamer}
\begin{document}
\begin{frame}
\frametitle{Example}
\begin{enumerate}[(a)]
\item<1-> Q: what is the answer to the first question?
\item[]<2-> A: The answer is A.
\item<3-> Q: what is the answer to the second question?
\item[]<4-> A: The answer is B.
\item<5-> Q: what is the answer to the second question?
\item[]<6-> A: The answer is C.
\end{enumerate}
\end{frame}
\end{document}