
我想要這個枚舉清單包含以下內容:
- 僅問題標示 (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}