Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

up vote 12 down vote accepted

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

share|improve this answer
1  
This <+-> option is an abbreviated version of <1->, <2->, ..., right? –  Patrick Li Jan 1 at 12:40
1  
@PatrickLi kind of, see this answer for an explanation of the +- usage. –  dcmst Jan 1 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 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. –  dcmst Jan 2 at 10:45
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.