9

I want this enumerate list to the following things:

  1. Only the questions are labeled by (a), (b), (c). The answers should not be labeled at all.
  2. These six lines should appear one by one. At first, only the first question is shown, followed by its answer after I press next page. Then the second question, then the second answer, ...

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

enter image description here

2 Answers 2

12

One possibility is to create a custom empty item command:

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

I also removed the individual overlay specifications and added an +- operator that affects the entire list.

enter image description here


As noted in the comments by @moewe, the code can be made more compact by adding the reused elements to the custom items definitions:

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

The result is the same as as before. I'm not doing the same for the "what is the answer to..." parts because I suspect those are there just for the sake of the MWE

4
  • 1
    This <+-> option is an abbreviated version of <1->, <2->, ..., right?
    – JACKY Li
    Jan 1, 2014 at 12:40
  • 1
    @PatrickLi kind of, see this answer for an explanation of the +- usage.
    – Old Nick
    Jan 1, 2014 at 14:54
  • 1
    It might not be a bad idea to move the "A: " into the \answer as well \newcommand{\answer}{\item[] A: } and define a new command \newcommand{\question}{\item Q: } and use it as \question what is the answer to the first question \answer 42.
    – moewe
    Jan 2, 2014 at 8:54
  • 2
    @moewe Yes, I agree. Extending your reasoning, you could eventually want to add to the answer item the repetitive part, like \newcommand{\answer}[1]{\item[] A: The answer is #1.} And then use it as \answer{A}. I'll update my answer.
    – Old Nick
    Jan 2, 2014 at 10:45
8

Simply use [] to specify empty item labels. Definitely you can define your own macros as well for items like this.

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

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.