# Split enumerate over multiple slides without letting items share space in beamer

I want to display questions and answers in the following way in beamer:

\documentclass{beamer}

\begin{document}

\begin{frame}[t]{Equations}
Solve the equation
\begin{enumerate}
\only<1-2>{\item[1.] $x+1=0$ \\}
\only<2> {Answer: $x = -1$}
\only<3-4>{\item[2.] $x+3=0$ \\}
\only<4> {Answer: $x = -3$}
\end{enumerate}
\end{frame}

\end{document}


Importantly, I want:

• to have only one question per slide
• to have the answer appear after the question, without a new \item
• the items not to share space, ie that each item appears at the top of its slide

I can't find a way to have the above while keeping the enumerate counter running automatically, hence the hard-coded counters in the example above. Is there a simple way to have that as well?

Here is a proposal.

You can create custom counters for questions, and for the question and answer overlays. The rest is pretty straightforward : initialize the counters (\newcounter{}), set the counters (\setcounter{}), and increment (\stepcounter{} or \addtocounter{}).

% arara: lwpdflatex
\documentclass{beamer}

% Question counter
\newcounter{question}
% Question overlay counter
\newcounter{questionoverlay}
% Command that automatically increases counters in order to have
% Automatic question number in \item (including increments)
% Automatic overlay handling (including increments
\stepcounter{question}%
}
% Environment used to reset the counters with an optional starting number for the question counter
\newenvironment{myenumerate}[1][1]{%
\setcounter{question}{#1}%
\setcounter{questionoverlay}{1}%
\begin{enumerate}%
}{%
\end{enumerate}%
}

\begin{document}

\begin{frame}[t]{Equations}
Solve the equation
\begin{myenumerate}
\questionanswer{$x+1=0$}{$x = -1$}
\questionanswer{$x+3=0$}{$x = -3$}
\end{myenumerate}
\end{frame}

\begin{frame}[t]{Equations}
Solve the equation
\begin{myenumerate}[10]
\questionanswer{$x+1=0$}{$x = -1$}
\questionanswer{$x+3=0$}{$x = -3$}
\end{myenumerate}
\end{frame}

\end{document}